MCI Wav Recording - Set Buffer Size/Location? 
Author Message
 MCI Wav Recording - Set Buffer Size/Location?

Hello everyone, I've been away from the newsgroups for quite a while. But I
have encountered a problem and I'm hoping you all will take mercy on me for
my disloyalty. Plus, I think this is a pretty challenging API question.
Here's the scenario:

I am trying to create a relatively simple program to record wav files (from
audio input). In the past I have used programs like SoundForge and CoolEdit
to do this, but they both seem to be limited to 2GB. However, I would like
to be able to record for longer periods of time. I would also like to add
some timing functionality to make it start and stop recording at specified
intervals (ie. to record a show on the radio while I'm away)...

So I have created a program that successfully uses mciSendString to open
waveaudio, start recording, and save to a wav file. I even figured out
settings for stereo, bit rate, etc. However, it is using my C: drive by
default for a buffer, and I only have about 700MB free there, so that's not
really helping. I'd like to tell it to use another drive for the buffer, or
perhaps several drives. But just one would be sufficient. So does anyone
have any idea how to change the buffer location so I can do this? I'll
include the important parts of my code at the bottom of this message, but if
you would like to see the full code, I am happy to send the whole app. Just
send me an email.

I'd be very grateful if you could forward responses to my email as well:

Geoff Glaze (aka Goffredo)

Public Function WavRecordOpenFile() As Boolean

    WavRecordOpenFile = False

    If MyMciSendString("close all") Then
        ' just in case...
    End If
    If MyMciSendString("open waveaudio") Then
        If MyMciSendString("open new type waveaudio alias gwavrec") Then
            WavRecordOpenFile = True
        End If
    End If

End Function

Public Function WavRecordCloseFile(sFile As String) As Boolean

    WavRecordCloseFile = False

    If MyMciSendString("save gwavrec " & sFile) Then
        If MyMciSendString("close gwavrec") Then
            WavRecordCloseFile = True
        End If
    End If

End Function

Public Function WavStartRecord() As Boolean

    If MyMciSendString("set gwavrec time format ms bitspersample 16 channels
2 samplespersec 44100") Then
    End If

    WavStartRecord = MyMciSendString("record gwavrec")

End Function

Public Function WavStopRecord() As Boolean

    WavStopRecord = MyMciSendString("stop gwavrec")

End Function

Public Function MyMciSendString(lpstrCommand As String) As Boolean
    Dim lRet As Long
    Dim sRet As String

    MyMciSendString = False

    On Local Error Resume Next

    sRet = Space(128)
    lRet = mciSendString(lpstrCommand, sRet, 128, 0&)
    sRet = StringFromBuffer(sRet)

    If lRet <> 0 Then
        MsgBox "mciSendString " & lpstrCommand & vbCrLf & "Error: " &
Format(lRet) & vbCrLf & sRet & vbCrLf & MyMciErrorString(lRet),
        MsgBox "mciSendString " & lpstrCommand & vbCrLf & sRet
        MyMciSendString = True
    End If

End Function

Public Function MyMciErrorString(lErr As Long) As String
    Dim sErr As String
    Dim lRet As Long
    sErr = Space(128)
    lRet = mciGetErrorString(lErr, sErr, 128&)
    MyMciErrorString = StringFromBuffer(sErr)
End Function

Public Function StringFromBuffer(Buffer As String) As String
    Dim nPos As Long

    nPos = InStr(Buffer, vbNullChar)
    If nPos > 0 Then
        StringFromBuffer = Left$(Buffer, nPos - 1)
        StringFromBuffer = Buffer
    End If
End Function

Mon, 16 Sep 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. MCI wav Record How to clear buffer

2. Recording wav file with MMControl (MCI)

3. Using the MCI Multimedia to record Wav files

4. MCI Control: Recording and deleting wav file

5. Problem setting the MSCOMM transmit buffer size.

6. Buffer size error while updating record ?

7. Run Time Change of DB Location, Setting Passwords, and Rpt Location

8. Buffering MCI to memory

9. How to set te quality when recording WAV files using MCI? (VB3)

10. Record Set Guru's - Can't Create Record Set error 429

11. Record Set Guru's - Can't Create Record Set error 429

12. help: Getting a wav file to the buffer (Modem)


Powered by phpBB® Forum Software