SMS: alleviate Nuked-PSG clicking, part 1

This commit is contained in:
tildearrow 2022-11-07 17:35:00 -05:00
parent 184a6bd6b2
commit 133627b325
2 changed files with 16 additions and 5 deletions

View file

@ -129,7 +129,7 @@ void DivPlatformSMS::tick(bool sysTick) {
if (chan[i].outVol<0) chan[i].outVol=0; if (chan[i].outVol<0) chan[i].outVol=0;
// old formula // old formula
// ((chan[i].vol&15)*MIN(15,chan[i].std.vol.val))>>4; // ((chan[i].vol&15)*MIN(15,chan[i].std.vol.val))>>4;
rWrite(0,0x90|(i<<5)|(isMuted[i]?15:(15-(chan[i].outVol&15)))); chan[i].writeVol=true;
} }
if (chan[i].std.arp.had) { if (chan[i].std.arp.had) {
if (!chan[i].inPorta) { if (!chan[i].inPorta) {
@ -235,6 +235,12 @@ void DivPlatformSMS::tick(bool sysTick) {
chan[3].freqChanged=false; chan[3].freqChanged=false;
updateSNMode=false; updateSNMode=false;
} }
for (int i=0; i<4; i++) {
if (chan[i].writeVol) {
rWrite(0,0x90|(i<<5)|(isMuted[i]?15:(15-(chan[i].outVol&15))));
chan[i].writeVol=false;
}
}
} }
int DivPlatformSMS::dispatch(DivCommand c) { int DivPlatformSMS::dispatch(DivCommand c) {
@ -250,7 +256,9 @@ int DivPlatformSMS::dispatch(DivCommand c) {
} }
chan[c.chan].active=true; chan[c.chan].active=true;
//if (!parent->song.brokenOutVol2) { //if (!parent->song.brokenOutVol2) {
rWrite(0,0x90|c.chan<<5|(isMuted[c.chan]?15:(15-(chan[c.chan].vol&15)))); chan[c.chan].writeVol=true;
chan[c.chan].outVol=chan[c.chan].vol;
//rWrite(0,0x90|c.chan<<5|(isMuted[c.chan]?15:(15-(chan[c.chan].vol&15))));
//} //}
chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_STD)); chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_STD));
if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) { if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) {
@ -276,7 +284,9 @@ int DivPlatformSMS::dispatch(DivCommand c) {
if (!chan[c.chan].std.vol.has) { if (!chan[c.chan].std.vol.has) {
chan[c.chan].outVol=c.value; chan[c.chan].outVol=c.value;
} }
if (chan[c.chan].active) rWrite(0,0x90|c.chan<<5|(isMuted[c.chan]?15:(15-(chan[c.chan].vol&15)))); if (chan[c.chan].active) {
chan[c.chan].writeVol=true;
}
} }
break; break;
case DIV_CMD_GET_VOLUME: case DIV_CMD_GET_VOLUME:
@ -356,7 +366,7 @@ int DivPlatformSMS::dispatch(DivCommand c) {
void DivPlatformSMS::muteChannel(int ch, bool mute) { void DivPlatformSMS::muteChannel(int ch, bool mute) {
isMuted[ch]=mute; isMuted[ch]=mute;
if (chan[ch].active) rWrite(0,0x90|ch<<5|(isMuted[ch]?15:(15-(chan[ch].outVol&15)))); if (chan[ch].active) chan[ch].writeVol=true;
} }
void DivPlatformSMS::forceIns() { void DivPlatformSMS::forceIns() {

View file

@ -31,7 +31,7 @@ extern "C" {
class DivPlatformSMS: public DivDispatch { class DivPlatformSMS: public DivDispatch {
struct Channel { struct Channel {
int freq, baseFreq, pitch, pitch2, note, actualNote, ins; int freq, baseFreq, pitch, pitch2, note, actualNote, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta; bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, writeVol;
signed char vol, outVol; signed char vol, outVol;
DivMacroInt std; DivMacroInt std;
void macroInit(DivInstrument* which) { void macroInit(DivInstrument* which) {
@ -52,6 +52,7 @@ class DivPlatformSMS: public DivDispatch {
keyOn(false), keyOn(false),
keyOff(false), keyOff(false),
inPorta(false), inPorta(false),
writeVol(false),
vol(15), vol(15),
outVol(15) {} outVol(15) {}
}; };