diff -r -u esound-0.2.8.orig/esd.c esound-0.2.8/esd.c --- esound-0.2.8.orig/esd.c Tue Feb 16 07:20:35 1999 +++ esound-0.2.8/esd.c Fri Jan 18 14:47:45 2002 @@ -278,7 +278,7 @@ int i, j, freq=440; int magl, magr; - int default_format = ESD_BITS16 | ESD_STEREO; + int default_format = ESD_BITS8 | ESD_MONO; /* end test scaffolding parameters */ /* parse the command line args */ @@ -308,6 +308,9 @@ } else if ( !strcmp( argv[ arg ], "-b" ) ) { fprintf( stderr, "- server format: 8 bit samples\n" ); default_format &= ~ESD_MASK_BITS; default_format |= ESD_BITS8; + } else if ( !strcmp( argv[ arg ], "-m" ) ) { + fprintf( stderr, "- server format: mono samples\n" ); + default_format &= ~ESD_MASK_CHAN; default_format |= ESD_MONO; } else if ( !strcmp( argv[ arg ], "-r" ) ) { if ( ++arg != argc ) { default_rate = atoi( argv[ arg ] ); @@ -348,6 +351,7 @@ fprintf( stderr, "Usage: esd [options]\n\n" ); fprintf( stderr, " -d DEVICE force esd to use sound device DEVICE\n" ); fprintf( stderr, " -b run server in 8 bit sound mode\n" ); + fprintf( stderr, " -m run server in mono sound mode\n" ); fprintf( stderr, " -r RATE run server at sample rate of RATE\n" ); fprintf( stderr, " -as SECS free audio device after SECS of inactivity\n" ); #ifdef ESDBG diff -r -u esound-0.2.8.orig/esd.h esound-0.2.8/esd.h --- esound-0.2.8.orig/esd.h Tue Feb 16 05:59:35 1999 +++ esound-0.2.8/esd.h Fri Jan 18 14:47:45 2002 @@ -16,7 +16,7 @@ #define ESD_DEFAULT_PORT (5001) /* default sample rate for the EsounD server */ -#define ESD_DEFAULT_RATE (44100) +#define ESD_DEFAULT_RATE (22050) /* maximum length of a stream/sample name */ #define ESD_NAME_MAX (128) diff -r -u esound-0.2.8.orig/mix.c esound-0.2.8/mix.c --- esound-0.2.8.orig/mix.c Thu Feb 11 01:48:55 1999 +++ esound-0.2.8/mix.c Fri Jan 18 14:48:34 2002 @@ -37,6 +37,7 @@ void clip_mix_to_output_16s( signed short *output, int length ); void clip_mix_to_output_8u( signed char *output, int length ); +void clip_mix_to_output_8u_mono( signed char *output, int length ); /* TODO: straighten out the mix algorithm comment annotations */ /* TOTO: i don't think we're in kansas anymore... */ @@ -871,6 +872,27 @@ } } } +/*******************************************************************/ +/* takes mixed data, and clips data to the output buffer */ +void clip_mix_to_output_8u_mono( signed char *output, int length ) +{ + signed int *mixed = mixed_buffer; + signed int *end = mixed_buffer + length/sizeof(signed short); + + ESDBG_MIXER( printf( "clipping mix to output 8 bit mono (%d bytes)\n", + length ); ); + + while ( mixed < end ) { + if (*mixed < SHRT_MIN) { + *output++ = 0; mixed++; + } else if (*mixed > SHRT_MAX) { + *output++ = 255; mixed++; + } else { + *output++ = (*mixed++) / 256 + 128; + } + mixed++; + } +} /*******************************************************************/ /* takes all input players, and mixes them to the mixed_buffer */ @@ -920,11 +942,17 @@ /* ESDBG_COMMS( printf( "maximum stream length = %d bytes\n", max ); ); */ - if ( (esd_audio_format & ESD_MASK_BITS) == ESD_BITS16 ) - clip_mix_to_output_16s( output, max ); + if ( (esd_audio_format & ESD_MASK_CHAN) == ESD_STEREO ) { + if ( (esd_audio_format & ESD_MASK_BITS) == ESD_BITS16 ) + clip_mix_to_output_16s( output, max ); + else { + clip_mix_to_output_8u( output, max ); + max /= 2; /* half as many samples as you'd think */ + } + } else { - clip_mix_to_output_8u( output, max ); - max /= 2; /* half as many samples as you'd think */ + clip_mix_to_output_8u_mono( output, max ); + max /= 4; } return max;