begin parser refactor

This commit is contained in:
[poww10s]
2020-09-09 21:57:31 -04:00
parent d5c779fd91
commit ae25346f78
3 changed files with 5 additions and 190 deletions
+3
View File
@@ -2,3 +2,6 @@
[0904/152354.511:ERROR:crash_report_database_win.cc(428)] unexpected header
[0907/174603.131:ERROR:crash_report_database_win.cc(428)] unexpected header
[0908/203339.473:ERROR:crash_report_database_win.cc(428)] unexpected header
[0909/143134.669:ERROR:crash_report_database_win.cc(428)] unexpected header
[0909/144239.412:ERROR:crash_report_database_win.cc(428)] unexpected header
[0909/215336.442:ERROR:crash_report_database_win.cc(428)] unexpected header
+1 -190
View File
@@ -6,7 +6,7 @@ import FileIOComponent from "./components/FileIOComponent";
import MidiComponent from "./components/MidiComponent";
//import EditorComponent from "./components/EditorComponent";
import Parser from "binary-parser";
import Parser from "packet";
// converts SYSEX file to the dump format the system uses (and the implementation refers to)
function parse(binary) {
@@ -34,195 +34,6 @@ function parse(binary) {
const trimmedBinary = binary.slice(5, -1);
// every eigth byte is padding, so we remove it
const unpaddedBinary = trimmedBinary.filter((el, idx) => idx % 8);
const paramStart = new Parser()
.uint8("midiChannel")
.bit2("assignMode")
.bit1("eg2Reset")
.bit1("eg1Reset")
.bit1("triggerMode")
.bit2("keyPriority")
.uint8("unisonDetune");
const pitch = new Parser()
.uint8("pitchTune")
.uint8("pitchBendRange")
.uint8("pitchTranspose")
.uint8("pitchVibratoInt");
const osc1 = new Parser()
.uint8("osc1Wave")
.uint8("osc1WaveCtrl1")
.uint8("osc1WaveCtrl2")
.uint8("osc1DWGSWave");
const osc2 = new Parser()
.bit2("ignore") // only timbres 1 and 2
.bit2("osc2ModSelect")
.bit2("ignore")
.bit2("osc2Wave")
.uint8("osc2Semitone")
.uint8("osc2Tune");
const mixer = new Parser()
.uint8("Level1")
.uint8("Level2")
.uint8("noiseLevel");
const filter = new Parser()
.uint8("filterType")
.uint8("filterCutoff")
.uint8("filterResonance")
.uint8("filterEG1Intensity")
.uint8("filterVelocitySense")
.uint8("filterKeyboardTrack");
const amp = new Parser()
.uint8("ampLevel")
.uint8("ampPanpot")
.bit1("ignore")
.bit1("ampSW")
.bit6("ignore")
.bit1("ampDistortion")
.uint8("ampVelocitySense")
.uint8("ampKeyboardTrack");
const env = new Parser()
.uint8("egAttack")
.uint8("egDecay")
.uint8("egSustain")
.uint8("egRelease");
const lfo = new Parser()
.bit2("ignore")
.bit2("lfoKeySync")
.bit2("ignore")
.bit2("lfoWave")
.uint8("lfoFreq")
.bit1("lfoTempoSync")
.bit2("ignore")
.bit5("lfoSyncNote");
const patchMods = new Parser()
.bit4("patch1Dest") // Patch Begin // only timbres and and 2
.bit4("patch1Src")
.uint8("patch1Intensity") // Patch End
.bit4("patch2Dest")
.bit4("patch2Src")
.uint8("patch2Intensity")
.bit4("patch3Dest")
.bit4("patch3Src")
.uint8("patch3Intensity")
.bit4("patch4Dest")
.bit4("patch4Src")
.uint8("patch4Intensity")
.seek(56);
const timbre = new Parser()
.nest({ type: paramStart })
.nest({ type: pitch })
.nest({ type: osc1 })
.seek(1)
.nest({ type: osc2 })
.bit1("ignore")
.bit7("portamentoTime")
.nest({ type: mixer })
.nest({ type: filter })
.nest({ type: amp })
.nest("eg1", { type: env })
.nest("eg2", { type: env })
.nest("lfo1", { type: lfo })
.nest("lfo2", { type: lfo })
.nest({ type: patchMods });
const vocoder = new Parser()
.nest({ type: paramStart })
.nest({ type: pitch })
.nest({ type: osc1 })
.seek(1)
.bit7("ignore")
.bit1("hpfGate")
.seek(1)
.bit1("ignore")
.bit7("portamentoTime")
.nest({ type: mixer })
.uint8("hpfLevel")
.uint8("gateSense")
.uint8("threshold")
.uint8("filterShift")
.uint8("filterCutoff")
.uint8("filterResonance")
.uint8("filterModSource")
.uint8("filterIntensity")
.uint8("filterEFSense")
.uint8("ampLevel")
.uint8("ampDirectLevel")
.bit7("ignore")
.b1("ampDistortion")
.uint8("ampVelocitySense")
.uint8("ampKeyTrack")
.nest("eg1", { type: env })
.nest("eg2", { type: env })
.nest("lfo1", { type: lfo })
.nest("lfo2", { type: lfo })
.array("level", {
type: "uint8",
lengthInBytes: 16,
})
.array("pan", {
type: "uint8",
lengthInBytes: 16,
})
.array("efHoldLevel", {
type: "uint8",
lengthInBytes: 16,
});
//end stuff
const parser = new Parser()
.endianness("big")
.string("name", ["ASCII", 12])
.seek(3)
.bit5("ignore")
.bit3("arpTriggerLength")
.bit8("arpTriggerPattern")
.bit2("ignore")
.bit2("voiceMode")
.bit4("ignore")
.bit4("scaleKey")
.bit4("scaleType")
.seek(1)
.bit1("delayFxSync")
.bit3("ignore")
.bit4("delayFXTimeBase")
.uint8("delayFXDelayTime")
.uint8("delayFXDepth")
.uint8("delayFXType")
.uint8("modFXLFOSpeed")
.uint8("modFXDepth")
.uint8("modFXType")
.uint8("eqHiFreq")
.uint8("eqHiGain")
.uint8("eqLowFreq")
.uint8("eqLowGain")
.uint8be("arpTempo")
.uint8le("arpSeqTempo")
.bit1("arpOnOff")
.bit1("arpLatchOnOff")
.bit2("arpTarget")
.bit1("ignore")
.bit1("arpKeySync")
.bit4("arpRange")
.bit4("arpType")
.uint8("arpGateTime")
.uint8("arpResolution")
.uint8("arpSwing")
.uint8("kbdOctave")
.nest("timbre1", { type: timbre })
.nest("timbre2", { type: timbre })
.nest("vocoder", { type: vocoder });
parser.parse(trimmedBinary); // return a object with this
}
function PatchEditor() {
+1
View File
@@ -0,0 +1 @@
// function that skip bits in a byte OR can get the value of groupings of bits in a byte