Bonjour

Mon besoin est d'enregistrer un son par le microphone pour pouvoir l'analyser par une transformée de fourrier afin d'en déterminer les fréquences.

Afin d'apprivoiser la commande mciSendString, j'ai écrit un tout petit bout de programme qui ouvre/ferme le tiroir de mon lecteur de CD. Le but étant de lancer un traitement lors de la signification de la fin d'exécution de la commande (utilisation de "notify" dans la commande d'ouverture) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
Private Sub Command1_Click()
  ' Set up the custom window procedure for use with Form1.
  pOldProc = SetWindowLong(Form1.hWnd, GWL_WNDPROC, AddressOf WindowProc)
 
  t = mciSendString("set cdaudio door open notify", Nil, 0, Form1.hWnd)
  Dim tata As String * 100
  t = mciGetErrorString(t, tata, 100)
  Debug.Print tata
 
End Sub
 
Private Sub Command2_Click()
 
  t = mciSendString("set cdaudio door closed", Nil, 0, 0)
  Dim tata As String * 100
  t = mciGetErrorString(t, tata, 100)
  Debug.Print tata
 
End Sub
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Public Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, _
      ByVal lParam As Long) As Long
   Dim mbtext As String  ' text of message box
   Dim retval As Long    ' return value
 
   ' If the notification message is received, tell the user how
   ' the playback of the MIDI file concluded.
   Select Case uMsg
   Case MM_MCINOTIFY
      Select Case wParam
      Case MCI_NOTIFY_ABORTED
         mbtext = "Playback of the MIDI file was somehow aborted."
      Case MCI_NOTIFY_FAILURE
         mbtext = "An error occured while playing the MIDI file."
      Case MCI_NOTIFY_SUCCESSFUL
         mbtext = "Playback of the MIDI file concluded successfully."
      Case MCI_NOTIFY_SUPERSEDED
         mbtext = "Another command requested notification from this device."
      End Select
      retval = MsgBox(mbtext, vbOKOnly Or vbInformation)
      WindowProc = 0
   Case Else
      retval = CallWindowProc(pOldProc, hWnd, uMsg, wParam, lParam)
   End Select
End Function
Mon problème est que si je reçois bien les messages dans la procédure WindowProc après exécution de Command1_Click, je ne vois jamais passer le message MM_MCINOTIFY !...

Où se situe mon erreur ?

Merci de votre aide

Eric (nouveau sur le forum)