News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

record from the microphone

Started by Fraile, December 20, 2019, 11:05:38 PM

Previous topic - Next topic

Fraile

Hi everyone, I want to record the voice, from the microphone. When I open the device, I get an error.

Example Code:

CapturaAudio Proto

.Const

.Data?

.Data
DeviceType      DB "waveaudio", 0
WavFile         DB "d:\TempFile.wav", 0

.Code

CapturaAudio Proc

Local wDeviceID:DWord
Local dwReturn:DWord
Local mciOpenParms:MCI_OPEN_PARMS
Local mciRecordParms:MCI_RECORD_PARMS
Local mciSaveParms:MCI_SAVE_PARMS
Local mciPlayParms:MCI_PLAY_PARMS

   Mov mciOpenParms.lpstrDeviceType, Offset DeviceType
   Mov mciOpenParms.lpstrElementName, NULL

   Invoke mciSendCommand, 0, MCI_OPEN, MCI_OPEN_ELEMENT + MCI_OPEN_TYPE + MCI_OPEN_SHAREABLE, Addr mciOpenParms
   Mov dwReturn, Eax

   Invoke PasarADecimal, Eax



   Mov Eax, mciOpenParms.wDeviceID
   Mov wDeviceID, Eax

   Mov mciRecordParms.dwTo, 60000
   Invoke mciSendCommand, wDeviceID, MCI_PLAY, MCI_FROM + MCI_WAIT, Addr mciPlayParms

   Mov mciSaveParms.lpFileName, Offset WavFile
   Invoke mciSendCommand, wDeviceID, MCI_SAVE, MCI_SAVE_FILE + MCI_WAIT, Addr mciSaveParms

   Invoke mciSendCommand, wDeviceID, MCI_CLOSE, 0, 0


   Xor Eax, Eax

   
   Ret
CapturaAudio EndP


help please.....

jj2007

Post complete code, and tell us which error

Fraile

Sorry,

The error gives, when, I record. number 274

The code until this error is this.

this code is inside a dll

CapturaAudio Proto


.Const

.Data?

.Data
DeviceType      DB "waveaudio", 0
WavFile         DB "d:\TempFile.wav", 0

.Code

CapturaAudio Proc

Local wDeviceID:DWord
Local dwReturn:DWord
Local mciOpenParms:MCI_OPEN_PARMS
Local mciRecordParms:MCI_RECORD_PARMS
Local mciSaveParms:MCI_SAVE_PARMS
Local mciPlayParms:MCI_PLAY_PARMS
Local mciGeneric:MCI_GENERIC_PARMS

   Mov mciOpenParms.dwCallback, 0
   Mov mciOpenParms.wDeviceID, 0
   Mov mciOpenParms.lpstrDeviceType, Offset DeviceType
   Mov mciOpenParms.lpstrElementName, NULL
   Mov mciOpenParms.lpstrAlias, 0

   Invoke mciSendCommand, 0, MCI_OPEN, MCI_OPEN_TYPE, Addr mciOpenParms
   Mov dwReturn, Eax





   Mov Eax, mciOpenParms.wDeviceID
   Mov wDeviceID, Eax

    Invoke  GetDesktopWindow

   Mov mciRecordParms.dwCallback, Eax
   Mov mciRecordParms.dwFrom, 0
   Mov mciRecordParms.dwTo, 30000
   Invoke mciSendCommand, wDeviceID, MCI_RECORD, MCI_NOTIFY + MCI_TO, Addr mciRecordParms

    ;Invoke PasarADecimal, Eax

    ;Invoke Sleep, 30000

   Invoke mciSendCommand, wDeviceID, MCI_STOP, MCI_WAIT, Addr mciGeneric

   Mov mciSaveParms.lpFileName, Offset WavFile
   Invoke mciSendCommand, wDeviceID, MCI_SAVE, MCI_SAVE_FILE + MCI_WAIT, Addr mciSaveParms

   Invoke mciSendCommand, wDeviceID, MCI_CLOSE, MCI_WAIT, Addr mciGeneric


   Xor Eax, Eax

   
   Ret
CapturaAudio EndP


Fraile

If someone has, for example, how to record from the microphone.


Fraile

I already have it!!!. I leave an example.

CapturaAudio Proto


.Const

.Data?

.Data
DeviceType      DB "waveaudio", 0
WavFile         DB "d:\TempFile.wav", 0
ElementName     DB 0

.Code

CapturaAudio Proc

Local wDeviceID:DWord
Local dwReturn:DWord
Local mciOpenParms:MCI_OPEN_PARMS
Local mciRecordParms:MCI_RECORD_PARMS
Local mciSaveParms:MCI_SAVE_PARMS
Local mciPlayParms:MCI_PLAY_PARMS
Local mciGeneric:MCI_GENERIC_PARMS

   Mov mciOpenParms.dwCallback, 0
   Mov mciOpenParms.wDeviceID, 0
   Mov mciOpenParms.lpstrDeviceType, Offset DeviceType
   Mov mciOpenParms.lpstrElementName, Offset ElementName
   Mov mciOpenParms.lpstrAlias, 0

   Invoke mciSendCommand, 0, MCI_OPEN, MCI_OPEN_TYPE + MCI_OPEN_ELEMENT + MCI_WAIT, Addr mciOpenParms
   Mov dwReturn, Eax

    ;Invoke PasarADecimal, Eax




   Mov Eax, mciOpenParms.wDeviceID
   Mov wDeviceID, Eax

    Invoke  GetDesktopWindow

   Mov mciRecordParms.dwCallback, Eax
   Mov mciRecordParms.dwFrom, 0
   Mov mciRecordParms.dwTo, 30000
   Invoke mciSendCommand, wDeviceID, MCI_RECORD, 0, Addr mciRecordParms

    ;Invoke PasarADecimal, Eax

    Invoke Sleep, 30000

   Invoke mciSendCommand, wDeviceID, MCI_STOP, MCI_WAIT, Addr mciGeneric

   Mov mciSaveParms.lpFileName, Offset WavFile
   Invoke mciSendCommand, wDeviceID, MCI_SAVE, MCI_SAVE_FILE + MCI_WAIT, Addr mciSaveParms

   Invoke mciSendCommand, wDeviceID, MCI_CLOSE, MCI_WAIT, Addr mciGeneric


   Xor Eax, Eax

   
   Ret
CapturaAudio EndP


Fraile

Does anyone know how to record the audio in a memory buffer?

Fraile

Hi, I found a great example, http://masm32.com/board/index.php?topic=1239.15

very very good. Thanks Donkey.

:eusa_clap: