void digi_kill_sound_linked_to_segment( int segnum, int sidenum, int soundnum ) { int i,killed; soundnum = digi_xlat_sound(soundnum); if (!digi_initialized) return; killed = 0; for (i=0; i<MAX_SOUND_OBJECTS; i++ ) { if ( (SoundObjects[i].flags & SOF_USED) && (SoundObjects[i].flags & SOF_LINK_TO_POS) ) { if ((SoundObjects[i].link_type.pos.segnum == segnum) && (SoundObjects[i].soundnum==(short)soundnum ) && (SoundObjects[i].link_type.pos.sidenum==sidenum) ) { if ( SoundObjects[i].flags & SOF_PLAYING ) { EndSound(SoundObjects[i].soundnum); } SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound killed++; } } } // If this assert happens, it means that there were 2 sounds // that got deleted. Weird, get John. if ( killed > 1 ) { mprintf( (1, "ERROR: More than 1 sounds were deleted from seg %d\n", segnum )); } }
void digi_play_sample_3d( int sndnum, int angle, int volume, int no_dups ) { int vol; int i = sndnum, demo_angle; if (Newdemo_state == ND_STATE_RECORDING) { demo_angle = fixmuldiv(angle, F1_0, 255); if (no_dups) newdemo_record_sound_3d_once(sndnum, demo_angle, volume); else newdemo_record_sound_3d(sndnum, demo_angle, volume); } if (!digi_initialized) return; if (digi_paused) { digi_resume_all(); if (digi_paused) return; } if ( sndnum < 0 ) return; i = digi_xlat_sound(sndnum); if (i == -1) return; vol = fixmuldiv(volume, digi_volume, F1_0); ChangeSoundVolume( i, vol ); BeginSound(i, SOUND_RATE_11k); ChangeSoundStereoPosition(i, angle); }
static void put_char_delay(const grs_font &cv_font, briefing *const br, const char ch) { char str[2]; int w; str[0] = ch; str[1] = '\0'; if (br->delay_count && (timer_query() < br->start_time + br->delay_count)) { br->message--; // Go back to same character return; } if (br->streamcount >= br->messagestream.size()) return; br->messagestream[br->streamcount].x = br->text_x; br->messagestream[br->streamcount].y = br->text_y; br->messagestream[br->streamcount].color = *Current_color; br->messagestream[br->streamcount].ch = ch; br->streamcount++; br->prev_ch = ch; gr_get_string_size(cv_font, str, &w, nullptr, nullptr); br->text_x += w; #if defined(DXX_BUILD_DESCENT_II) if (!EMULATING_D1 && !br->chattering) { br->printing_channel.reset(digi_start_sound(digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, sound_object_none)); br->chattering=1; } #endif br->start_time = timer_query(); }
void digi_start_sound_queued( short soundnum, fix volume ) { int i; soundnum = digi_xlat_sound(soundnum); if (soundnum < 0 ) return; i = SoundQ_tail+1; if ( i>=MAX_Q ) i = 0; // Make sure its loud so it doesn't get cancelled! if ( volume < F1_0+1 ) volume = F1_0 + 1; if ( i != SoundQ_head ) { SoundQ[SoundQ_tail].time_added = timer_query(); SoundQ[SoundQ_tail].soundnum = soundnum; SoundQ_num++; SoundQ_tail = i; } // Try to start it! SoundQ_process(); }
int digi_link_sound_to_pos2( int soundnum, short segnum, short sidenum, vms_vector * pos, int forever, fix max_volume, fix max_distance ) { int i, volume, pan; if ( max_volume < 0 ) return -1; if (!digi_initialised) return -1; if (digi_xlat_sound(soundnum) < 0) return -1; if (Sounddat(soundnum)->data==NULL) { Int3(); return -1; } if ((segnum<0)||(segnum>Highest_segment_index)) return -1; if ( !forever ) { // Hack to keep sounds from building up... digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, pos, segnum, max_volume, &volume, &pan, max_distance ); digi_play_sample_3d( soundnum, pan, volume, 0 ); return -1; } for (i=0; i<MAX_SOUND_OBJECTS; i++ ) if (SoundObjects[i].flags==0) break; if (i==MAX_SOUND_OBJECTS) { mprintf((1, "Too many sound objects!\n" )); return -1; } SoundObjects[i].signature=next_signature++; SoundObjects[i].flags = SOF_USED | SOF_LINK_TO_POS; if ( forever ) SoundObjects[i].flags |= SOF_PLAY_FOREVER; SoundObjects[i].lp_segnum = segnum; SoundObjects[i].lp_sidenum = sidenum; SoundObjects[i].lp_position = *pos; SoundObjects[i].soundnum = soundnum; SoundObjects[i].max_volume = max_volume; SoundObjects[i].max_distance = max_distance; SoundObjects[i].volume = 0; SoundObjects[i].pan = 0; digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, &SoundObjects[i].lp_position, SoundObjects[i].lp_segnum, SoundObjects[i].max_volume, &SoundObjects[i].volume, &SoundObjects[i].pan, SoundObjects[i].max_distance ); if (!forever || SoundObjects[i].volume >= MIN_VOLUME) digi_start_sound_object(i); return SoundObjects[i].signature; }
int digi_link_sound_to_object2( int org_soundnum, short objnum, int forever, fix max_volume, fix max_distance ) { int i,volume,pan; object * objp; int soundnum; soundnum = digi_xlat_sound(org_soundnum); if ( max_volume < 0 ) return -1; // if ( max_volume > F1_0 ) max_volume = F1_0; if (!digi_initialised) return -1; if (soundnum < 0 ) return -1; if (GameSounds[soundnum].data==NULL) { Int3(); return -1; } if ((objnum<0)||(objnum>Highest_object_index)) return -1; if ( !forever ) { // Hack to keep sounds from building up... digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, &Objects[objnum].pos, Objects[objnum].segnum, max_volume,&volume, &pan, max_distance ); digi_play_sample_3d( org_soundnum, pan, volume, 0 ); return -1; } for (i=0; i<MAX_SOUND_OBJECTS; i++ ) if (SoundObjects[i].flags==0) break; if (i==MAX_SOUND_OBJECTS) { mprintf((1, "Too many sound objects!\n" )); return -1; } SoundObjects[i].signature=next_signature++; SoundObjects[i].flags = SOF_USED | SOF_LINK_TO_OBJ; if ( forever ) SoundObjects[i].flags |= SOF_PLAY_FOREVER; SoundObjects[i].lo_objnum = objnum; SoundObjects[i].lo_objsignature = Objects[objnum].signature; SoundObjects[i].max_volume = max_volume; SoundObjects[i].max_distance = max_distance; SoundObjects[i].volume = 0; SoundObjects[i].pan = 0; SoundObjects[i].soundnum = soundnum; objp = &Objects[SoundObjects[i].lo_objnum]; 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 (!forever || SoundObjects[i].volume >= MIN_VOLUME) digi_start_sound_object(i); return SoundObjects[i].signature; }
// Play the given sound number. // Volume is max at F1_0. void digi_play_sample( int soundno, fix max_volume ) { if ( Newdemo_state == ND_STATE_RECORDING ) newdemo_record_sound( soundno ); if (!digi_initialised) return; if (digi_xlat_sound(soundno) < 0 ) return; digi_start_sound(soundno, max_volume, F0_5); }
void digi_play_sample( int soundno, fix max_volume ) { if ( Newdemo_state == ND_STATE_RECORDING ) newdemo_record_sound( soundno ); soundno = digi_xlat_sound(soundno); if (soundno < 0 ) return; // start the sample playing digi_start_sound( soundno, max_volume, 0xffff/2, 0, -1, -1, -1 ); }
int digi_is_sound_playing(int soundno) { int i; soundno = digi_xlat_sound(soundno); for (i = 0; i < MAX_SOUND_SLOTS; i++) //changed on 980905 by adb: added SoundSlots[i].playing && if (SoundSlots[i].playing && SoundSlots[i].soundno == soundno) //end changes by adb return 1; return 0; }
// Play the given sound number. // Volume is max at F1_0. void digi_play_sample( int soundno, fix max_volume ) { #ifdef NEWDEMO if ( Newdemo_state == ND_STATE_RECORDING ) newdemo_record_sound( soundno ); #endif soundno = digi_xlat_sound(soundno); if (!digi_initialised) return; if (soundno < 0 ) return; digi_start_sound(soundno, max_volume, F0_5, 0, 0, 0, 0); }
void digi_play_sample_looping( int soundno, fix max_volume,int loop_start, int loop_end ) { soundno = digi_xlat_sound(soundno); if (soundno < 0 ) return; if (digi_looping_channel>-1) digi_stop_sound( digi_looping_channel ); digi_looping_sound = soundno; digi_looping_volume = max_volume; digi_looping_start = loop_start; digi_looping_end = loop_end; digi_play_sample_looping_sub(); }
void digi_play_sample_3d( int soundno, int angle, int volume, int no_dups ) // Volume from 0-0x7fff { no_dups = 1; if ( Newdemo_state == ND_STATE_RECORDING ) { if ( no_dups ) newdemo_record_sound_3d_once( soundno, angle, volume ); else newdemo_record_sound_3d( soundno, angle, volume ); } if (!digi_initialised) return; if (digi_xlat_sound(soundno) < 0 ) return; if (volume < MIN_VOLUME ) return; digi_start_sound(soundno, volume, angle); }
// Play the given sound number. If the sound is already playing, // restart it. void digi_play_sample_once( int soundno, fix max_volume ) { int i; if ( Newdemo_state == ND_STATE_RECORDING ) newdemo_record_sound( soundno ); if (!digi_initialised) return; if (digi_xlat_sound(soundno) < 0 ) return; LOCK(); for (i=0; i < MAX_SOUND_SLOTS; i++) if (SoundSlots[i].soundno == soundno) SoundSlots[i].playing = 0; UNLOCK(); digi_start_sound(soundno, max_volume, F0_5); }
void digi_load_sounds() { int i, sound_num; if (!digi_initialized) return; if ( RegisterSounds(sound_list, 1) ) digi_close(); // on low memory conditions, we need to release sounds from the registered // set so the memory can be freed. The call to RegisterSounds only registers // them with halestorm. We will use LoadSound to actually load those sounds that // we intend to use. for (i = 0; i < MAX_SOUNDS; i++) { sound_num = digi_xlat_sound(i); if (sound_num != -1) LoadSound(sound_num); // load the sound into memory..hales says this is locked high in heap } }
// Play the given sound number. If the sound is already playing, // restart it. void digi_play_sample_once( int soundno, fix max_volume ) { int i; #ifdef NEWDEMO if ( Newdemo_state == ND_STATE_RECORDING ) newdemo_record_sound( soundno ); #endif soundno = digi_xlat_sound(soundno); if (!digi_initialised) return; if (soundno < 0 ) return; for (i=0; i < MAX_SOUND_SLOTS; i++) if (SoundSlots[i].soundno == soundno) SoundSlots[i].playing = 0; digi_start_sound(soundno, max_volume, F0_5, 0, 0, 0, 0); }
void digi_play_sample_3d( int soundno, int angle, int volume, int no_dups ) { no_dups = 1; if ( Newdemo_state == ND_STATE_RECORDING ) { if ( no_dups ) newdemo_record_sound_3d_once( soundno, angle, volume ); else newdemo_record_sound_3d( soundno, angle, volume ); } soundno = digi_xlat_sound(soundno); if (soundno < 0 ) return; if (volume < 10 ) return; // start the sample playing digi_start_sound( soundno, volume, angle, 0, -1, -1, -1 ); }
// Play the given sound number. If the sound is already playing, // restart it. void digi_play_sample_once( int soundno, fix max_volume ) { int i; #ifdef NEWDEMO if ( Newdemo_state == ND_STATE_RECORDING ) newdemo_record_sound( soundno ); #endif if (!digi_initialised) return; if (digi_xlat_sound(soundno) < 0 ) return; for (i=0; i < MAX_SOUND_SLOTS; i++) if (SoundSlots[i].soundno == soundno) { DS_release_slot(i,1); } digi_start_sound(soundno, max_volume, F0_5); }
void digi_close() { int i, sound_num; if (!digi_initialized) return; digi_stop_current_song(); SetMasterVolume(master_save); // free the sounds that we have registered. for (i = 0; i < num_sounds; i++) { sound_num = digi_xlat_sound(i); if (sound_num != -1) FreeSound(i); } ReleaseRegisteredSounds(); FinisSoundMusicSystem(); digi_initialized = 0; }
void digi_play_sample( int sndnum, fix max_volume ) { OSErr err; int i, vol; if (Newdemo_state == ND_STATE_RECORDING) newdemo_record_sound(sndnum); if (!digi_initialized) return; if (digi_paused) { digi_resume_all(); if (digi_paused) return; } if ( sndnum < 0 ) return; i = digi_xlat_sound(sndnum); if (i == -1) return; vol = fixmuldiv(max_volume, digi_volume, F1_0); ChangeSoundVolume(i, vol ); err = BeginSound(i, SOUND_RATE_11k); ChangeSoundStereoPosition(i, 0); }
//if soundnum==-1, kill any sound void digi_kill_sound_linked_to_segment( int segnum, int sidenum, int soundnum ) { int i,killed; if (soundnum != -1) soundnum = digi_xlat_sound(soundnum); killed = 0; for (i=0; i<MAX_SOUND_OBJECTS; i++ ) { if ( (SoundObjects[i].flags & SOF_USED) && (SoundObjects[i].flags & SOF_LINK_TO_POS) ) { if ((SoundObjects[i].link_type.pos.segnum == segnum) && (SoundObjects[i].link_type.pos.sidenum==sidenum) && (soundnum==-1 || SoundObjects[i].soundnum==soundnum )) { if ( SoundObjects[i].channel > -1 ) { digi_stop_sound( SoundObjects[i].channel ); N_active_sound_objects--; } SoundObjects[i].channel = -1; SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound killed++; } } } }
int digi_link_sound_to_object3( int org_soundnum, short objnum, int forever, fix max_volume, fix max_distance, int loop_start, int loop_end ) { int i,volume,pan; object * objp; int soundnum; soundnum = digi_xlat_sound(org_soundnum); if ( max_volume < 0 ) return -1; // if ( max_volume > F1_0 ) max_volume = F1_0; if (soundnum < 0 ) return -1; if (GameSounds[soundnum].data==NULL) { Int3(); return -1; } if ((objnum<0)||(objnum>Highest_object_index)) return -1; if ( !forever ) { // && GameSounds[soundnum - SOUND_OFFSET].length < SOUND_3D_THRESHHOLD) { // Hack to keep sounds from building up... digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, &Objects[objnum].pos, Objects[objnum].segnum, max_volume,&volume, &pan, max_distance ); digi_play_sample_3d( org_soundnum, pan, volume, 0 ); return -1; } if ( Newdemo_state == ND_STATE_RECORDING ) { newdemo_record_link_sound_to_object3( org_soundnum, objnum, max_volume, max_distance, loop_start, loop_end ); } for (i=0; i<MAX_SOUND_OBJECTS; i++ ) if (SoundObjects[i].flags==0) break; if (i==MAX_SOUND_OBJECTS) { return -1; } SoundObjects[i].signature=next_signature++; SoundObjects[i].flags = SOF_USED | SOF_LINK_TO_OBJ; if ( forever ) SoundObjects[i].flags |= SOF_PLAY_FOREVER; SoundObjects[i].link_type.obj.objnum = objnum; SoundObjects[i].link_type.obj.objsignature = Objects[objnum].signature; SoundObjects[i].max_volume = max_volume; SoundObjects[i].max_distance = max_distance; SoundObjects[i].volume = 0; SoundObjects[i].pan = 0; SoundObjects[i].soundnum = soundnum; SoundObjects[i].loop_start = loop_start; SoundObjects[i].loop_end = loop_end; if (Dont_start_sound_objects) { //started at level start SoundObjects[i].flags |= SOF_PERMANENT; SoundObjects[i].channel = -1; } else { objp = &Objects[SoundObjects[i].link_type.obj.objnum]; 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 ); digi_start_sound_object(i); // If it's a one-shot sound effect, and it can't start right away, then // just cancel it and be done with it. if ( (SoundObjects[i].channel < 0) && (!(SoundObjects[i].flags & SOF_PLAY_FOREVER)) ) { SoundObjects[i].flags = 0; return -1; } } return SoundObjects[i].signature; }
int digi_link_sound_to_pos2( int org_soundnum, short segnum, short sidenum, vms_vector * pos, int forever, fix max_volume, fix max_distance ) { int i, volume, pan; int soundnum; soundnum = digi_xlat_sound(org_soundnum); if ( max_volume < 0 ) return -1; // if ( max_volume > F1_0 ) max_volume = F1_0; if (soundnum < 0 ) return -1; if (GameSounds[soundnum].data==NULL) { Int3(); return -1; } if ((segnum<0)||(segnum>Highest_segment_index)) return -1; if ( !forever ) { //&& GameSounds[soundnum - SOUND_OFFSET].length < SOUND_3D_THRESHHOLD) { // Hack to keep sounds from building up... digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, pos, segnum, max_volume, &volume, &pan, max_distance ); digi_play_sample_3d( org_soundnum, pan, volume, 0 ); return -1; } for (i=0; i<MAX_SOUND_OBJECTS; i++ ) if (SoundObjects[i].flags==0) break; if (i==MAX_SOUND_OBJECTS) { return -1; } SoundObjects[i].signature=next_signature++; SoundObjects[i].flags = SOF_USED | SOF_LINK_TO_POS; if ( forever ) SoundObjects[i].flags |= SOF_PLAY_FOREVER; SoundObjects[i].link_type.pos.segnum = segnum; SoundObjects[i].link_type.pos.sidenum = sidenum; SoundObjects[i].link_type.pos.position = *pos; SoundObjects[i].soundnum = soundnum; SoundObjects[i].max_volume = max_volume; SoundObjects[i].max_distance = max_distance; SoundObjects[i].volume = 0; SoundObjects[i].pan = 0; SoundObjects[i].loop_start = SoundObjects[i].loop_end = -1; if (Dont_start_sound_objects) { //started at level start SoundObjects[i].flags |= SOF_PERMANENT; SoundObjects[i].channel = -1; } else { 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 ); digi_start_sound_object(i); // If it's a one-shot sound effect, and it can't start right away, then // just cancel it and be done with it. if ( (SoundObjects[i].channel < 0) && (!(SoundObjects[i].flags & SOF_PLAY_FOREVER)) ) { SoundObjects[i].flags = 0; return -1; } } return SoundObjects[i].signature; }