add cutoff and pulse width slides for C64, SID2 and SID3
Also add clipping for ADSR, duty and cutoff when in instrument types you go SID3 -> SID2 or SID2 -> C64 or SID3 -> C64
This commit is contained in:
parent
e0df55749a
commit
46f1ae33c7
11 changed files with 162 additions and 18 deletions
|
|
@ -158,6 +158,24 @@ void DivPlatformC64::tick(bool sysTick) {
|
|||
int i=chanOrder[_i];
|
||||
|
||||
chan[i].std.next();
|
||||
|
||||
if(sysTick)
|
||||
{
|
||||
if(chan[i].pw_slide != 0)
|
||||
{
|
||||
chan[i].duty -= chan[i].pw_slide;
|
||||
chan[i].duty = CLAMP(chan[i].duty, 0, 0xfff);
|
||||
rWrite(i*7+2,chan[i].duty&0xff);
|
||||
rWrite(i*7+3,(chan[i].duty>>8) | (chan[i].outVol << 4));
|
||||
}
|
||||
if(cutoff_slide != 0)
|
||||
{
|
||||
filtCut += cutoff_slide;
|
||||
filtCut = CLAMP(filtCut, 0, 0x7ff);
|
||||
updateFilter();
|
||||
}
|
||||
}
|
||||
|
||||
if (chan[i].std.vol.had) {
|
||||
vol=MIN(15,chan[i].std.vol.val);
|
||||
willUpdateFilter=true;
|
||||
|
|
@ -535,6 +553,12 @@ int DivPlatformC64::dispatch(DivCommand c) {
|
|||
chan[c.chan].release=c.value&15;
|
||||
rWrite(c.chan*7+6,(chan[c.chan].sustain<<4)|(chan[c.chan].release));
|
||||
break;
|
||||
case DIV_CMD_C64_PW_SLIDE:
|
||||
chan[c.chan].pw_slide = c.value * c.value2;
|
||||
break;
|
||||
case DIV_CMD_C64_CUTOFF_SLIDE:
|
||||
cutoff_slide = c.value * c.value2;
|
||||
break;
|
||||
case DIV_CMD_MACRO_OFF:
|
||||
chan[c.chan].std.mask(c.value,true);
|
||||
break;
|
||||
|
|
@ -653,8 +677,11 @@ void DivPlatformC64::reset() {
|
|||
chan[i].std.setEngine(parent);
|
||||
fakeLow[i]=0;
|
||||
fakeBand[i]=0;
|
||||
chan[i].pw_slide = 0;
|
||||
}
|
||||
|
||||
cutoff_slide = 0;
|
||||
|
||||
if (sidCore==2) {
|
||||
dSID_init(sid_d,chipClock,rate,sidIs6581?6581:8580,needInitTables);
|
||||
dSID_setMuteMask(
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class DivPlatformC64: public DivDispatch {
|
|||
short duty;
|
||||
bool sweepChanged, filter;
|
||||
bool resetMask, resetFilter, resetDuty, gate, ring, sync, test;
|
||||
short pw_slide;
|
||||
Channel():
|
||||
SharedChannel<signed char>(15),
|
||||
prevFreq(65535),
|
||||
|
|
@ -56,7 +57,8 @@ class DivPlatformC64: public DivDispatch {
|
|||
gate(true),
|
||||
ring(false),
|
||||
sync(false),
|
||||
test(false) {}
|
||||
test(false),
|
||||
pw_slide(0) {}
|
||||
};
|
||||
Channel chan[3];
|
||||
DivDispatchOscBuffer* oscBuf[3];
|
||||
|
|
@ -76,6 +78,7 @@ class DivPlatformC64: public DivDispatch {
|
|||
unsigned char writeOscBuf;
|
||||
unsigned char sidCore;
|
||||
int filtCut, resetTime, initResetTime;
|
||||
short cutoff_slide;
|
||||
|
||||
bool keyPriority, sidIs6581, needInitTables, no1EUpdate, multiplyRel, macroRace;
|
||||
unsigned char chanOrder[3];
|
||||
|
|
|
|||
|
|
@ -113,6 +113,24 @@ void DivPlatformSID2::tick(bool sysTick) {
|
|||
bool willUpdateFilter = false;
|
||||
|
||||
chan[i].std.next();
|
||||
|
||||
if(sysTick)
|
||||
{
|
||||
if(chan[i].pw_slide != 0)
|
||||
{
|
||||
chan[i].duty -= chan[i].pw_slide;
|
||||
chan[i].duty = CLAMP(chan[i].duty, 0, 0xfff);
|
||||
rWrite(i*7+2,chan[i].duty&0xff);
|
||||
rWrite(i*7+3,(chan[i].duty>>8) | (chan[i].outVol << 4));
|
||||
}
|
||||
if(chan[i].cutoff_slide != 0)
|
||||
{
|
||||
chan[i].filtCut += chan[i].cutoff_slide;
|
||||
chan[i].filtCut = CLAMP(chan[i].filtCut, 0, 0xfff);
|
||||
updateFilter(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (chan[i].std.vol.had) {
|
||||
chan[i].outVol=VOL_SCALE_LINEAR(chan[i].vol&15,MIN(15,chan[i].std.vol.val),15);
|
||||
rWrite(i*7+3,(chan[i].duty>>8) | (chan[i].outVol << 4));
|
||||
|
|
@ -521,6 +539,12 @@ int DivPlatformSID2::dispatch(DivCommand c) {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_C64_PW_SLIDE:
|
||||
chan[c.chan].pw_slide = c.value * c.value2;
|
||||
break;
|
||||
case DIV_CMD_C64_CUTOFF_SLIDE:
|
||||
chan[c.chan].cutoff_slide = c.value * c.value2;
|
||||
break;
|
||||
case DIV_CMD_MACRO_OFF:
|
||||
chan[c.chan].std.mask(c.value,true);
|
||||
break;
|
||||
|
|
@ -633,6 +657,9 @@ void DivPlatformSID2::reset() {
|
|||
chan[i].noise_mode = 0;
|
||||
|
||||
rWrite(0x3 + 7 * i,0xf0);
|
||||
|
||||
chan[i].cutoff_slide = 0;
|
||||
chan[i].pw_slide = 0;
|
||||
}
|
||||
|
||||
sid2->reset();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ class DivPlatformSID2: public DivDispatch {
|
|||
unsigned char noise_mode;
|
||||
unsigned char mix_mode;
|
||||
int filtCut;
|
||||
bool do_pw_sweep_writes, do_cutoff_sweep_writes;
|
||||
short cutoff_slide;
|
||||
short pw_slide;
|
||||
Channel():
|
||||
SharedChannel<signed char>(15),
|
||||
prevFreq(0x1ffff),
|
||||
|
|
@ -60,8 +61,8 @@ class DivPlatformSID2: public DivDispatch {
|
|||
noise_mode(0),
|
||||
mix_mode(0),
|
||||
filtCut(0),
|
||||
do_pw_sweep_writes(false),
|
||||
do_cutoff_sweep_writes(false) {}
|
||||
cutoff_slide(0),
|
||||
pw_slide(0) {}
|
||||
};
|
||||
Channel chan[3];
|
||||
DivDispatchOscBuffer* oscBuf[3];
|
||||
|
|
|
|||
|
|
@ -276,6 +276,25 @@ void DivPlatformSID3::tick(bool sysTick)
|
|||
{
|
||||
chan[i].std.next();
|
||||
|
||||
if(sysTick)
|
||||
{
|
||||
if(chan[i].pw_slide != 0)
|
||||
{
|
||||
chan[i].duty -= chan[i].pw_slide;
|
||||
chan[i].duty = CLAMP(chan[i].duty, 0, 0xffff);
|
||||
updateDuty(i);
|
||||
}
|
||||
for(int j = 0; j < SID3_NUM_FILTERS; j++) //filters' slides
|
||||
{
|
||||
if(chan[i].filt[j].cutoff_slide != 0)
|
||||
{
|
||||
chan[i].filt[j].cutoff += chan[i].filt[j].cutoff_slide;
|
||||
chan[i].filt[j].cutoff = CLAMP(chan[i].filt[j].cutoff, 0, 0xffff);
|
||||
updateFilter(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool panChanged = false;
|
||||
bool flagsChanged = false;
|
||||
bool envChanged = false;
|
||||
|
|
@ -644,6 +663,7 @@ int DivPlatformSID3::dispatch(DivCommand c) {
|
|||
|
||||
bool updEnv = false;
|
||||
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_SID3);
|
||||
int filter = 0;
|
||||
|
||||
switch (c.cmd) {
|
||||
case DIV_CMD_NOTE_ON: {
|
||||
|
|
@ -999,6 +1019,13 @@ int DivPlatformSID3::dispatch(DivCommand c) {
|
|||
chan[c.chan].filt[(c.value >> 4) & 3].enabled = c.value & 1;
|
||||
updateFilter(c.chan, (c.value >> 4) & 3);
|
||||
break;
|
||||
case DIV_CMD_C64_PW_SLIDE:
|
||||
chan[c.chan].pw_slide = c.value * c.value2 * 16;
|
||||
break;
|
||||
case DIV_CMD_C64_CUTOFF_SLIDE:
|
||||
filter = abs(c.value2) - 1;
|
||||
chan[c.chan].filt[filter].cutoff_slide = c.value * (c.value2 > 0 ? 1 : -1) * 16;
|
||||
break;
|
||||
case DIV_CMD_SAMPLE_POS:
|
||||
chan[c.chan].dacPos=c.value;
|
||||
break;
|
||||
|
|
@ -1108,6 +1135,8 @@ void DivPlatformSID3::reset() {
|
|||
{
|
||||
chan[i].filt[j].enabled = false;
|
||||
updateFilter(i, j);
|
||||
|
||||
chan[i].filt[j].cutoff_slide = 0;
|
||||
}
|
||||
|
||||
chan[i].panLeft = chan[i].panRight = 0xff;
|
||||
|
|
@ -1116,6 +1145,8 @@ void DivPlatformSID3::reset() {
|
|||
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].pw_slide = 0;
|
||||
}
|
||||
|
||||
sampleTick = 0;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class DivPlatformSID3: public DivDispatch {
|
|||
struct Channel: public SharedChannel<signed short> {
|
||||
int prevFreq;
|
||||
unsigned char wave, special_wave, attack, decay, sustain, sr, release;
|
||||
unsigned short duty;
|
||||
int duty;
|
||||
bool resetMask, resetFilter, resetDuty, gate, ring, sync, phase, oneBitNoise;
|
||||
bool phaseReset, envReset, phaseResetNoise;
|
||||
bool noiseFreqChanged;
|
||||
|
|
@ -44,7 +44,7 @@ class DivPlatformSID3: public DivDispatch {
|
|||
|
||||
struct Filter
|
||||
{
|
||||
unsigned short cutoff;
|
||||
int cutoff;
|
||||
unsigned char resonance;
|
||||
unsigned char output_volume;
|
||||
unsigned char distortion_level;
|
||||
|
|
@ -52,6 +52,8 @@ class DivPlatformSID3: public DivDispatch {
|
|||
bool enabled;
|
||||
unsigned char filter_matrix;
|
||||
|
||||
short cutoff_slide;
|
||||
|
||||
Filter():
|
||||
cutoff(0),
|
||||
resonance(0),
|
||||
|
|
@ -59,7 +61,8 @@ class DivPlatformSID3: public DivDispatch {
|
|||
distortion_level(0),
|
||||
mode(0),
|
||||
enabled(false),
|
||||
filter_matrix(0) {}
|
||||
filter_matrix(0),
|
||||
cutoff_slide(0) {}
|
||||
} filt[SID3_NUM_FILTERS];
|
||||
|
||||
int noise_baseNoteOverride;
|
||||
|
|
@ -79,6 +82,8 @@ class DivPlatformSID3: public DivDispatch {
|
|||
unsigned char phaseInv;
|
||||
unsigned char feedback;
|
||||
|
||||
short pw_slide;
|
||||
|
||||
void handleArpNoise(int offset=0)
|
||||
{
|
||||
DivMacroStruct& m = this->std.op[3].am;
|
||||
|
|
@ -176,7 +181,8 @@ class DivPlatformSID3: public DivDispatch {
|
|||
dacPos(0),
|
||||
dacSample(-1),
|
||||
phaseInv(0),
|
||||
feedback(0) {}
|
||||
feedback(0),
|
||||
pw_slide(0) {}
|
||||
};
|
||||
Channel chan[SID3_NUM_CHANNELS];
|
||||
DivDispatchOscBuffer* oscBuf[SID3_NUM_CHANNELS];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue