diff -r -u esound-0.2.23.orig/esd.c esound-0.2.23/esd.c --- esound-0.2.23.orig/esd.c Sun Sep 9 19:56:36 2001 +++ esound-0.2.23/esd.c Fri Jan 25 01:29:51 2002 @@ -487,7 +487,7 @@ int first = 1; - int default_format = ESD_BITS16 | ESD_STEREO; + int default_format = ESD_BITS8 | ESD_MONO; /* end test scaffolding parameters */ /* parse the command line args */ @@ -517,6 +517,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 ] ); @@ -576,6 +579,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" ); fprintf( stderr, " -unix use unix domain sockets instead of tcp/ip\n" ); diff -r -u esound-0.2.23.orig/esd.h esound-0.2.23/esd.h --- esound-0.2.23.orig/esd.h Sun Nov 5 06:57:58 2000 +++ esound-0.2.23/esd.h Fri Jan 25 01:29:51 2002 @@ -20,7 +20,7 @@ #define ESD_DEFAULT_PORT (16001) /* 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.23.orig/mix.c esound-0.2.23/mix.c --- esound-0.2.23.orig/mix.c Mon Sep 20 00:51:34 1999 +++ esound-0.2.23/mix.c Fri Jan 25 01:29:51 2002 @@ -37,6 +37,7 @@ void clip_mix_to_output_16s( signed short *output, int length ); void clip_mix_to_output_8u( unsigned char *output, int length ); +void clip_mix_to_output_8u_mono( unsigned char *output, int length ); /* TODO: straighten out the mix algorithm comment annotations */ /* TOTO: i don't think we're in kansas anymore... */ @@ -870,6 +871,27 @@ } } } +/*******************************************************************/ +/* takes mixed data, and clips data to the output buffer */ +void clip_mix_to_output_8u_mono( unsigned 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 */ @@ -919,11 +941,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; Only in esound-0.2.23: mix.c.orig