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

View file

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