void digi_debug() { int i; int n_voices = 0; if (!digi_initialised) return; for (i = 0; i < digi_max_channels; i++) { if (digi_is_channel_playing(i)) n_voices++; } }
void digi_debug() { int i; int n_voices = 0; if (!Digi_initialized) return; for (i = 0; i < digi_max_channels; i++) { if (digi_is_channel_playing(i)) n_voices++; } mprintf_at((0, 2, 0, "DIGI: Active Sound Channels: %d/%d (HMI says %d/32) ", n_voices, digi_max_channels, -1)); //mprintf_at((0, 3, 0, "DIGI: Number locked sounds: %d ", digi_total_locks )); }
void SoundQ_process() { if ( SoundQ_channel > -1 ) { if ( digi_is_channel_playing(SoundQ_channel) ) return; SoundQ_end(); } while ( SoundQ_head != SoundQ_tail ) { sound_q * q = &SoundQ[SoundQ_head]; if ( q->time_added+MAX_LIFE > timer_query() ) { SoundQ_channel = digi_start_sound(q->soundnum, F1_0+1, 0xFFFF/2, 0, -1, -1, -1 ); return; } else { // expired; remove from Queue SoundQ_end(); } } }
void digi_sync_sounds() { int i; int oldvolume, oldpan; if ( Newdemo_state == ND_STATE_RECORDING) { if ( !was_recording ) { digi_record_sound_objects(); } was_recording = 1; } else { was_recording = 0; } SoundQ_process(); for (i=0; i<MAX_SOUND_OBJECTS; i++ ) { if ( SoundObjects[i].flags & SOF_USED ) { oldvolume = SoundObjects[i].volume; oldpan = SoundObjects[i].pan; if ( !(SoundObjects[i].flags & SOF_PLAY_FOREVER) ) { // Check if its done. if (SoundObjects[i].channel > -1 ) { if ( !digi_is_channel_playing(SoundObjects[i].channel) ) { digi_end_sound( SoundObjects[i].channel ); SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound N_active_sound_objects--; continue; // Go on to next sound... } } } if ( SoundObjects[i].flags & SOF_LINK_TO_POS ) { digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, &SoundObjects[i].link_type.pos.position, SoundObjects[i].link_type.pos.segnum, SoundObjects[i].max_volume, &SoundObjects[i].volume, &SoundObjects[i].pan, SoundObjects[i].max_distance ); } else if ( SoundObjects[i].flags & SOF_LINK_TO_OBJ ) { object * objp; if ( Newdemo_state == ND_STATE_PLAYBACK ) { int objnum; objnum = newdemo_find_object( SoundObjects[i].link_type.obj.objsignature ); if ( objnum > -1 ) { objp = &Objects[objnum]; } else { objp = &Objects[0]; } } else { objp = &Objects[SoundObjects[i].link_type.obj.objnum]; } if ((objp->type==OBJ_NONE) || (objp->signature!=SoundObjects[i].link_type.obj.objsignature)) { // The object that this is linked to is dead, so just end this sound if it is looping. if ( SoundObjects[i].channel>-1 ) { if (SoundObjects[i].flags & SOF_PLAY_FOREVER) digi_stop_sound( SoundObjects[i].channel ); else digi_end_sound( SoundObjects[i].channel ); N_active_sound_objects--; } SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound continue; // Go on to next sound... } else { digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, &objp->pos, objp->segnum, SoundObjects[i].max_volume, &SoundObjects[i].volume, &SoundObjects[i].pan, SoundObjects[i].max_distance ); } } if (oldvolume != SoundObjects[i].volume) { if ( SoundObjects[i].volume < 1 ) { // Sound is too far away, so stop it from playing. if ( SoundObjects[i].channel>-1 ) { if (SoundObjects[i].flags & SOF_PLAY_FOREVER) digi_stop_sound( SoundObjects[i].channel ); else digi_end_sound( SoundObjects[i].channel ); N_active_sound_objects--; SoundObjects[i].channel = -1; } if (! (SoundObjects[i].flags & SOF_PLAY_FOREVER)) { SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound continue; } } else { if (SoundObjects[i].channel<0) { digi_start_sound_object(i); } else { digi_set_channel_volume( SoundObjects[i].channel, SoundObjects[i].volume ); } } } if (oldpan != SoundObjects[i].pan) { if (SoundObjects[i].channel>-1) digi_set_channel_pan( SoundObjects[i].channel, SoundObjects[i].pan ); } } } #ifndef NDEBUG // digi_sound_debug(); #endif }