@@ -186,33 +186,35 @@ void LamePaulaMixer::initMixTables() {
186186 voicesPerChannel = ((voices+1 )&0xfe )/channels;
187187 }
188188
189+ // Input samples: 8-bit signed 80,81,82,...,FE,FF,00,01,02,...,7E,7F
190+ // Array: 00->x, 01->x, ...,7E->x,7F->x,80->x,81->,82->,...,FE->x/,FF->x
189191 uword ui;
190192 long si;
191193 for (udword vol=0 ; vol<=PaulaVoice::VOLUME_MAX; vol++) {
192194 long spc;
193- // Input samples: 80,81,82,...,FE,FF,00,01,02,...,7E,7F
194- // Array: 00/x, 01/x, 02/x,...,7E/x,7F/x,80/x,81/x,82/x,...,FE/x/,FF/x
195+
195196 ui = (vol<<8 );
196197 si = 0 ;
197- while (si++ < 128 ) {
198- mix8vol[ui] = 0x80 + (si*vol)/PaulaVoice::VOLUME_MAX;
198+ while (si < 128 ) {
199+ mix8vol[ui] = (si*vol)/PaulaVoice::VOLUME_MAX;
199200 spc = ((si/voicesPerChannel)*vol)/PaulaVoice::VOLUME_MAX;
200201 mix8mono[ui] = (sbyte)spc;
201202 mix8right[ui] = (sbyte)(spc*panRight);
202203 mix8left[ui] = (sbyte)(spc*panLeft);
203204 ui++;
205+ si++;
204206 }
205207 si = -128 ;
206- while (si++ < 0 ) {
207- mix8vol[ui] = 0x80 + (si*vol)/PaulaVoice::VOLUME_MAX;
208+ while (si < 0 ) {
209+ mix8vol[ui] = (si*vol)/PaulaVoice::VOLUME_MAX;
208210 spc = ((si/voicesPerChannel)*vol)/PaulaVoice::VOLUME_MAX;
209211 mix8mono[ui] = (sbyte)spc;
210212 mix8right[ui] = (sbyte)(spc*panRight);
211213 mix8left[ui] = (sbyte)(spc*panLeft);
212214 ui++;
215+ si++;
213216 }
214- // Input samples: 80,81,82,...,FE,FF,00,01,02,...,7E,7F
215- // Array: 0/x, 100/x, 200/x, ..., FF00/x
217+
216218 ui = (vol<<8 );
217219 si = 0 ;
218220 while (si < 128 *256 ) {
@@ -282,11 +284,11 @@ void LamePaulaMixer::updateVoiceVolume() {
282284}
283285
284286ubyte LamePaulaMixer::getSample_7V () {
285- uword sam = (ubyte) mix8vol[(voiceVol[3 ]<<8 )+pVoice[3 ]->getSample ()];
286- sam += (ubyte) mix8vol[(voiceVol[4 ]<<8 )+pVoice[4 ]->getSample ()];
287- sam += (ubyte) mix8vol[(voiceVol[5 ]<<8 )+pVoice[5 ]->getSample ()];
288- sam += (ubyte) mix8vol[(voiceVol[6 ]<<8 )+pVoice[6 ]->getSample ()];
289- return clipping4[sam];
287+ sword sam = mix8vol[(voiceVol[3 ]<<8 )+pVoice[3 ]->getSample ()];
288+ sam += mix8vol[(voiceVol[4 ]<<8 )+pVoice[4 ]->getSample ()];
289+ sam += mix8vol[(voiceVol[5 ]<<8 )+pVoice[5 ]->getSample ()];
290+ sam += mix8vol[(voiceVol[6 ]<<8 )+pVoice[6 ]->getSample ()];
291+ return clipping4[0x200 + sam];
290292}
291293
292294void LamePaulaMixer::fillBuffer (void * buffer, udword bufferLen, PaulaPlayer *player) {
0 commit comments