Selectionner une fréquence ou plusieur

Signaler
Messages postés
40
Date d'inscription
dimanche 11 janvier 2004
Statut
Membre
Dernière intervention
9 décembre 2006
-
Messages postés
2094
Date d'inscription
jeudi 16 septembre 2004
Statut
Membre
Dernière intervention
3 janvier 2022
-
bonjour

Voila le module de mon programmeen VB6, que doit je ajouter pour pouvoir selectionner une fréquence ex : 1000Hz  de facon a pouvoir incrementer un bargraph par exemple.
déja une fréquence ce serait cool.

Merci d'avance  

Module :

Option Explicit


Public DevHandle As Long 'Handle of the open audio device


Public Visualizing As Boolean
Public Divisor As Long


Public ScopeHeight As Long 'Saves time because hitting up a Long is faster
                            'than a property.
                           
Public Type WaveFormatEx
    FormatTag As Integer
    Channels As Integer
    SamplesPerSec As Long
    AvgBytesPerSec As Long
    BlockAlign As Integer
    BitsPerSample As Integer
    ExtraDataSize As Integer
End Type


Public Type WAVEHDR
    lpData As Long
    dwBufferLength As Long
    dwBytesRecorded As Long
    dwUser As Long
    dwFlags As Long
    dwLoops As Long
    lpNext As Long 'wavehdr_tag
    Reserved As Long
End Type


Public Type WAVEINCAPS
    ManufacturerID As Integer      'wMid
    ProductID As Integer       'wPid
    DriverVersion As Long       'MMVERSIONS vDriverVersion
    ProductName(1 To 32) As Byte 'szPname[MAXPNAMELEN]
    Formats As Long
    Channels As Integer
    Reserved As Integer
End Type


Public Const WAVE_INVALIDFORMAT = &H0&                 '/* invalid format */
Public Const WAVE_FORMAT_1M08 = &H1&                   '/* 11.025 kHz, Mono,   8-bit
Public Const WAVE_FORMAT_1S08 = &H2&                   '/* 11.025 kHz, Stereo, 8-bit
Public Const WAVE_FORMAT_1M16 = &H4&                   '/* 11.025 kHz, Mono,   16-bit
Public Const WAVE_FORMAT_1S16 = &H8&                   '/* 11.025 kHz, Stereo, 16-bit
Public Const WAVE_FORMAT_2M08 = &H10&                  '/* 22.05  kHz, Mono,   8-bit
Public Const WAVE_FORMAT_2S08 = &H20&                  '/* 22.05  kHz, Stereo, 8-bit
Public Const WAVE_FORMAT_2M16 = &H40&                  '/* 22.05  kHz, Mono,   16-bit
Public Const WAVE_FORMAT_2S16 = &H80&                  '/* 22.05  kHz, Stereo, 16-bit
Public Const WAVE_FORMAT_4M08 = &H100&                 '/* 44.1   kHz, Mono,   8-bit
Public Const WAVE_FORMAT_4S08 = &H200&                 '/* 44.1   kHz, Stereo, 8-bit
Public Const WAVE_FORMAT_4M16 = &H400&                 '/* 44.1   kHz, Mono,   16-bit
Public Const WAVE_FORMAT_4S16 = &H800&                 '/* 44.1   kHz, Stereo, 16-bit


Public Const WAVE_FORMAT_PCM = 1


Public Const WHDR_DONE = &H1&              '/* done bit */
Public Const WHDR_PREPARED = &H2&          '/* set if this header has been prepared */
Public Const WHDR_BEGINLOOP = &H4&         '/* loop start block */
Public Const WHDR_ENDLOOP = &H8&           '/* loop end block */
Public Const WHDR_INQUEUE = &H10&          '/* reserved for driver */


Public Const WIM_OPEN = &H3BE
Public Const WIM_CLOSE = &H3BF
Public Const WIM_DATA = &H3C0


Public Declare Function waveInAddBuffer Lib "winmm" (ByVal InputDeviceHandle As Long, ByVal WaveHdrPointer As Long, ByVal WaveHdrStructSize As Long) As Long
Public Declare Function waveInPrepareHeader Lib "winmm" (ByVal InputDeviceHandle As Long, ByVal WaveHdrPointer As Long, ByVal WaveHdrStructSize As Long) As Long
Public Declare Function waveInUnprepareHeader Lib "winmm" (ByVal InputDeviceHandle As Long, ByVal WaveHdrPointer As Long, ByVal WaveHdrStructSize As Long) As Long


Public Declare Function waveInGetNumDevs Lib "winmm" () As Long
Public Declare Function waveInGetDevCaps Lib "winmm" Alias "waveInGetDevCapsA" (ByVal uDeviceID As Long, ByVal WaveInCapsPointer As Long, ByVal WaveInCapsStructSize As Long) As Long


Public Declare Function waveInOpen Lib "winmm" (WaveDeviceInputHandle As Long, ByVal WhichDevice As Long, ByVal WaveFormatExPointer As Long, ByVal CallBack As Long, ByVal CallBackInstance As Long, ByVal Flags As Long) As Long
Public Declare Function waveInClose Lib "winmm" (ByVal WaveDeviceInputHandle As Long) As Long


Public Declare Function waveInStart Lib "winmm" (ByVal WaveDeviceInputHandle As Long) As Long
Public Declare Function waveInReset Lib "winmm" (ByVal WaveDeviceInputHandle As Long) As Long
Public Declare Function waveInStop Lib "winmm" (ByVal WaveDeviceInputHandle As Long) As Long


Public Const PI As Double = 3.1415
Public Const NumSamples = 1024


Public Wave As WAVEHDR
Public InData(0 To NumSamples - 1) As Integer


Public LastVolLeft As Double
Public LastVolRight As Double
Public VolLeft As Double
Public VolRight As Double


Sub InitDevices()
    Dim Caps As WAVEINCAPS, Which As Long
    frmMain.DevicesBox.Clear
    For Which = 0 To waveInGetNumDevs - 1
        Call waveInGetDevCaps(Which, VarPtr(Caps), Len(Caps))
        If Caps.Formats And WAVE_FORMAT_1S16 Then
            Call frmMain.DevicesBox.AddItem(StrConv(Caps.ProductName, vbUnicode), Which)
        End If
    Next
    If frmMain.DevicesBox.ListCount = 0 Then
        MsgBox "You have no audio input devices!", vbCritical, "Ack!"
    End If
    frmMain.DevicesBox.ListIndex = 0
End Sub


Public Sub DoStop()
    DevHandle = 0
    Call waveInReset(DevHandle)
    Call waveInClose(DevHandle)
End Sub

3 réponses

Messages postés
2094
Date d'inscription
jeudi 16 septembre 2004
Statut
Membre
Dernière intervention
3 janvier 2022
1
Ce qu'il faut rajouter ? Plein de chose...
Regarde de ce coté : http://www.vbfrance.com/codes/FFT-CALCUL-SPECTRE-FILTRAGE_30471.aspx

Flachy Joe
Messages postés
40
Date d'inscription
dimanche 11 janvier 2004
Statut
Membre
Dernière intervention
9 décembre 2006

bonjour et maerci flachy Joe,

Ce n'est pas tellement Fourier et ses algoritmes qui m'interesse mais comment peux t'on faire pour selectionner q'une fréquence (exemple reprit si dessus 1000Hz) d'un son pour avoir une variable qui incrementer un bargraph .

Merci
Messages postés
2094
Date d'inscription
jeudi 16 septembre 2004
Statut
Membre
Dernière intervention
3 janvier 2022
1
Ben, il faut justement calculer le spectre (courbe de l'intensité du son en fonction de la frequence) et recuperrer la valeur de celui çi à la frequence voulue.

Flachy Joe