Page 1 of 1

MCI - record sound

Posted: Tue Apr 19, 2005 2:06 am
by J. Baker
Are there MCI commands to record from "Wave" or "Stereo Mix" from the sound card?

Posted: Tue Apr 19, 2005 3:04 am
by Paul
I put this together back in February 2002 (found on PureProject.net website)...

Code: Select all

Global buffer$
buffer$=Space(256)

Procedure MCI(command.s)
  result=mciSendString_(command,@buffer$,256,0)
  ProcedureReturn result
EndProcedure


;---------------------------------------------------------------------
clip.s="C:\Test.wav"      ;file to save to disk
Alignment=4
bits=16                   ;16bit wave file
channels=2                ;1=mono 2=stero
samples=44100             ;44.1kHz sample rate
reclength=5               ;length of audio to record (this example records 5 seconds)

InitGadget(2)
If OpenWindow(0,10,10,200,100,#PB_Window_SystemMenu,"Record Audio")=0:End:EndIf
If CreateGadgetList(WindowID())=0:End:EndIf
TextGadget(0,10,10,100,20,"")


MCI("open new type waveaudio alias recsound")
MCI("set recsound time format ms")
MCI("set recsound alignment "+Str(Alignment)+" bitspersample "+Str(bits)+" samplespersec "+Str(samples)+" channels "+Str(channels)+" bytespersec "+Str(samples*Alignment) )
MCI("record recsound")

While elapsed < reclength*1000
  MCI("status recsound position")
  elapsed=Val(buffer$)
  SetGadgetText(0,"Recorded: "+Str(elapsed/1000)+" secs.")
  Delay(20)
Wend

MCI("save recsound "+clip)
MCI("close recsound")
End

Posted: Tue Apr 19, 2005 3:12 am
by goomoo
1.Double click on the Speaker on TaskBar, this will brings Volume Control window.
2.Choose menu Options>Properties
3.Select the Record radio button. Check the Stero Mix and uncheck Microphone item.
4.Now when you use MCI command to record sounds, you are recording from the soundboard.

Hope this give you some help. :D

Posted: Tue Apr 19, 2005 3:35 pm
by J. Baker
Paul wrote:I put this together back in February 2002 (found on PureProject.net website)...
Thanks Paul!
goomoo wrote:1.Double click on the Speaker on TaskBar, this will brings Volume Control window.
2.Choose menu Options>Properties
3.Select the Record radio button. Check the Stero Mix and uncheck Microphone item.
4.Now when you use MCI command to record sounds, you are recording from the soundboard.
Doesn't seem to work. I can barely hear the recorded wav. Tried to turn up the input and output levels but still barely able to hear it.

Posted: Tue Apr 19, 2005 3:52 pm
by BluesInA
i wrote (used code from the archive) a small program to do the same thing...using mci commands, it'll record anything my soundcard plays. it worked fine on my main computer but when i tried it out on a laptop it wouldn't work. same symptoms - very faint audio. i kept fiddling with the sound settings in the control panel and got it to work. don't give up, keep on clicking...

long time lurker,
mike

Posted: Tue Apr 19, 2005 5:09 pm
by J. Baker
I got it, just had to mess around with my control panel some more, thanks!

Posted: Fri Apr 22, 2005 9:37 pm
by J. Baker
One more question...

Why can't the wav be saved anywhere else beside C:\, such as?

Code: Select all

clip.s="C:\Documents And Settings\Owner\Desktop\Test.wav"
Doesn't seem to work for me.

Posted: Fri Apr 22, 2005 9:50 pm
by Paul
If you are using long path names with spaces, try:

Code: Select all

clip.s=Chr(34)+"C:\Documents and Settings\Owner\Desktop\Test.wav"+Chr(34)

Posted: Fri Apr 22, 2005 10:09 pm
by J. Baker
Paul wrote:If you are using long path names with spaces, try:

Code: Select all

clip.s=Chr(34)+"C:\Documents and Settings\Owner\Desktop\Test.wav"+Chr(34)
Thanks alot Paul! :D