Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update all sounds relative to the player #57

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rott/fx_man.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ int FX_SoundActive( int handle );
int FX_StopSound( int handle );
int FX_StopAllSounds( void );

int FX_SetXY(int handle, int x, int y);
int FX_AllSoundsRTP(void);

#if 0
int FX_StartDemandFeedPlayback( void ( *function )( char **ptr, unsigned long *length ),
int rate, int pitchoffset, int vol, int left, int right,
Expand Down
35 changes: 34 additions & 1 deletion rott/fx_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static struct
{
sound_t *sfx;
int x, y;
} channels[MAX_CHANNELS];

static int FX_Installed = 0;
Expand Down Expand Up @@ -209,7 +210,7 @@ int FX_StopSound(int handle)
channels[handle].sfx->count--;
}

channels[handle].sfx = NULL;
memset(&channels[handle], 0, sizeof(channels[handle]));
}

return FX_Ok;
Expand Down Expand Up @@ -407,6 +408,16 @@ int FX_Play(int handle, int sndnum, int pitchoffset, int angle, int distance,
return -1;
}

int FX_SetXY(int handle, int x, int y)
{
CHECK_HANDLE(handle);

channels[handle].x = x;
channels[handle].y = y;

return FX_Ok;
}

int FX_SetPitch(int handle, int pitchoffset)
{
return FX_Ok;
Expand All @@ -433,3 +444,25 @@ int FX_StopAllSounds(void)

return FX_Ok;
}

int FX_AllSoundsRTP(void)
{
int i;

for (i = 0; i < MAX_CHANNELS; i++)
{
if (FX_SoundActive(i))
{
if (channels[i].x | channels[i].y)
{
SD_PanRTP(i, channels[i].x, channels[i].y);
}
}
else
{
FX_StopSound(i);
}
}

return FX_Ok;
}
2 changes: 2 additions & 0 deletions rott/rt_playr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5938,6 +5938,8 @@ void T_Player (objtype *ob)
}
#endif

// [FG] update all sound pannings relative to the player
SD_AllSoundsRTP();
}


Expand Down
9 changes: 9 additions & 0 deletions rott/rt_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ int SD_PlaySoundRTP ( int sndnum, int x, int y )

voice = SD_PlayIt ( sndnum, angle, distance, pitch );

FX_SetXY(voice, x, y);

return voice;
}

Expand Down Expand Up @@ -499,12 +501,19 @@ void SD_PanRTP ( int handle, int x, int y )

status = FX_Pan3D ( handle, angle, distance );

FX_SetXY(handle, x, y);

if (status != FX_Ok)
{
//TODO: This code does nothing.
}
}

void SD_AllSoundsRTP(void)
{
FX_AllSoundsRTP();
}

//***************************************************************************
//
// SD_SetPan - set the pan of a sample
Expand Down
1 change: 1 addition & 0 deletions rott/rt_sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ int SD_Play3D ( int sndnum, int angle, int distance );
int SD_PlayPitchedSound ( int sndnum, int volume, int pitch );
void SD_SetSoundPitch ( int sndnum, int pitch );
boolean SD_SoundOkay ( int sndnum );
void SD_AllSoundsRTP(void);

//***************************************************************************
//
Expand Down
Loading