This chapter explains the steps and points to note when outputting sound on the Sega Saturn using the sound control library.
┏━━━━━━━┓ ┏━━━━━━┓ ┏━━━━━━┓
┃Sound ┃ ┃ ┃ ┃ ┃
┃Library┃←→┃Master┃←→┃Slave ┃
┠───────┨ ┃ CPU ┃ ┃ CPU ┃
┃ ┃ ┃ ┃ ┃ ┃
┃ ┃ ┗━━━━━━┛ ┗━━━━━━┛
┃ ┃ ↑
┃ ┃ ↓
┃ ┃ ┏━━━━━━━┓
┃ ┃ ┃Sound ┃
┃ ┃ ┃Driver ┃ ┏━━━━━━━━┓
┃ ┃ ┠───────┨ ┃SoundCPU┃
┗━━━━━━━┛ ┃Command┃←→┃MC68000 ┃
┃Buffer ┃ ┃ ┃
┃ ┃ ┗━━━━━━━━┛
┠───────┨ ↓
┃ ┃ ┏━━━━━━━━━┓
┃Sound ┃ ┃PCM sound┃→Speaker
┃Data ┃ ┃source ┃
┃ ┃ ┗━━━━━━━━━┛
┗━━━━━━━┛
Shared RAM
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Setting the sound driver ┃
┃ and starting MC68000 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
↓
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Sound data set ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
↓
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Control of BGM performance/sound ┃
┃ effects and PCM sound source ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┌ ┐ │slDMACopy(sounddat , (void *)0x25a0b000 , sizeof(sounddat)) ;│ │slDMAWait() ; │ └ ┘
Song: Song (sound effect) number Prio: Priority when using sound source Volume: Volume Rate: Time to reach Volume
slBGMTempo(Sint16 Tempo) ; /* Change tempo */ slBGMFade(Uint8 Volume , Uint8 Rate) ; /* Change volume */ slBGMOff(); /* Stop playing */ slBGMPause(); /* Pause the performance */ slBGMCont(); /* Resume playing */ slBGMStat(); /* Check if it is playing */
Song: Song (sound effect) number Prio: Priority when using sound sources Volume: Volume Pan: Distribution of left and right volume
slSequenceTempo(Uint8 Seqnm , Sint16 Tempo) ; /* Change tempo */ slSequenceFade(Uint8 Seqnm, Uint8 Volume, Uint8 Rate); /* Change volume */ slSequencePan(Uint8 Seqnm, Uint8 Pan); /* Change direction of generation */ slSequenceOff(Uint8 Seqnm) ; /* Stop the sequence */ slSequencePause(Uint8 Seqnm) ; /* Pause the sequence */ slSequenceCont(Uint8 Seqnm) ; /* Resume the paused sequence */ slSequenceStat(Uint8 Seqnm) ; /* Check if the sequence is playing */
pdat: PCM type structure data such as playback mode of PCM stream data: Sound source data of PCM stream size: Size of PCM stream data
The PCM type structure data has the following structure and is used to specify the playback parameters of the PCM stream.
Figure 14-4 PCM type structure data
typedef struct{
Uint8 mode; /* Mode */
Uint8 channel; /* PCM Channel Number */
Uint8 level; /* 0 ~ 127 */
Sint8 pan; /* -128 ‾ +127 */
Uint16 pitch;
Uint8 eflevelR; /* Effect level for Right(nomo) 0 ~ 7 */
Uint8 efselectR; /* Effect select for Right(mono) 0 ~ 15 */
Uint8 eflevelL; /* Effect level for Left(mono) 0 ~ 7 */
Uint8 efselectL; /* Effect select for Left(mono) 0 ~ 15 */
}PCM;
mode: Specify _Stereo or _Mono, _PCM16Bit or _PCM8Bit channel: PCM playback channel (set by this function)
level: volume pan: left/right distribution of volume pitch: playback rate (pitch changes)
eflevelR: Effect level (for right channel)
efselectR: Effect number (for right channel)
eflevelL: Effect level (for left channel)
efselectL: Effect number (for left channel)
slPCMOff(PCM *pdat); /*Stop playing*/ slPCMParmChange(PCM *pdat) ; /*Change parameters*/ slPCMStat(PCM *pdat) ;/*Check whether the specified PCM channel is playing*/
slSndVolume(Uint8 Volume) ; /* Overall volume */ slSoundAllOff(); /* Stop all sound sequences */ slDSPOff(); /* Stop the effect DSP */ slSndMixChange(Uint8 Tbank , Uint8 Mixno) ; /* Switch mixer */ slSndMixParmChange(Uint8 Effect , Uint8 Level , Uint8 Pan) ; /* Change mixer parameters */
25A00000┏━━━━━━━━━━━━━━━┓
┃ ┃
┃ Exception ┃
┃ vectors, etc. ┃
25A00500┣━━━━━━━━━━━━━━━┫
┃ ┃
┃ Current ┃
┃ map data ┃
25A00700┣━━━━━━━━━━━━━━━┫
┃ ┃
┃ Command ┃
┃ buffer ┃
25A00800┣━━━━━━━━━━━━━━━┫
┃ ┃
┃ Sound driver ┃
┃ ┃
25A0A000┣━━━━━━━━━━━━━━━┫
┃ ┃
┃ Map data ┃
┃ ┃
25A0B000┣━━━━━━━━━━━━━━━┫
┃ ┃
┃ Tones, ┃
┃ sequences ┃
25A78000┣━━━━━━━━━━━━━━━┫
┃ ┃
┃ PCM playback ┃
┃ buffer ┃
25A7FFFF┗━━━━━━━━━━━━━━━┛
Bank Song Contents ---- ---- ------- 0 0 Song (no loop) 1 Song (with loop) 1 0 Pash (C3) 1 Pash (D3) 2 Pash (E3) 3 Pash (F3) 4 Pash (G3) 5 Pash (A3) 6 Pash (B3) 7 Pash (C4) 2 0 Yeah 3 0 Long violin sound 1 Short violin sound (loop)
Flow 14-1 sampsnd1: BGM and sound effect playback test
Flow 14-2 sampsnd2: PCM sound source playback test
functional type | Function name | Parameter | function |
|---|---|---|---|
| void | slInitSound | void *drv,Uint32 drvsz,void *map,Uint32 mapsz | Setting the sound driver and initializing the sound control CPU |
| Bool | slBGMOn | Uint16 Song, Uint8 Prio, Uint8 Volume, Uint8 Rate | Start of BGM performance |
| Bool | slBGMTempo | Sint16 Tempo | Change BGM playing speed |
| Bool | slBGMFade | Uint8 Volume,Uint8 Rate | Change BGM performance volume |
| Bool | slBGMOff | void | Stopping BGM playing |
| Bool | slBGMPause | void | Pausing BGM play |
| Bool | slBGMCont | void | Resume playing BGM during pause |
| Bool | slBGMStat | void | Check if BGM is playing |
| Uint8 | slSequenceOn | Uint16 Song, Uint8 Prio, Uint8 Volume, Uint8 Rate | Start of the specified sound effect |
| Bool | slSequenceTempo | Uint8 Seqnm,Uint16 Tempo | Change the speed of the specified sound effect |
| Bool | slSequenceFade | Uint8 Seqnm,Uint8 Volume,Uint8 Rate | Change the volume of the specified sound effect |
| Bool | slSequencePan | Uint8 Seqnm,Uint8 Pan | Change the direction of the specified sound effect |
| Bool | slSequenceOff | Uint8 Seqnm | Stopping the specified sound effect |
| Bool | slSequencePause | Uint8 Seqnm | Pauses the production of the specified sound effect |
| Bool | slSequenceCont | Uint8 Seqnm | Resume sound effect while paused |
| Bool | slSequenceStat | Uint8 Seqnm | Check if the specified sound effect is playing |
| Sint8 | slPCMOn | PCM *pdat,void *data,Uint32 size | Start of performance using PCM sound source |
| Bool | slPCMOff | PCM *pdat | Stopping the performance by PCM sound source |
| Bool | slPCMParmChange | PCM *pdat | Changing parameters for PCM playback |
| Bool | slPCMStat | PCM *pdat | Checking whether the specified PCM channel is playing |
| Bool | slSndVolume | Uint8 Volume | whole volume set |
| Bool | slSoundAllOff | void | Stop playing all sound sequences |
| Bool | slDSPOff | void | Stopping DSP performance |
| Bool | slSndMixChange | Uint8 Tbank,Uint8 Mixno | Switching the mixer corresponding to the tone bank |
| Bool | slSndMixParmChange | UInt Effect,Uint8 Level,Uint8 Pan | Change mixer parameters |
★ SGL User's Manual ★ PROGRAMMER'S TUTORIAL