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
new flag tells MCI that the waveaudio device should be opened for recording, not playback.
alias parameter is required when using the
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.
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.
stop command turns the microphone off and stops recording from it.
save command copies all of the recorded audio data to a file named
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]
close command is used to tell the Media Control Interface that you are done with the microphone.