The following procedure uses the Media Control Interface to record an audio file.
TO RECORD.WAVEFORM
IGNORE MCI [open new type waveaudio alias mysong]
MCI [record mysong]
WAIT 300
MCI [stop mysong]
MCI [save mysong mysong.wav]
MCI [close mysong]
END
Let's take a closer look at each instruction in the example above.
The procedure first opens the waveaudio device by issuing an open
command.
The new
flag tells MCI that the waveaudio device should be opened for recording, not playback.
The alias
parameter is required when using the new
flag.
In this case, it gives the recording session the name "mysong" so that future instructions can refer to it.
Unlike most other commands, the open
command outputs a value on success.
Since Logo programs must do something with every value that is output, we simply IGNORE it.
The record
command is used to start recording on the microphone.
The WAIT instruction just waits for five seconds. This has nothing to do with MCI, it just gives you some time to record your audio clip.
The stop
command turns the microphone off and stops recording from it.
The save
command copies all of the recorded audio data to a file named mysong.wav
.
Keep in mind that all MCI commands are run asynchronously, which means that FMSLogo may start running other Logo instructions before the file has been fully written.
To make sure that FMSLogo waits until the file is 100% written, you can add the wait
flag, like this:
MCI [save mysong mysong.wav wait]
Once the mysong.wav has been saved, it can be played with most other audio programs. It can also be played with FMSLogo by using the PLAYWAVE command or other MCI instructions.
The close
command is used to tell the Media Control Interface that you are done with the microphone.