'Em um módulo classe:
Option Explicit
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
'retorna erro de retorno de STATUS
Private Sub PrintMCIStatus(Code As Long)
Dim ErrorMsg As String
ErrorMsg = String$(1024, vbNullChar) 'buffer para armazenar erro
mciGetErrorString Code, ErrorMsg, 1024 ' pega erro
ErrorMsg = Left(ErrorMsg, InStr(1, ErrorMsg, vbNullChar) - 1) 'limpa vazios
Debug.Print ErrorMsg
End Sub
'inicia bufferizacao - hwnd de form
Public Sub Record(ByVal hwnd As Long)
PrintMCIStatus mciSendString("open new type waveaudio alias Temp wait", vbNullString, 0, 0)
PrintMCIStatus mciSendString("seek Temp to start wait", vbNullString, 0, 0)
PrintMCIStatus mciSendString("record Temp overwrite notify", vbNullString, 0, hwnd)
End Sub
'toca arquivo Temp - c:windowsdesktoparquivo.mp3 ou c:windowsdesktoparquivo.wav
Public Sub PlaySound(ByVal FileName As String)
On Error Resume Next
PrintMCIStatus mciSendString("open """ & FileName & """ alias Temp wait", vbNullString, 0, 0)
PrintMCIStatus mciSendString("seek Temp to start wait", vbNullString, 0, 0)
PrintMCIStatus mciSendString("play Temp", vbNullString, 0, 0)
End Sub
'grava arquivo>>> C:windowsdesktoparquivo.wav
Public Sub StopSaveRecord(ByVal Arquivo As String)
PrintMCIStatus mciSendString("stop Temp", vbNullString, 0, 0)
PrintMCIStatus mciSendString("save Temp """ & Arquivo & """", vbNullString, 0, 0)
PrintMCIStatus mciSendString("close Temp", vbNullString, 0, 0)
End Sub
'converte de wav para mp3 >>> c:windowsdesktopArq.wav e c:windowsdesktopArq.mp3
Public Sub Converter(ByVal FileName As String, Optional ByVal NewFileName As String = "")
On Error Resume Next
Dim Tempo As Double
Shell "lame.exe -h """ & FileName & """ """ & NewFileName & """", vbHide
'aguarda enquanto arquivo nao convertido ou tempo de conversao estourou
Tempo = Timer
Do
DoEvents
Loop While Len(Dir(NewFileName, vbNormal)) = 0 And Tempo + 3 > Timer
End Sub
'Encerrar Arquivo sem gravar (e para caso de play)
Public Sub EncerrarArquivo()
PrintMCIStatus mciSendString("close Temp", vbNullString, 0, 0)
End Sub