MCI - record sound

Just starting out? Need help? Post your questions and find answers here.
User avatar
J. Baker
Addict
Addict
Posts: 2188
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

MCI - record sound

Post by J. Baker »

Are there MCI commands to record from "Wave" or "Stereo Mix" from the sound card?
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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
Image Image
goomoo
User
User
Posts: 42
Joined: Sun Dec 05, 2004 9:25 am
Location: China
Contact:

Post 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
Hello, Everyone.
Thanks for your help.
User avatar
J. Baker
Addict
Addict
Posts: 2188
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post 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.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
BluesInA
User
User
Posts: 11
Joined: Mon Mar 07, 2005 3:20 pm

Post 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
User avatar
J. Baker
Addict
Addict
Posts: 2188
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

I got it, just had to mess around with my control panel some more, thanks!
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
J. Baker
Addict
Addict
Posts: 2188
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post 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.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post 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)
Image Image
User avatar
J. Baker
Addict
Addict
Posts: 2188
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post 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
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Post Reply