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; }
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; }
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; }