An Overview of the MIDI Score-Playing Process
This section shows how a task uses the components of the MIDI environment to play back a MIDI score. A task typically follows these steps:
- Open the Audio and Math folios and initialize the Juggler. This opens the Audio and Music folios so that the Music library can use instruments, the audio clock, and math functions. It also sets up the Juggler to handle MIDI playback.
- Create a MIDI environment.
- Set the maximum number of voices and programs available. This limits the number of instrument templates and DSP resources required.
- Create a
ScoreContext
data structure. This step also includes creating attendant data structures such as ScoreChannel
data structures.
- Create a PIMap. This step imports the necessary instrument templates and then associates them with corresponding program numbers.
- Create a mixer for connecting voice output to the D to A input. This step also creates the
NoteTracker
data structures necessary for allocating voices, and allocates system amplitude for the mixer.
- Import a MIDI score file.
- Import a MIDI file from CD-ROM or other source. This translates MIDI messages and places them in a Juggler sequence or collection. It also sets up an interpreter procedure for the Juggler object that correctly interprets the MIDI messages in the object.
- Specify a score context for the imported score. This sets a pointer in the Juggler object to the score context necessary for playback.
- Adjust score timing to match the MIDI song tempo. This step either sets the audio clock to an appropriate rate, or it scales MIDI timestamps for each score event.
- Play the score in a
BumpJuggler()
loop.
- Clean up.
- Free allocated amplitude.
- Reset the audio clock.
- Delete all the instrument templates.
- Delete the score context and attendant data structures.
- Terminate the Juggler.
- Close the Math and Audio folios.
The following sections discuss the details for each of these steps.