Fix sound DC levels
This was causing popping in Mega Man (I)
This commit is contained in:
parent
0ba9fa35b6
commit
8dac6800be
4 changed files with 9 additions and 11 deletions
|
@ -220,14 +220,13 @@ void Channel1::loadState(const SaveState &state) {
|
|||
|
||||
void Channel1::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cycles) {
|
||||
const unsigned outBase = envelopeUnit.dacIsOn() ? soBaseVol & soMask : 0;
|
||||
const unsigned outLow = outBase * (0 - 15ul);
|
||||
const unsigned endCycles = cycleCounter + cycles;
|
||||
|
||||
for (;;) {
|
||||
const unsigned outHigh = master ? outBase * (envelopeUnit.getVolume() * 2 - 15ul) : outLow;
|
||||
const unsigned outHigh = master ? outBase * (envelopeUnit.getVolume()) : 0;
|
||||
const unsigned outLow = -outHigh;
|
||||
const unsigned nextMajorEvent = nextEventUnit->getCounter() < endCycles ? nextEventUnit->getCounter() : endCycles;
|
||||
unsigned out = dutyUnit.isHighState() ? outHigh : outLow;
|
||||
|
||||
while (dutyUnit.getCounter() <= nextMajorEvent) {
|
||||
*buf = out - prevOut;
|
||||
prevOut = out;
|
||||
|
|
|
@ -125,11 +125,11 @@ void Channel2::loadState(const SaveState &state) {
|
|||
|
||||
void Channel2::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cycles) {
|
||||
const unsigned outBase = envelopeUnit.dacIsOn() ? soBaseVol & soMask : 0;
|
||||
const unsigned outLow = outBase * (0 - 15ul);
|
||||
const unsigned endCycles = cycleCounter + cycles;
|
||||
|
||||
for (;;) {
|
||||
const unsigned outHigh = master ? outBase * (envelopeUnit.getVolume() * 2 - 15ul) : outLow;
|
||||
const unsigned outHigh = master ? outBase * (envelopeUnit.getVolume()) : 0;
|
||||
const unsigned outLow = -outHigh;
|
||||
const unsigned nextMajorEvent = nextEventUnit->getCounter() < endCycles ? nextEventUnit->getCounter() : endCycles;
|
||||
unsigned out = dutyUnit.isHighState() ? outHigh : outLow;
|
||||
while (dutyUnit.getCounter() <= nextMajorEvent) {
|
||||
|
|
|
@ -155,7 +155,7 @@ void Channel3::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cy
|
|||
|
||||
for (;;) {
|
||||
const unsigned nextMajorEvent = lengthCounter.getCounter() < endCycles ? lengthCounter.getCounter() : endCycles;
|
||||
unsigned out = outBase * (master ? ((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - 15ul : 0 - 15ul);
|
||||
unsigned out = outBase * (master ? ((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - (15 >> rShift) : 0);
|
||||
|
||||
while (waveCounter <= nextMajorEvent) {
|
||||
*buf += out - prevOut;
|
||||
|
@ -168,7 +168,7 @@ void Channel3::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cy
|
|||
++wavePos;
|
||||
wavePos &= 0x1F;
|
||||
sampleBuf = waveRam[wavePos >> 1];
|
||||
out = outBase * (/*master ? */((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - 15ul/* : 0 - 15ul*/);
|
||||
out = outBase * (/*master ? */((sampleBuf >> (~wavePos << 2 & 4) & 0xF) >> rShift) * 2 - (15 >> rShift)/* : 0 - 15ul*/);
|
||||
}
|
||||
|
||||
if (cycleCounter < nextMajorEvent) {
|
||||
|
@ -184,7 +184,7 @@ void Channel3::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cy
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
unsigned const out = outBase * (0 - 15ul);
|
||||
unsigned const out = outBase * 0;
|
||||
*buf += out - prevOut;
|
||||
prevOut = out;
|
||||
cycleCounter += cycles;
|
||||
|
|
|
@ -264,14 +264,13 @@ void Channel4::loadState(const SaveState &state) {
|
|||
|
||||
void Channel4::update(uint_least32_t *buf, const unsigned soBaseVol, unsigned cycles) {
|
||||
const unsigned outBase = envelopeUnit.dacIsOn() ? soBaseVol & soMask : 0;
|
||||
const unsigned outLow = outBase * (0 - 15ul);
|
||||
const unsigned endCycles = cycleCounter + cycles;
|
||||
|
||||
for (;;) {
|
||||
const unsigned outHigh = /*master ? */outBase * (envelopeUnit.getVolume() * 2 - 15ul)/* : outLow*/;
|
||||
const unsigned outHigh = /*master ? */outBase * (envelopeUnit.getVolume())/* : outLow*/;
|
||||
const unsigned outLow = -outHigh;
|
||||
const unsigned nextMajorEvent = nextEventUnit->getCounter() < endCycles ? nextEventUnit->getCounter() : endCycles;
|
||||
unsigned out = lfsr.isHighState() ? outHigh : outLow;
|
||||
|
||||
while (lfsr.getCounter() <= nextMajorEvent) {
|
||||
*buf += out - prevOut;
|
||||
prevOut = out;
|
||||
|
|
Loading…
Add table
Reference in a new issue