rework noise readout, alter noise freq for specific feedback bits config
This commit is contained in:
parent
4079f7a8c3
commit
80933510a5
|
@ -72,6 +72,19 @@ const char* regCheatSheetSID3[]={
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t LFSRmask;
|
||||||
|
float freqScaling;
|
||||||
|
} noiseFreqData;
|
||||||
|
|
||||||
|
const noiseFreqData noiseInterestingWavesData[] =
|
||||||
|
{
|
||||||
|
{524288, 523.0f / 1675.0f}, //wave very close to SID2 noise mode 1 wave
|
||||||
|
|
||||||
|
{0, 0.0f}, //end marker
|
||||||
|
};
|
||||||
|
|
||||||
const char** DivPlatformSID3::getRegisterSheet() {
|
const char** DivPlatformSID3::getRegisterSheet() {
|
||||||
return regCheatSheetSID3;
|
return regCheatSheetSID3;
|
||||||
}
|
}
|
||||||
|
@ -490,6 +503,7 @@ void DivPlatformSID3::tick(bool sysTick)
|
||||||
if (chan[i].std.ex7.had) { //noise LFSR feedback bits
|
if (chan[i].std.ex7.had) { //noise LFSR feedback bits
|
||||||
chan[i].noiseLFSRMask = chan[i].std.ex7.val & 0x3fffffff;
|
chan[i].noiseLFSRMask = chan[i].std.ex7.val & 0x3fffffff;
|
||||||
updateNoiseLFSRMask(i);
|
updateNoiseLFSRMask(i);
|
||||||
|
chan[i].noiseFreqChanged = true;
|
||||||
}
|
}
|
||||||
if (chan[i].std.op[1].ar.had) { //1-bit noise / PCM mode for wavetable chan
|
if (chan[i].std.op[1].ar.had) { //1-bit noise / PCM mode for wavetable chan
|
||||||
if(i == SID3_NUM_CHANNELS - 1) //wave chan
|
if(i == SID3_NUM_CHANNELS - 1) //wave chan
|
||||||
|
@ -714,15 +728,27 @@ void DivPlatformSID3::tick(bool sysTick)
|
||||||
if(chan[i].independentNoiseFreq)
|
if(chan[i].independentNoiseFreq)
|
||||||
{
|
{
|
||||||
chan[i].noiseFreq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].noise_fixedArp?chan[i].noise_baseNoteOverride:chan[i].noise_arpOff,chan[i].noise_fixedArp,false,2,chan[i].noise_pitch2,chipClock,CHIP_FREQBASE * 64);
|
chan[i].noiseFreq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].noise_fixedArp?chan[i].noise_baseNoteOverride:chan[i].noise_arpOff,chan[i].noise_fixedArp,false,2,chan[i].noise_pitch2,chipClock,CHIP_FREQBASE * 64);
|
||||||
|
|
||||||
if (chan[i].noiseFreq<0) chan[i].noiseFreq=0;
|
|
||||||
if (chan[i].noiseFreq>0xffffff) chan[i].noiseFreq=0xffffff;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
chan[i].noiseFreq = chan[i].freq;
|
chan[i].noiseFreq = chan[i].freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
int index = 0;
|
||||||
|
while(noiseInterestingWavesData != 0 && !found)
|
||||||
|
{
|
||||||
|
if(noiseInterestingWavesData[index].LFSRmask == chan[i].noiseLFSRMask)
|
||||||
|
{
|
||||||
|
chan[i].noiseFreq *= noiseInterestingWavesData[index].freqScaling;
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chan[i].noiseFreq<0) chan[i].noiseFreq=0;
|
||||||
|
if (chan[i].noiseFreq>0xffffff) chan[i].noiseFreq=0xffffff;
|
||||||
|
|
||||||
updateNoiseFreq(i);
|
updateNoiseFreq(i);
|
||||||
|
|
||||||
chan[i].noiseFreqChanged = false;
|
chan[i].noiseFreqChanged = false;
|
||||||
|
@ -1052,6 +1078,7 @@ int DivPlatformSID3::dispatch(DivCommand c) {
|
||||||
chan[c.chan].noiseLFSRMask &= ~(0xffU << (8 * c.value2));
|
chan[c.chan].noiseLFSRMask &= ~(0xffU << (8 * c.value2));
|
||||||
chan[c.chan].noiseLFSRMask |= ((c.value & (c.value2 == 3 ? 0x3f : 0xff)) << (8 * c.value2));
|
chan[c.chan].noiseLFSRMask |= ((c.value & (c.value2 == 3 ? 0x3f : 0xff)) << (8 * c.value2));
|
||||||
updateNoiseLFSRMask(c.chan);
|
updateNoiseLFSRMask(c.chan);
|
||||||
|
chan[c.chan].noiseFreqChanged = true;
|
||||||
break;
|
break;
|
||||||
case DIV_CMD_SID3_1_BIT_NOISE:
|
case DIV_CMD_SID3_1_BIT_NOISE:
|
||||||
if(c.chan == SID3_NUM_CHANNELS - 1) //wave chan
|
if(c.chan == SID3_NUM_CHANNELS - 1) //wave chan
|
||||||
|
@ -1250,7 +1277,7 @@ void DivPlatformSID3::reset() {
|
||||||
chan[i].freq = chan[i].noiseFreq = 0;
|
chan[i].freq = chan[i].noiseFreq = 0;
|
||||||
updatePanning(i);
|
updatePanning(i);
|
||||||
|
|
||||||
chan[i].noiseLFSRMask = (1 << 29) | (1 << 5) | (1 << 3) | 1; //https://docs.amd.com/v/u/en-US/xapp052 for 30 bits: 30, 6, 4, 1
|
chan[i].noiseLFSRMask = 1 | (1 << 23) | (1 << 25) | (1 << 29); //https://docs.amd.com/v/u/en-US/xapp052 for 30 bits: 30, 6, 4, 1; but inverted since our LFSR is moving in different direction
|
||||||
|
|
||||||
chan[i].pw_slide = 0;
|
chan[i].pw_slide = 0;
|
||||||
|
|
||||||
|
|
|
@ -2254,7 +2254,16 @@ void sid3_clock_lfsr(sid3_channel* ch)
|
||||||
|
|
||||||
uint16_t sid3_noise(uint32_t lfsr, bool one_bit)
|
uint16_t sid3_noise(uint32_t lfsr, bool one_bit)
|
||||||
{
|
{
|
||||||
return one_bit ? ((lfsr & 1) ? 0xffff : 0) : (lfsr & 0xffff);
|
return one_bit ? ((lfsr & 1) ? 0xffff : 0) :
|
||||||
|
|
||||||
|
((((lfsr & 1) << 7) |
|
||||||
|
((lfsr & 4) << 4) |
|
||||||
|
((lfsr & 0x40) >> 1) |
|
||||||
|
((lfsr & 0x200) >> 5) |
|
||||||
|
((lfsr & 0x800) >> 8) |
|
||||||
|
((lfsr & 0x8000) >> 13) |
|
||||||
|
((lfsr & 0x40000) >> 17) |
|
||||||
|
((lfsr & 0x100000) >> 20)) << 8); //bits like in SID
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t sid3_special_wave(SID3* sid3, uint32_t acc, uint8_t wave)
|
uint16_t sid3_special_wave(SID3* sid3, uint32_t acc, uint8_t wave)
|
||||||
|
@ -2353,8 +2362,8 @@ void sid3_reset(SID3* sid3)
|
||||||
{
|
{
|
||||||
memset(&sid3->chan[i], 0, sizeof(sid3_channel));
|
memset(&sid3->chan[i], 0, sizeof(sid3_channel));
|
||||||
sid3->chan[i].adsr.hold_zero = true;
|
sid3->chan[i].adsr.hold_zero = true;
|
||||||
sid3->chan[i].lfsr = 0x1;
|
sid3->chan[i].lfsr = 0x0ffffff; //three MSBs are left as 0
|
||||||
sid3->chan[i].lfsr_taps = (1 << 29) | (1 << 5) | (1 << 3) | 1; //https://docs.amd.com/v/u/en-US/xapp052 for 30 bits: 30, 6, 4, 1
|
sid3->chan[i].lfsr_taps = 1 | (1 << 23) | (1 << 25) | (1 << 29); //https://docs.amd.com/v/u/en-US/xapp052 for 30 bits: 30, 6, 4, 1; but inverted since our LFSR is moving in different direction
|
||||||
|
|
||||||
for(int j = 0; j < SID3_NUM_FILTERS; j++)
|
for(int j = 0; j < SID3_NUM_FILTERS; j++)
|
||||||
{
|
{
|
||||||
|
@ -3044,7 +3053,7 @@ void sid3_clock(SID3* sid3)
|
||||||
{
|
{
|
||||||
ch->accumulator = 0;
|
ch->accumulator = 0;
|
||||||
ch->noise_accumulator = 0;
|
ch->noise_accumulator = 0;
|
||||||
ch->lfsr = 0x1;
|
ch->lfsr = 0x0fffffff; //three MSBs are left as 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3053,7 +3062,7 @@ void sid3_clock(SID3* sid3)
|
||||||
{
|
{
|
||||||
ch->accumulator = 0;
|
ch->accumulator = 0;
|
||||||
ch->noise_accumulator = 0;
|
ch->noise_accumulator = 0;
|
||||||
ch->lfsr = 0x1;
|
ch->lfsr = 0x0fffffff; //three MSBs are left as 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3315,7 +3324,7 @@ void sid3_write(SID3* sid3, uint16_t address, uint8_t data)
|
||||||
if(sid3->chan[channel].flags & SID3_CHAN_NOISE_PHASE_RESET)
|
if(sid3->chan[channel].flags & SID3_CHAN_NOISE_PHASE_RESET)
|
||||||
{
|
{
|
||||||
sid3->chan[channel].noise_accumulator = 0;
|
sid3->chan[channel].noise_accumulator = 0;
|
||||||
sid3->chan[channel].lfsr = 0x1;
|
sid3->chan[channel].lfsr = 0x0fffffff; //three MSBs are left as 0
|
||||||
}
|
}
|
||||||
|
|
||||||
sid3->chan[channel].flags &= ~(SID3_CHAN_ENV_RESET | SID3_CHAN_NOISE_PHASE_RESET | SID3_CHAN_PHASE_RESET);
|
sid3->chan[channel].flags &= ~(SID3_CHAN_ENV_RESET | SID3_CHAN_NOISE_PHASE_RESET | SID3_CHAN_PHASE_RESET);
|
||||||
|
|
|
@ -743,16 +743,16 @@ String macroHoverES5506FilterMode(int id, float val, void* u) {
|
||||||
String mode="???";
|
String mode="???";
|
||||||
switch (((int)val)&3) {
|
switch (((int)val)&3) {
|
||||||
case 0:
|
case 0:
|
||||||
mode="HP/K2, HP/K2";
|
mode=_("HP/K2, HP/K2");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
mode="HP/K2, LP/K1";
|
mode=_("HP/K2, LP/K1");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
mode="LP/K2, LP/K2";
|
mode=_("LP/K2, LP/K2");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
mode="LP/K2, LP/K1";
|
mode=_("LP/K2, LP/K1");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -797,10 +797,18 @@ String macroSID3SourceChan(int id, float val, void* u)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return fmt::sprintf("Channel %d", (int)val + 1);
|
return fmt::sprintf(_("Channel %d"), (int)val + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String macroSID3NoiseLFSR(int id, float val, void* u)
|
||||||
|
{
|
||||||
|
return _("SID2 noise modes:\n\n"
|
||||||
|
"Mode 2: \n"
|
||||||
|
"Mode 3: \n"
|
||||||
|
"Mode 4: ");
|
||||||
|
}
|
||||||
|
|
||||||
String macroSID2WaveMixMode(int id, float val, void* u)
|
String macroSID2WaveMixMode(int id, float val, void* u)
|
||||||
{
|
{
|
||||||
if((int)val > 3) return "???";
|
if((int)val > 3) return "???";
|
||||||
|
@ -2224,7 +2232,7 @@ void FurnaceGUI::drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float avail
|
||||||
ImGui::SetNextItemWidth(availableWidth);
|
ImGui::SetNextItemWidth(availableWidth);
|
||||||
String& mmlStr=mmlString[index];
|
String& mmlStr=mmlString[index];
|
||||||
if (ImGui::InputText("##IMacroMML",&mmlStr)) {
|
if (ImGui::InputText("##IMacroMML",&mmlStr)) {
|
||||||
decodeMMLStr(mmlStr,i.macro->val,i.macro->len,i.macro->loop,i.min,(i.isBitfield)?((1<<(i.isBitfield?i.max:0))-1):i.max,i.macro->rel,i.bit30);
|
decodeMMLStr(mmlStr,i.macro->val,i.macro->len,i.macro->loop,i.min,(i.isBitfield)?((1<<(i.isBitfield?(i.max):0))-1):i.max,i.macro->rel,i.bit30);
|
||||||
}
|
}
|
||||||
if (!ImGui::IsItemActive()) {
|
if (!ImGui::IsItemActive()) {
|
||||||
encodeMMLStr(mmlStr,i.macro->val,i.macro->len,i.macro->loop,i.macro->rel,false,i.bit30);
|
encodeMMLStr(mmlStr,i.macro->val,i.macro->len,i.macro->loop,i.macro->rel,false,i.bit30);
|
||||||
|
@ -6393,7 +6401,7 @@ void FurnaceGUI::drawInsSID3(DivInstrument* ins)
|
||||||
|
|
||||||
if(!ins->sid3.doWavetable)
|
if(!ins->sid3.doWavetable)
|
||||||
{
|
{
|
||||||
macroList.push_back(FurnaceGUIMacroDesc(_("Noise LFSR bits"),&ins->std.ex7Macro,0,29,16 * 30,uiColors[GUI_COLOR_MACRO_NOISE],false,NULL,NULL,true));
|
macroList.push_back(FurnaceGUIMacroDesc(_("Noise LFSR bits"),&ins->std.ex7Macro,0,30,16 * 30,uiColors[GUI_COLOR_MACRO_NOISE],false,NULL,macroSID3NoiseLFSR,true));
|
||||||
macroList.push_back(FurnaceGUIMacroDesc(_("1-Bit Noise"),&ins->std.opMacros[1].arMacro,0,1,32,uiColors[GUI_COLOR_MACRO_NOISE],false,NULL,NULL,true));
|
macroList.push_back(FurnaceGUIMacroDesc(_("1-Bit Noise"),&ins->std.opMacros[1].arMacro,0,1,32,uiColors[GUI_COLOR_MACRO_NOISE],false,NULL,NULL,true));
|
||||||
macroList.push_back(FurnaceGUIMacroDesc(_("Wave Mix"),&ins->std.ex8Macro,0,4,64,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,macroSID3WaveMixMode));
|
macroList.push_back(FurnaceGUIMacroDesc(_("Wave Mix"),&ins->std.ex8Macro,0,4,64,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,macroSID3WaveMixMode));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue