Next: , Previous: Lamp Effects, Up: Effects


6.5 Sound and Music Effects

The main difference with sound and music is that the main CPU does not implement the effect; they are generated by a separate board. The main CPU sends commands to the secondary board to request that a particular sound be played. Because of this, no running task is required for the effect. (Platforms other than WPC may differ in this regard.)

Sounds and music may also overlap, depending on the capabilities of the sound board. Each platform defines a set of independent channels. When a sound needs to be played, you can specify a subset of channels that it can be played on. If one of them is free, the sound can be played. The system tracks which channels are free or in use.

There is no easy way to know when the sound has finished playing. The sound board is capable of sending responses back to the CPU board, but this has not been explored thoroughly yet. For now, sound calls need to specify how long the sound will take to complete, so that the channels can be deallocated. Exact precision is not really necessary here, unless trying to string together a sequence of speech calls.

The music channel is treated special, because it is the one used for the running background track. All other sounds are transient, whereas the music plays in a constant loop.

Some sound effects need to preempt the background music, so that both are not heard simultaneously. When a sound effect allocates the music channel, that kills the background music first; when the temporary sound finishes, the background is automatically restarted.

music_update
Request an update of the background music.
sound_start
Start a sound effect. This operates at a layer above sound_send, which is the low-level API to send a command to the sound board. This API handles priority, channel allocation, and tracks the duration of effects.
sample_start
Start a sound sample call.
speech_start
Start a speech call.
music_effect_start
Start a music effect that preempts the background.
music_disable
Disable the background music.
music_enable
Reenable the background music.
music_timed_disable
Disable the background music for a given amount of time; it will be reenabled automatically once the time expires.