filename | src/aica/audio.c |
changeset | 82:81a4acf75f10 |
prev | 79:6d832137fdff |
next | 106:9048bac046c3 |
author | nkeynes |
date | Sun Jan 22 22:40:05 2006 +0000 (18 years ago) |
permissions | -rw-r--r-- |
last change | Add aica_enable() function for aica-only mode, disable by default Halt ARM on invalid address but leave everything else running Error if ESD can't start |
file | annotate | diff | log | raw |
1.1 --- a/src/aica/audio.c Mon Jan 16 11:23:05 2006 +00001.2 +++ b/src/aica/audio.c Sun Jan 22 22:40:05 2006 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: audio.c,v 1.3 2006-01-16 11:23:05 nkeynes Exp $1.6 + * $Id: audio.c,v 1.4 2006-01-17 12:54:02 nkeynes Exp $1.7 *1.8 * Audio mixer core. Combines all the active streams into a single sound1.9 * buffer for output.1.10 @@ -25,7 +25,7 @@1.11 #include <string.h>1.13 #define NUM_BUFFERS 31.14 -#define MS_PER_BUFFER 1001.15 +#define MS_PER_BUFFER 10001.17 #define BUFFER_EMPTY 01.18 #define BUFFER_WRITING 11.19 @@ -186,12 +186,14 @@1.20 audio_channel_t channel = &audio.channels[i];1.21 if( channel->active ) {1.22 int32_t sample;1.23 + int vol_left = (channel->vol * (32 - channel->pan)) >> 5;1.24 + int vol_right = (channel->vol * (channel->pan + 1)) >> 5;1.25 switch( channel->sample_format ) {1.26 case AUDIO_FMT_16BIT:1.27 for( j=0; j<num_samples; j++ ) {1.28 sample = *(int16_t *)(arm_mem + channel->posn + channel->start);1.29 - result_buf[j][0] += sample * channel->vol_left;1.30 - result_buf[j][1] += sample * channel->vol_right;1.31 + result_buf[j][0] += sample * vol_left;1.32 + result_buf[j][1] += sample * vol_right;1.34 channel->posn_left += channel->sample_rate;1.35 while( channel->posn_left > audio.output_rate ) {1.36 @@ -213,8 +215,8 @@1.37 case AUDIO_FMT_8BIT:1.38 for( j=0; j<num_samples; j++ ) {1.39 sample = (*(int8_t *)(arm_mem + channel->posn + channel->start)) << 8;1.40 - result_buf[j][0] += sample * channel->vol_left;1.41 - result_buf[j][1] += sample * channel->vol_right;1.42 + result_buf[j][0] += sample * vol_left;1.43 + result_buf[j][1] += sample * vol_right;1.45 channel->posn_left += channel->sample_rate;1.46 while( channel->posn_left > audio.output_rate ) {1.47 @@ -236,8 +238,8 @@1.48 case AUDIO_FMT_ADPCM:1.49 for( j=0; j<num_samples; j++ ) {1.50 sample = (int16_t)channel->adpcm_predict;1.51 - result_buf[j][0] += sample * channel->vol_left;1.52 - result_buf[j][1] += sample * channel->vol_right;1.53 + result_buf[j][0] += sample * vol_left;1.54 + result_buf[j][1] += sample * vol_right;1.55 channel->posn_left += channel->sample_rate;1.56 while( channel->posn_left > audio.output_rate ) {1.57 channel->posn_left -= audio.output_rate;1.58 @@ -273,8 +275,8 @@1.59 audio_buffer_t buf = audio.output_buffers[audio.write_buffer];1.60 uint16_t *data = (uint16_t *)&buf->data[buf->posn];1.61 for( j=0; j < num_samples; j++ ) {1.62 - *data++ = (int16_t)(result_buf[j][0] >> 8);1.63 - *data++ = (int16_t)(result_buf[j][1] >> 8);1.64 + *data++ = (int16_t)(result_buf[j][0] >> 6);1.65 + *data++ = (int16_t)(result_buf[j][1] >> 6);1.66 buf->posn += 4;1.67 if( buf->posn == buf->length ) {1.68 audio_next_write_buffer();
.