fix panbrello depth

This commit is contained in:
tildearrow 2024-08-16 23:59:20 -05:00
parent 3b04df7a13
commit 8ad9bfa245

View file

@ -1647,26 +1647,34 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
chan[i].panPos+=chan[i].panRate; chan[i].panPos+=chan[i].panRate;
chan[i].panPos&=255; chan[i].panPos&=255;
// calculate... // calculate inverted...
switch (chan[i].panPos&0xc0) { switch (chan[i].panPos&0xc0) {
case 0: // center -> right case 0: // center -> right
chan[i].panL=0xff-((chan[i].panPos&0x3f)<<2); chan[i].panL=((chan[i].panPos&0x3f)<<2);
chan[i].panR=0xff; chan[i].panR=0;
break; break;
case 0x40: // right -> center case 0x40: // right -> center
chan[i].panL=(chan[i].panPos&0x3f)<<2; chan[i].panL=0xff-((chan[i].panPos&0x3f)<<2);
chan[i].panR=0xff; chan[i].panR=0;
break; break;
case 0x80: // center -> left case 0x80: // center -> left
chan[i].panL=0xff; chan[i].panL=0;
chan[i].panR=0xff-((chan[i].panPos&0x3f)<<2); chan[i].panR=((chan[i].panPos&0x3f)<<2);
break; break;
case 0xc0: // left -> center case 0xc0: // left -> center
chan[i].panL=0xff; chan[i].panL=0;
chan[i].panR=(chan[i].panPos&0x3f)<<2; chan[i].panR=0xff-((chan[i].panPos&0x3f)<<2);
break; break;
} }
// multiply by depth
chan[i].panL=(chan[i].panL*chan[i].panDepth)/15;
chan[i].panR=(chan[i].panR*chan[i].panDepth)/15;
// then invert it to get final panning
chan[i].panL^=0xff;
chan[i].panR^=0xff;
dispatchCmd(DivCommand(DIV_CMD_PANNING,i,chan[i].panL,chan[i].panR)); dispatchCmd(DivCommand(DIV_CMD_PANNING,i,chan[i].panL,chan[i].panR));
} }