#include #include #include "sound.h" // Init sound system. Load in vab and set the main volume void InitSound() { // return vab_id (0-15), open VAB and transfer to sound buffer vab_id = SsVabTransfer((u_char*)SNDFX_VH, (u_char*)SNDFX_VB,-1,1); // open SEQ, max of 32 SEQ's can be opened at the same time seq_id = SsSeqOpen((u_long*)MUSIC_SEQ,vab_id); // set main volume SsSetMVol(MAIN_VOL,MAIN_VOL); // set reverb SetupReverb(); // set SEQ volume SsSeqSetVol(seq_id,SEQ_VOL,SEQ_VOL); } // Setup our sound effects structure void InitSFX( voice_ptr sound_effect, short vab_id, short program, short tone, short note, short fine, short vol_l, short vol_r ) { sound_effect->vabid = vab_id; sound_effect->program = program; sound_effect->tone = tone; sound_effect->note = note; sound_effect->fine = fine; sound_effect->vol_l = vol_l; sound_effect->vol_r = vol_r; } // Play the sound effect void PlaySFX( voice_ptr sound_effect ) { SsUtKeyOn(sound_effect->vabid, sound_effect->program, sound_effect->tone, sound_effect->note, sound_effect->fine, sound_effect->vol_l, sound_effect->vol_r); } // Set reverb type, depth, delay and feedback void SetupReverb() { short type; // set reverb type type = SsUtSetReverbType( SS_REV_TYPE_HALL ); if( type < 0 ) printf(" ERROR: Reverb fail \n"); // turn on reverb SsUtReverbOn(); // wait awhile VSync(0); VSync(0); // set depth SsUtSetReverbDepth(127,127); // set delay SsUtSetReverbDelay(127); // set feedback SsUtSetReverbFeedback(127); } // Start playing the SEQ file. Will play infinity times! void PlayMusic() { // read in music and begin playing SsSeqPlay(seq_id, SSPLAY_PLAY, SSPLAY_INFINITY); } // Pause playing the SEQ file void PauseMusic() { SsSeqPause(seq_id); } // Replay the SEQ file void ReplayMusic() { SsSeqReplay(seq_id); } // Close down the sound system void StopSound( void ) { // stop SEQ data reading SsSeqStop(seq_id); // wait awhile VSync(0); VSync(0); // close SEQ data SsSeqClose(seq_id); // Close VAB data // close vab SsVabClose(vab_id); }