Return to previous page | Return to menu | Go to next page


14-2. Sound driver settings

To control sound with SEGA Saturn using a sound driver, follow the steps below.

Figure 14-2 Sound control procedure

Set sound driver and start MC68000

In order to use sound, you must first start MC68000 for sound control. A driver program that runs on the MC68000 is also required. These can be set by executing the library function “slInitSound ()”.

[void slInitSound (void * drv, Uint32 drvsz, void * map, Uint32 mapsz);]
Set the sound driver and initialize the sound CPU (MC68000). “Drv” is a sound driver program that runs on the MC68000 and is loaded from address 0 of the MC68000. “Drvsz” is the size of this driver program.
Usually
slInitSound(drv , sizeof(drv) , maptbl , sizeof(maptbl)) ;
Use it like this.

This function “slInitSound ()” executes the following procedure.

  1. Reset MC68000
  2. MC68000 memory area 0 clear up to 0xB000
  3. Driver program transfer (size from address 0)
  4. Map data transfer (size from address 0xA000)
  5. Registering memory area for PCM playback
  6. MC68000 start
  7. Map data registration

Sound data set

By simply executing “slInitSound ()” above, the performance data has not been set yet, so set it. Performance data is stored after 0xB000 (0x25A0B000 on the program) in the memory area of ​​MC68000 (please contact the sound designer as it may vary depending on the map data). Transfer using the following function:

Figure 14-3 Example of sound data set

Now you are ready to play.

BGM performance

Music (and sound effects) are handled in units called sequences. A sequence is to play a series of sound combinations (flow) from the beginning to the end (this is a song or a one-shot sound effect). You can play up to eight at the same time. SGL allocates number 0 for BGM in these 8 sequences. To play BGM, execute the “slBGMOn ()” function.

[Bool slBGMOn (Uint16 Song, Uint8 Prio, Uint8 Volume, Uint8 Rate);]
Starts BGM performance.
Song: Song (sound effect) number
Prio: Priority when using sound sources
Volume: Volume
Rate: Time to reach Volume
Priority “Prio” is called priority when using sound sources. Since multiple sequences share sound sources with 32 channels and produce sound, the total number of channels used by each exceeds 32. This is to secure the channel by deleting from the low priority sound.

The volume “volume” can be selected from 0 to 127. The higher the value, the higher the volume. The rate “Rate” is the time to reach the specified volume, and can be specified from 0 to 255. If it is 0, it will be instantly volume, and if it is 1-255, it will fade in from volume 0 to the specified volume.

BGM can change the tempo and volume by the following functions, and can stop, pause and resume the performance.

slBGMTempo (Sint16 Tempo); / * Change tempo * /
slBGMFade (Uint8 Volume, Uint8 Rate); / * Volume change * /
slBGMOff (); / * Stop playing * /
slBGMPause (); / * Pause performance * /
slBGMCont (); / * Resume performance * /
slBGMStat (); / * Check if playing * /

Sound effect output

Sound effects are also managed as a sequence, similar to the above BGM. To output sound effects, execute the function “slSequenceOn ()”.

[Uint8 slSequenceOn (Uint16 Song, Uint8 Prio, Uint8 Volume, Uint8 Pan);]
Song: Song (sound effect) number
Prio: Priority when using sound sources
Volume: Volume
Pan: Left / right volume distribution

The parameters are similar to BGM functions, but the parameter Pan is different. This indicates how the left and right volumes are distributed, and can be used to determine the direction in which the sound can be heard. For Pan, values ​​from -128 to +127 can be specified, -128 represents the left, 0 represents the front, and +127 represents the right.

Assigned value of parameter Pan:
Left : -128 << 0 >> +127 : Right

If you set Volume or Pan depending on the distance or direction in the explosion of a 3D shooting game, you should feel more realistic.

This function “slSequenceOn ()” returns the number of the pronunciation management number for the specified sound effect. This pronunciation management number is used when the output sound effect is changed using the following function.

slSequenceTempo (Uint8 Seqnm, Sint16 Tempo); / * Change tempo * /

slSequenceFade (Uint8 Seqnm, Uint8 Volume, Uint8 Rate); / * Change volume * /

slSequencePan (Uint8 Seqnm, Uint8 Pan); / * Change the direction of occurrence * /

slSequenceOff (Uint8 Seqnm); / * Stop the sequence * /

slSequencePause (Uint8 Seqnm); / * Pause the sequence * /

slSequenceCont (Uint8 Seqnm); / * Resume a paused sequence * /

slSequenceStat (Uint8 Seqnm); / * Check if the sequence is playing * /

Sound effect output using PCM sound source

You can use a PCM sound source to output sampled sound effects such as voice and explosion sounds. In addition to the above sequence, sound effect playback by PCM stream can be output simultaneously up to 4 channels. When using a PCM stream, the function “slPCMOn ()”