Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

VB MMControl and Recording.

Options
  • 24-08-2009 4:50pm
    #1
    Registered Users Posts: 721 ✭✭✭


    I've made an app in VB for recording, works fine. It'll record from whatever the default recording device is and saves it before the app ends. The code (Very basic at the moment, just trying to prove the concept) is here if that would be of benefit to anyone:
    Private Sub Form_Load()
    MMControl1.Notify = False
    MMControl1.Wait = True
    MMControl1.Shareable = False
    MMControl1.DeviceType = "WaveAudio"
    MMControl1.FileName = App.Path &"\Recorded Audio 42.wav"
    MMControl1.Command = "Open"
    MMControl1.Command = "Record"
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    MMControl1.Command = "Save"
    MMControl1.Command = "Close"
    End Sub
    

    However, when it records it records in shameful quality. Just above a telephone conversation. Is there any way I can change the sample rate and bitrate or is it doomed to record in quality this bad forever?


Comments

  • Registered Users Posts: 2,931 ✭✭✭Ginger


    You can do this, but its not as easy as .Bitrate = 16 for example

    So

    Public Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long

    Public 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


    dim RetLng as long
    RetLng = mciSendString("set recwav time format ms bitspersample 16 channels 1 samplespersec 16000", 0, 0, 0)

    This will set for 16Khz recording


  • Registered Users Posts: 721 ✭✭✭mk6705


    Thanks Ginger,
    I added a module to the project and put the following into it:
    Dim RetLng As Long
    
    Public Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
    
    Public 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
    

    Then, in the actual form I put:
    Private Sub Form_Load()
    RetLng = mciSendString("set recwav time format ms bitspersample 16 channels 2 samplespersec 44100", 0, 0, 0)
    End Sub
    

    As you can see, I changed the channels and samplerate to suit me.
    However, it's still recording in the default. Anything I'm going wrong that you can see?

    Thanks for your help again.


  • Registered Users Posts: 2,931 ✭✭✭Ginger




  • Registered Users Posts: 721 ✭✭✭mk6705


    Ginger wrote: »

    Hi Ginger, I saw it said recwav instead of recwave so I changed this, to no avail...
    Will it affect an active MMControl on the form or will this only work for commanding the DLL to record directly?


  • Registered Users Posts: 721 ✭✭✭mk6705


    Ok I ditched the MMControl and am now sending commands to winmm.dll. It won't accept spaces in the filename (I don't think there's anything I can do with this so I'll use underscores) but I set all the settings...and it still records in bad quality. It makes a big file but it only fills in a small bit then fills the rest of it with crap so I have a big file yet in crap quality. Is there some bit rate setting I should set that I'm missing?


  • Advertisement
Advertisement