Index: sid.c =================================================================== --- sid.c (Revision 24790) +++ sid.c (Arbeitskopie) @@ -71,7 +71,9 @@ * */ -static int32_t samples[CHUNK_SIZE] IBSS_ATTR; /* The sample buffer */ +/* The sample buffers */ +static int32_t samples_r[CHUNK_SIZE] IBSS_ATTR; +static int32_t samples_l[CHUNK_SIZE] IBSS_ATTR; /* Static buffer for the plain SID-File */ static unsigned char sidfile[0x10000]; @@ -348,8 +350,8 @@ } /* render a buffer of n samples with the actual register contents */ -void synth_render (int32_t *buffer, unsigned long len) ICODE_ATTR; -void synth_render (int32_t *buffer, unsigned long len) +void synth_render (int32_t *buffer_r, int32_t *buffer_l, unsigned long len) ICODE_ATTR; +void synth_render (int32_t *buffer_r, int32_t *buffer_l, unsigned long len) { unsigned long bp; /* step 1: convert the not easily processable sid registers into some @@ -392,9 +394,9 @@ /* now render the buffer */ for (bp=0;bp>22; + outf[v&1]+=(((int)(outv-0x80))*osc[v].envval)>>22; else - outo+=(((int)(outv-0x80))*osc[v].envval)>>22; + outo[v&1]+=(((int)(outv-0x80))*osc[v].envval)>>22; } #endif #ifndef USE_FILTER - /* Don't use filters, just mix all voices together */ - outf+=((signed short)(outv-0x80)) * (osc[v].envval>>4); + /* Don't use filters, just mix voices together */ + outf[v&1]+=((signed short)(outv-0x80)) * (osc[v].envval>>4); #endif - } + } /* for (v=0;v<3;v++) */ #ifdef USE_FILTER @@ -526,23 +528,30 @@ * This filter sounds a lot like the 8580, as the low-quality, dirty * sound of the 6581 is uuh too hard to achieve :) */ - filter.h = quickfloat_ConvertFromInt(outf) - (filter.b>>8)*filter.rez - filter.l; - filter.b += quickfloat_Multiply(filter.freq, filter.h); - filter.l += quickfloat_Multiply(filter.freq, filter.b); + outf[0]+=outf[2]; /* mix voice 1 and 3 to right channel */ + for (v=0;v<2;v++) { /* do step 3 for both channels */ + filter.h = quickfloat_ConvertFromInt(outf[v]) - (filter.b>>8)*filter.rez - filter.l; + filter.b += quickfloat_Multiply(filter.freq, filter.h); + filter.l += quickfloat_Multiply(filter.freq, filter.b); - outf = 0; + outf[v] = 0; - if (filter.l_ena) outf+=quickfloat_ConvertToInt(filter.l); - if (filter.b_ena) outf+=quickfloat_ConvertToInt(filter.b); - if (filter.h_ena) outf+=quickfloat_ConvertToInt(filter.h); + if (filter.l_ena) outf[v]+=quickfloat_ConvertToInt(filter.l); + if (filter.b_ena) outf[v]+=quickfloat_ConvertToInt(filter.b); + if (filter.h_ena) outf[v]+=quickfloat_ConvertToInt(filter.h); + } - int final_sample = (filter.vol*(outo+outf)); - *(buffer+bp)= GenerateDigi(final_sample)<<13; + /* mix in other channel to reduce stereo panning for better sound on headphones */ + int final_sample_r = filter.vol*((outo[0]+outf[0]) + ((outo[1]+outf[1])>>4)); + int final_sample_l = filter.vol*((outo[1]+outf[1]) + ((outo[0]+outf[0])>>4)); + *(buffer_r+bp)= GenerateDigi(final_sample_r)<<13; + *(buffer_l+bp)= GenerateDigi(final_sample_l)<<13; #endif #ifndef USE_FILTER - *(buffer+bp) = GenerateDigi(outf)<<3; + *(buffer_r+bp) = GenerateDigi(outf[0])<<3; + *(buffer_l+bp) = GenerateDigi(outf[1])<<3; #endif - } + } /*for (bp=0;bpconfigure(DSP_SET_SAMPLE_DEPTH, 28); /* Mono output */ - ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); + ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); /* Set the elapsed time to the current subsong (in seconds) */ @@ -1291,19 +1300,19 @@ } if (nSamplesRendered + nSamplesToRender > CHUNK_SIZE) { - synth_render(samples+nSamplesRendered, CHUNK_SIZE-nSamplesRendered); + synth_render(samples_r+nSamplesRendered, samples_l+nSamplesRendered, CHUNK_SIZE-nSamplesRendered); nSamplesToRender -= CHUNK_SIZE-nSamplesRendered; nSamplesRendered = CHUNK_SIZE; } else { - synth_render(samples+nSamplesRendered, nSamplesToRender); + synth_render(samples_r+nSamplesRendered, samples_l+nSamplesRendered, nSamplesToRender); nSamplesRendered += nSamplesToRender; nSamplesToRender = 0; } } - ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE); + ci->pcmbuf_insert(samples_r, samples_l, CHUNK_SIZE); } if (ci->request_next_track())