Example: Playing a Track from a CD

The following procedure uses the Media Control Interface to play the first track on an audio CD.

TO PLAY.TRACK.1
  IGNORE MCI [open cdaudio]
  MCI [set cdaudio time format tmsf]
  MCI [play cdaudio from 1 to 2]
  WAIT 3600
  MCI [stop cdaudio]
  MCI [close cdaudio]
END

Let's take a closer look at each instruction in the example above.

The procedure first opens the "cdaudio" device by issuing an open command. This "open" has nothing to do with physically opening the CD tray, it is required before the cdaudio device will accept any other commands. 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 set command is used to specify the time format as "tmsf", which stands for "track:minute:second:frame".

The play command is used to start playing from one time to another. The track plays asynchronously, which means that FMSLogo doesn't wait for the track to finish playing before running the next instruction. If you wanted to wait until the track was done before moving on to the next instruction, you could add the wait flag to the end of the MCI instruction, as in:

MCI [play cdaudio from 1 to 2 wait]

Since we're using TMFS format, the to and from numbers are taken to be in tracks. TMFS values are given in tt:mm:ss:ff format, so if we wanted to play the first fifteen seconds of track 1, we could do that with the following instruction.

MCI [play cdaudio from 1 to 1:00:15]

Also note that it is not necessary to specify an end time for the play command. If you wanted to play the entire CD, you could do so with:

MCI [play cdaudio from 1]

The WAIT instruction just waits for 60 seconds. This has nothing to do with MCI, it just gives you some time to listen to the CD.

The stop command is used to stop the CD from playing.

The close command is used to tell the Media Control Interface that you are done with the cdaudio device.


SourceForge.net Logo