WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sample code
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WinBatch Script to Record and Playback Recorded Sound File

Keywords: playmedia sound playback record   

If you have problems with the following script, try it without the WAIT on the end.

Use Short filenames only, since the Playmedia stuff needs short names. For example:

		PlayMedia("save mysound c:\temp\me.wav wait")

Parrot: WinBatch Script to Record and Playback Recorded Sound File:


;Message("Parrot","Press OK to record")
;Assuming you have a microphone with your sound system,
;and you can record using sound recorder, then this script
;will record and playback stuff.

fname="c:\temp\me.wav"


while 1
  BoxOpen("Parrot","Hold shift key down to record (9 seconds max)%@CRLF%Hold CTRL to exit")
  while !IsKeyDown(@shift)
      if IsKeyDown(@CTRL) then goto byebye
      ;TimeDelay(0.25)
  endwhile
  PlayMedia("open new type waveaudio alias mysound buffer 9")
  PlayMedia("record mysound")
  BoxText("Recording...")
  while IsKeyDown(@SHIFT)
     TimeDelay(0.25)
  endwhile
  BoxText("Playback")
  PlayMedia("stop mysound")
  if FileExist(fname) then FileDelete(fname)
  PlayMedia("save mysound %fname% wait")
  PlayMedia("close mysound")
  PlayWaveform(fname,0)
endwhile
:byebye
Display(1,"All","Doned")

How PlayMedia Works:


Question:

I often record stuff off of the radio on my PC. I would like to build an application that would allow me to schedule recordings ( start and stop times ), similar to what a VCR allows you to do. I'm using the sample code above for this purpose.
  1. I'm wondering what is "PlayMedia"? Is it a DLL from Microsoft that you guys somehow made easily accesible to WinBatch? If this is so, are there anyother DLLs that have also been integrated for easy use?

  2. Recording works great :-) , but I think I opened a real can of worms here, I looked a little closer at the recording and it is an 8 bit mono recording :-( I have the MSDN Developer Network Visual Studio 97 but it is not real clear to me? Is there any way to setup how the recording is done using "MediaPlay"? I seem to be stuck in limbo ( or is it Hell? ) somewhere between Visual C++ and WinBatch.

Answer:

The windows OS has a large number of API's that are called to perform all sorts of functions. WinBatch is a layer over these API's. ALL the API's live in various DLLs scattered throughout the system.

The WinBatch PlayMedia functions calls the mciSendString API that send a command stirng into the Windows multimedia system. Almost any program can use it. The mciSendString call is fairly simple, except that you need to know the magic command stirngs to send to control the devices.

The theory was that the purveyors of various multimedia hardware would document what command strings their devices responded to. This has not, as far as I can tell, happened. Instead Microsoft has taken up the slack and has been documenting the various strings in their Visual C++ documentation.

So, to really use PlayMedia you have to track down the documentation for the strings you can use with the Windows mciSendString function. Do you have MSDN? You might start with MCI Command strings if you do, check out the quality command, and also the setaudio one.

So basically, you can use any of those mci commands ("open", "play", "record", "setaudio", "quality" ) by using the "PlayMedia" WinBatch instruction ( which in turn invokes the command by calling "mciSendString" ). With some minor questions about "wait" and "notify". But try it anyway.

I believe wait is removed from the command line and handled differently. and Notify is simply removed. Everything else ought to work just fine.


Article ID:   W13754
Filename:   Parrot Script to Playback Recorded Wave File.txt
File Created: 2000:08:28:09:32:10
Last Updated: 2000:08:28:09:32:10