fix volume regression

This commit is contained in:
tildearrow 2021-12-11 16:51:34 -05:00
parent 2f813c55e0
commit 93c88a093f
2 changed files with 14 additions and 14 deletions

View File

@ -992,14 +992,11 @@ void DivEngine::setLoops(int loops) {
void DivEngine::play() {
isBusy.lock();
for (int i=0; i<17; i++) {
chan[i]=DivChannelState();
}
dispatch->reset();
playing=true;
reset();
curRow=0;
clockDrift=0;
cycles=0;
playing=true;
isBusy.unlock();
}
@ -1009,6 +1006,15 @@ void DivEngine::stop() {
isBusy.unlock();
}
void DivEngine::reset() {
for (int i=0; i<17; i++) {
chan[i]=DivChannelState();
chan[i].volMax=(dispatch->dispatch(DivCommand(DIV_CMD_GET_VOLMAX,i))<<8)|0xff;
chan[i].volume=chan[i].volMax;
}
dispatch->reset();
}
unsigned char DivEngine::getOrder() {
return curOrder;
}
@ -1018,11 +1024,7 @@ void DivEngine::setOrder(unsigned char order) {
curOrder=order;
if (order>=song.ordersLen) curOrder=0;
if (playing) {
for (int i=0; i<17; i++) {
chan[i]=DivChannelState();
}
dispatch->reset();
playing=true;
reset();
curRow=0;
clockDrift=0;
cycles=0;
@ -1155,10 +1157,7 @@ bool DivEngine::init(String outName) {
blip_set_rates(bb[0],dispatch->rate,got.rate);
blip_set_rates(bb[1],dispatch->rate,got.rate);
for (int i=0; i<chans; i++) {
chan[i].volMax=(dispatch->dispatch(DivCommand(DIV_CMD_GET_VOLMAX,i))<<8)|0xff;
chan[i].volume=chan[i].volMax;
}
reset();
if (outName!="") {
short* ilBuffer=new short[got.bufsize*2];

View File

@ -90,6 +90,7 @@ class DivEngine {
void processRow(int i, bool afterDelay);
void nextOrder();
void nextRow();
void reset();
// returns true if end of song.
bool nextTick();
bool perSystemEffect(int ch, unsigned char effect, unsigned char effectVal);