Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Audio Recording using VFP 9

Status
Not open for further replies.

keepsafe

Programmer
Sep 22, 2009
14
US
I read thread184-962816 and could not get the save function to work. Here is what I am trying to do:
1: Record Audio from either the Aux, Mic port of the sound card. 2: Save the recording to a file.

 
What did you try? What didn't work? Did you get an error message? Did flames shoot out of your speakers?
 
The example in the thread you quoted includes a call to the Save method. Did you follow that example? What happened?

I assume you remembered to pass the output filename to the Save method. Also, did you remember to stop the recording before calling Save?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Hi Mike,
When I press the record button the message "Recording" appear I wait 30 seconds and press Stop. The message Stopping Recording appear. I look in my temp directory and the recording did not save. No error message etc.
I placed these codes inside a container class. Yet I did test it in a prg with the same results.


*
*
* Init Method
*
Method: INIT

DECLARE integer mciSendString IN WinMM.DLL ;
STRING cCommand, STRING @cRetStr, INTEGER nRetLen, ;
INTEGER wHnd

retstr=space(100)
retlen=100


RETURN

*
*
*
*
Start Button Code:

WAIT WINDOW NOWAIT "Recording ..."
THIS.PARENT.RecordNew('C:\Temp\MyNewFile.wav')
*
*
* Method for RecordNew
*
*
Method RecordNew

LPARAMETER pcFName
MESSAGEBOX(pcFName)
IF NOT EMPTY(THIS.DEVICE)
THIS.SendString('close '+THIS.DEVICE)
ENDIF
THIS.DEVICE = 'mywaveaudio'
THIS.SendString('open new type waveaudio alias '+THIS.DEVICE+' buffer 6')
THIS.SendString('record '+THIS.DEVICE)

RETURN .T.




Stop/Save Button Code:
Method Click()
WAIT WINDOW NOWAIT "Stopped recording ..."
THIS.Parent.Stop()
THIS.Parent.SAVE('C:\Temp\MyNewFile.wav')


*
*
* Stop Method
*
Method Click()
THIS.SendString( "stop "+THIS.DEVICE )
RETURN .T.

*
*
* Save Method
METHOD: SAVE

LPARAMETER pcFileName
THIS.ALIAS = "MyNewFile.wav"
IF VARTYPE(pcFileName)='C'
THIS.SendString( 'save '+THIS.ALIAS+' '+pcFileName )
ELSE
IF LOWER(THIS.element)<>'new'
THIS.SendString( 'save '+THIS.ALIAS )
ENDIF
ENDIF
RETURN .T.

*
* SendString Method
*
METHOD: SendString

LPARAMETERS cString
LOCAL cRet, err
cRet = SPACE(60)
err = mciSendString(cString,@cRet,60,0)
RETURN cRet







 
Hmm. Can't see anything obviously wrong with your code.

I suggest you step through the Stop/Save Button code in the debugger, to check that it is actually executing the SendString (and checking the string that you are sending is what you are expecting).

Also, does the call to mciSendString return something other than zero? If so, that might indicate an error code. Check Bill's last piece of code in the other thread to see the meaning of the error codes. Also here:
Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thank Mike,
I made some changes to the codes and seem to get it to work. Do you or anyone know how to save the file as a mp3 instead of a wav?
 
Keepsafe,

For the benefit of others, can you explain what you did to get it to work?

Re MP3: No, I don't think you can do that. You might need to use a separate utility to convert the WAV to MP3 (but I'm not sure about that).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top