Re: Full duplex in sound driver?

Petko Manolov (petkan@varel.bg)
Tue, 25 Aug 1998 18:07:51 +0000


fabio.ferrari wrote:
>
> I would recommend to use ALSA, but if you want to change OSS drivers

I don't care but default sound drivers shipping with linux tree are
OSS drivers. Did you send your patch to Hannu?

> please look at this address:
> http://www.iaccess.com.br/~fabio/docsb16fd.html
> It works now, but there are some problems. For example, mmap mode
> should not work.

static void
reduce_16_to_8 (unsigned char *buff, int n)
{
unsigned char *dest,*orig;
orig = dest = buff;
for( ; n >= 0 ; n--)
{
orig++;
*dest++ = *orig++;
}
}

I think this code from your patch is not correct. Even worse -
in signed samples case result is awfull. You didn't lower
signal level proportionaly rather than with constant. The result
is lowered with 8bit signal. The same is with coresponding
expand_8_to16().
The decision is to find MAX element from the 16bit samples and to
lower _proportionaly_ all samples acording to this MAX value but not
0xffff. Example for unsigned samples:

dvdr = MAX >> 8; /* for 16bit to 8bit case only;
MAX is computed already */
static void reduce_16_to_8( unsigned char *buf, int len ) {

unsigned char *dest,*orig;

dest = orig = buf;
for( ; len >= 0; len-- ) {
*dest = (unsigned char)(*((unsigned short *)orig)/dvdr);
dest++;
orig += 2;
}
}

This is much slower but _correct_. There is room for improvement.
For example if dvdr is equal to power of two you can replace the
division
with faster right shit, but this have to be checked.

Petkan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html