Skip to content

Commit

Permalink
engine: soundlib: add support for converting stereo to mono and back,…
Browse files Browse the repository at this point in the history
… attempt to simplify conversion boilerplate
  • Loading branch information
a1batross committed Jul 15, 2024
1 parent 56ba232 commit c5e4c0c
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 301 deletions.
6 changes: 3 additions & 3 deletions engine/client/s_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ wavdata_t *S_LoadSound( sfx_t *sfx )
if( !sc ) sc = S_CreateDefaultSound();

if( sc->rate < SOUND_11k ) // some bad sounds
Sound_Process( &sc, SOUND_11k, sc->width, SOUND_RESAMPLE );
Sound_Process( &sc, SOUND_11k, sc->width, sc->channels, SOUND_RESAMPLE );
else if( sc->rate > SOUND_11k && sc->rate < SOUND_22k ) // some bad sounds
Sound_Process( &sc, SOUND_22k, sc->width, SOUND_RESAMPLE );
Sound_Process( &sc, SOUND_22k, sc->width, sc->channels, SOUND_RESAMPLE );
else if( sc->rate > SOUND_22k && sc->rate < SOUND_44k ) // some bad sounds
Sound_Process( &sc, SOUND_44k, sc->width, SOUND_RESAMPLE );
Sound_Process( &sc, SOUND_44k, sc->width, sc->channels, SOUND_RESAMPLE );

sfx->cache = sc;

Expand Down
2 changes: 1 addition & 1 deletion engine/client/voice.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void Voice_RecordStart( void )

if( voice.input_file )
{
Sound_Process( &voice.input_file, voice.samplerate, voice.width, SOUND_RESAMPLE );
Sound_Process( &voice.input_file, voice.samplerate, voice.width, VOICE_PCM_CHANNELS, SOUND_RESAMPLE );
voice.input_file_pos = 0;

voice.start_time = Sys_DoubleTime();
Expand Down
2 changes: 1 addition & 1 deletion engine/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ int FS_ReadStream( stream_t *stream, int bytes, void *buffer );
int FS_SetStreamPos( stream_t *stream, int newpos );
int FS_GetStreamPos( stream_t *stream );
void FS_FreeStream( stream_t *stream );
qboolean Sound_Process( wavdata_t **wav, int rate, int width, uint flags );
qboolean Sound_Process( wavdata_t **wav, int rate, int width, int channels, uint flags );
uint Sound_GetApproxWavePlayLen( const char *filepath );
qboolean Sound_SupportedFileFormat( const char *fileext );

Expand Down
Loading

0 comments on commit c5e4c0c

Please sign in to comment.