diff --git a/papers/newIns.md b/papers/newIns.md index c7e76a2a3..9b63bf3c7 100644 --- a/papers/newIns.md +++ b/papers/newIns.md @@ -158,9 +158,10 @@ the following feature codes are recognized: - `EF`: ESFM ins data - `PN`: PowerNoise ins data - `S2`: SID2 ins data +- `S3`: SID3 ins data - `EN`: end of features - if you find this feature code, stop reading the instrument. - - it will usually appear only when there sample/wave lists. + - it will usually appear only when there are sample/wave lists. - instruments in a .fur shall end with this feature code. # instrument name (NA) @@ -324,13 +325,13 @@ size | description | - bit 2: band pass | - bit 1: high pass | - bit 0: low pass - 1 | attack/decay + 1 | attack/decay (ignore the values if reading SID3 instrument) | - bit 4-7: attack | - bit 0-3: decay - 1 | sustain release + 1 | sustain release (ignore the values if reading SID3 instrument) | - bit 4-7: sustain | - bit 0-3: release - 2 | duty + 2 | duty (0-4095 for C64/SID2, 0-65535 for SID3) 2 | cutoff/resonance | - bit 12-15: resonance | - bit 0-10: cutoff (0-11 on SID2) @@ -685,6 +686,71 @@ size | description -----|------------------------------------ 1 | parameters | - bit 6-7: noise mode - | - bit 4-5: wave mix mode + | - bit 4-5: wave mix mode (ignore the value if reading SID3 instrument) | - bit 0-3: volume ``` + +# SID3 data (S3) + +``` +size | description +-----|------------------------------------ + 1 | attack + 1 | decay + 1 | sustain + 1 | sustain rate + 1 | release + 1 | wave mix mode + 1 | parameters + | - bit 7: phase modulation + | - bit 6: enable special wave + | - bit 5: 1-bit noise + | - bit 4: separate noise pitch + | - bit 3: wavetable channel + 1 | phase modulation source channel + 1 | ring modulation source channel + 1 | hard sync source channel + 1 | special wave + 1 | parameters + | - bit 1: left channel signal inversion + | - bit 0: right channel signal inversion + 1 | feedback + 1 | number of filters +``` + +then, `number of filters` times, come settings for each filter: + +``` +size | description +-----|------------------------------------ + 1 | parameters + | - bit 7: enable filter + | - bit 6: initialize filter + | - bit 5: absolute cutoff macro + | - bit 4: enable cutoff scaling + | - bit 3: decrease cutoff when pitch increases (for cutoff scaling) + | - bit 2: scale cutoff only once, on new note + | - bit 1: enable resonance scaling + | - bit 0: decrease resonance when pitch increases (for resonance scaling) + 1 | parameters + | - bit 7: scale resonance only once, on new note + 2 | filter cutoff + 1 | filter resonance + 1 | filter output volume + 1 | filter distortion level + 1 | filter mode: + | - bit 5: connect filter output to channel master output + | - bit 4: connect filter input to channel ADSR output + | - bit 2: band pass + | - bit 1: high pass + | - bit 0: low pass + 1 | matrix connection: + | - bit 3: connect output of filter 4 to input + | - bit 2: connect output of filter 3 to input + | - bit 1: connect output of filter 2 to input + | - bit 0: connect output of filter 1 to input + 1 | cutoff scaling level + 1 | cutoff scaling center note: `0` is `c_5`, `1` is `c+5`, ..., `179` is `B-9` + 1 | resonance scaling level + 1 | resonance scaling center note: `0` is `c_5`, `1` is `c+5`, ..., `179` is `B-9` +``` diff --git a/src/engine/instrument.cpp b/src/engine/instrument.cpp index 737501d68..ff34b77fc 100644 --- a/src/engine/instrument.cpp +++ b/src/engine/instrument.cpp @@ -258,7 +258,6 @@ bool DivInstrumentESFM::Operator::operator==(const DivInstrumentESFM::Operator& bool DivInstrumentSID3::operator==(const DivInstrumentSID3& other) { return ( _C(sr) && - _C(lfsr_taps) && _C(phase_mod) && _C(phase_mod_source) && _C(ring_mod_source) && @@ -904,6 +903,8 @@ void DivInstrument::writeFeatureS3(SafeWriter* w) { w->writeC(sid3.sr); w->writeC(c64.r); + w->writeC(sid2.mixMode); + w->writeC( (sid3.phase_mod?0x80:0)| (sid3.specialWaveOn?0x40:0)| @@ -912,7 +913,6 @@ void DivInstrument::writeFeatureS3(SafeWriter* w) { (sid3.doWavetable?8:0) ); - w->writeI(sid3.lfsr_taps); w->writeC(sid3.phase_mod_source); w->writeC(sid3.ring_mod_source); w->writeC(sid3.sync_source); @@ -2320,7 +2320,12 @@ void DivInstrument::readFeatureS2(SafeReader& reader, short version) { unsigned char next=reader.readC(); sid2.volume=next&0xf; - sid2.mixMode=(next>>4)&3; + + if(type != DIV_INS_SID3) + { + sid2.mixMode=(next>>4)&3; + } + sid2.noiseMode=next>>6; READ_FEAT_END; @@ -2335,6 +2340,8 @@ void DivInstrument::readFeatureS3(SafeReader& reader, short version) { sid3.sr=reader.readC(); c64.r=reader.readC(); + sid2.mixMode=reader.readC(); + unsigned char next = reader.readC(); sid3.phase_mod = next&0x80; @@ -2343,7 +2350,6 @@ void DivInstrument::readFeatureS3(SafeReader& reader, short version) { sid3.separateNoisePitch = next&0x10; sid3.doWavetable = next&8; - sid3.lfsr_taps = reader.readI(); sid3.phase_mod_source = reader.readC(); sid3.ring_mod_source = reader.readC(); sid3.sync_source = reader.readC(); diff --git a/src/engine/instrument.h b/src/engine/instrument.h index 7821c1fab..c295b4d2e 100644 --- a/src/engine/instrument.h +++ b/src/engine/instrument.h @@ -865,7 +865,6 @@ struct DivInstrumentSID2 { struct DivInstrumentSID3 { unsigned char sr; - unsigned int lfsr_taps; bool phase_mod; unsigned char phase_mod_source, ring_mod_source, sync_source; bool specialWaveOn; @@ -935,7 +934,6 @@ struct DivInstrumentSID3 } DivInstrumentSID3(): sr(0), - lfsr_taps(0), phase_mod(false), phase_mod_source(0), ring_mod_source(0),