diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1998-05-07 02:55:41 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1998-05-07 02:55:41 +0000 |
commit | dcec8a13bf565e47942a1751a9cec21bec5648fe (patch) | |
tree | 548b69625b18cc2e88c3e68d0923be546c9ebb03 /drivers/sound/softoss_rs.c | |
parent | 2e0f55e79c49509b7ff70ff1a10e1e9e90a3dfd4 (diff) |
o Merge with Linux 2.1.99.
o Fix ancient bug in the ELF loader making ldd crash.
o Fix ancient bug in the keyboard code for SGI, SNI and Jazz.
Diffstat (limited to 'drivers/sound/softoss_rs.c')
-rw-r--r-- | drivers/sound/softoss_rs.c | 177 |
1 files changed, 87 insertions, 90 deletions
diff --git a/drivers/sound/softoss_rs.c b/drivers/sound/softoss_rs.c index f8dac8ed5..17ebb8b59 100644 --- a/drivers/sound/softoss_rs.c +++ b/drivers/sound/softoss_rs.c @@ -5,8 +5,8 @@ * Software based MIDI synthsesizer driver, the actual mixing loop. * Keep the loop as simple as possible to make it easier to rewrite this * routine in assembly. - */ -/* + * + * * Copyright (C) by Hannu Savolainen 1993-1997 * * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL) @@ -21,10 +21,9 @@ #if defined(CONFIG_SOFTOSS) || defined(MODULE) #include "softoss.h" -void -softsynth_resample_loop(short *buf, int loops) +void softsynth_resample_loop(short *buf, int loops) { - int iloop, voice; + int iloop, voice; volatile voice_info *v; #ifdef OSS_BIG_ENDIAN @@ -33,104 +32,102 @@ softsynth_resample_loop(short *buf, int loops) #endif for (iloop = 0; iloop < loops; iloop++) - { /* Mix one sample */ - - int accum, left = 0, right = 0; - int ix, position; - - for (voice = 0; voice < devc->maxvoice; voice++) - if (voice_active[voice]) - { /* Compute voice */ - - v = &softoss_voices[voice]; + { /* Mix one sample */ + int accum, left = 0, right = 0; + int ix, position; + + for (voice = 0; voice < devc->maxvoice; voice++) + { + if (voice_active[voice]) + { /* Compute voice */ + v = &softoss_voices[voice]; #ifdef SOFTOSS_TEST - ix = iloop << 3; - position = v->ptr; + ix = iloop << 3; + position = v->ptr; #else - ix = (position = v->ptr) >> 9; + ix = (position = v->ptr) >> 9; #endif - /* Interpolation (resolution of 512 steps) */ - { - int fract = v->ptr & 0x1f; /* 9 bits */ - - /* This method works with less arithmetic operations */ - register int v1 = v->wave[ix]; - - accum = v1 + ((((v->wave[ix + 1] - v1)) * (fract)) >> 9); - } - - left += (accum * v->leftvol); - right += (accum * v->rightvol); - - /* Update sample pointer */ - - position += v->step; - if (position <= v->endloop) - v->ptr = position; - else if (v->mode & WAVE_LOOPING) - { - if (v->mode & WAVE_BIDIR_LOOP) - { - v->mode ^= WAVE_LOOP_BACK; /* Turn around */ - v->step *= -1; - } else - { - position -= v->looplen; - v->ptr = position; - } - } - /* else leave the voice looping the current sample */ - - if (v->mode & WAVE_LOOP_BACK && position < v->startloop) - { - if (v->mode & WAVE_BIDIR_LOOP) - { - v->mode ^= WAVE_LOOP_BACK; /* Turn around */ - v->step *= -1; - } else - { - position += v->looplen; - v->ptr = position; - } - } - } /* Compute voice */ + /* Interpolation (resolution of 512 steps) */ + { + int fract = v->ptr & 0x1f; /* 9 bits */ + + /* This method works with less arithmetic operations */ + register int v1 = v->wave[ix]; + accum = v1 + ((((v->wave[ix + 1] - v1)) * (fract)) >> 9); + } + + left += (accum * v->leftvol); + right += (accum * v->rightvol); + + /* Update sample pointer */ + position += v->step; + if (position <= v->endloop) + v->ptr = position; + else if (v->mode & WAVE_LOOPING) + { + if (v->mode & WAVE_BIDIR_LOOP) + { v->mode ^= WAVE_LOOP_BACK; /* Turn around */ + v->step *= -1; + } + else + { + position -= v->looplen; + v->ptr = position; + } + } + /* else leave the voice looping the current sample */ + + if (v->mode & WAVE_LOOP_BACK && position < v->startloop) + { + if (v->mode & WAVE_BIDIR_LOOP) + { v->mode ^= WAVE_LOOP_BACK; /* Turn around */ + v->step *= -1; + } + else + { + position += v->looplen; + v->ptr = position; + } + } + } /* Compute voice */ + } #if 1 /* Delay */ - left += left_delay[delayp]; - right += right_delay[delayp]; + left += left_delay[delayp]; + right += right_delay[delayp]; - left_delay[delayp] = right >> 2; - right_delay[delayp] = left >> 2; - delayp = (delayp + 1) % devc->delay_size; + left_delay[delayp] = right >> 2; + right_delay[delayp] = left >> 2; + delayp = (delayp + 1) % devc->delay_size; #endif #define AFTERSCALE devc->afterscale; - left >>= AFTERSCALE; - right >>= AFTERSCALE; + left >>= AFTERSCALE; + right >>= AFTERSCALE; - if (left > 32767) - left = 32767; - if (left < -32768) - left = -32768; - if (right > 32767) - right = 32767; - if (right < -32768) - right = -32768; + if (left > 32767) + left = 32767; + if (left < -32768) + left = -32768; + if (right > 32767) + right = 32767; + if (right < -32768) + right = -32768; #ifdef OSS_BIG_ENDIAN - *cbuf++ = left & 0xff; - *cbuf++ = (left >> 8) & 0xff; - *cbuf++ = right & 0xff; - *cbuf++ = (right >> 8) & 0xff; + *cbuf++ = left & 0xff; + *cbuf++ = (left >> 8) & 0xff; + *cbuf++ = right & 0xff; + *cbuf++ = (right >> 8) & 0xff; #else - *buf++ = left; - *buf++ = right; + *buf++ = left; + *buf++ = right; #endif - if (devc->control_counter++ >= devc->control_rate) - { - devc->control_counter = 0; - softsyn_control_loop(); - } - } /* Mix one sample */ + if (devc->control_counter++ >= devc->control_rate) + { + devc->control_counter = 0; + softsyn_control_loop(); + } + } /* Mix one sample */ } #endif |