// // StopByOwner // // Stop all voices with the given owner id // void StopByOwner(U32 id) { if (Initialized()) { for (U32 i = 0; i < totalVoices; i++) { // Get the voice at this index Voice *voice = voices[i]; if (voice->owner == id) { voice->Stop(); } } } }
// // StopByRecord // // Stop all voices playing the given record // void StopByRecord(Record *r) { if (Initialized()) { for (U32 i = 0; i < totalVoices; i++) { // Get the voice at this index Voice *voice = voices[i]; if ((voice->Status() != SMP_DONE) && (voice->record == r)) { voice->Stop(); } } } }
// // StopByEffect // // Stop all voices played using the given effect // void StopByEffect(Effect *e) { if (Initialized()) { for (U32 i = 0; i < totalVoices; i++) { // Get the voice at this index Voice *voice = voices[i]; // Effect is still alive and matches the one supplied if (voice->effect.Alive() && voice->effect == e) { voice->Stop(); } } } }
// // Request // // Request the use of a voice // static Voice * Request(F32 priority, Bool flag3D, U8 &index) { ASSERT(Initialized()); // Try and find a voice that is currently free U32 i = 0; for (; i < totalVoices; i++) { // Get the voice at this index Voice *voice = voices[i]; // Correct type and available for use if ((voice->flag3D == flag3D) && (voice->Status() == SMP_DONE)) { index = (U8)i; return (voice); } } // Try and free a voice using the priority system for (i = 0; i < totalVoices; i++) { // Get the voice at this index Voice *voice = voices[i]; // Correct type and lower priority if ((voice->flag3D == flag3D) && (voice->priority < priority)) { index = (U8)i; voice->Stop(); return (voice); } } return (NULL); }