Merge branch 'parser-test' into master

This commit is contained in:
[poww10s]
2020-09-11 02:07:18 -04:00
2 changed files with 127 additions and 1 deletions
+1
View File
@@ -21,3 +21,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
debug.log
+126 -1
View File
@@ -6,7 +6,7 @@ import FileIOComponent from "./components/FileIOComponent";
import MidiComponent from "./components/MidiComponent";
//import EditorComponent from "./components/EditorComponent";
import Parser from "packet";
import { Parser } from "binary-parser";
// converts SYSEX file to the dump format the system uses (and the implementation refers to)
function parse(binary) {
@@ -34,6 +34,131 @@ 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 timbre = new Parser()
.uint8("midiChannel") // in 7 bits
.bit2("assignMode")
.bit1("eg2Reset")
.bit1("eg1Reset")
.bit1("triggerMode")
.bit2("keyPriority")
.uint8("unisonDetune")
.uint8("pitchTune")
.uint8("pitchBendRange")
.uint8("pitchTranspose")
.uint8("pitchVibratoInt")
.uint8("osc1Wave")
.uint8("osc1WaveCtrl1")
.uint8("osc1WaveCtrl2")
.uint8("osc1DWGSWave")
.seek(1)
.bit2("ignore1")
.bit2("osc2ModSelect")
.bit2("ignore2")
.bit2("osc2Wave")
.uint8("osc2Semitone")
.uint8("osc2Tune")
.bit1("ignore3")
.bit7("portamentoTime")
.uint8("osc1Level")
.uint8("osc2Level")
.uint8("noiseLevel")
.uint8("filterType")
.uint8("filterCutoff")
.uint8("filterResonance")
.uint8("filterEG1Intensity")
.uint8("filterVelocitySense")
.uint8("filterKeyboardTrack")
.uint8("ampLevel")
.uint8("ampPanpot")
.bit1("ignore4")
.bit1("ampSW")
.bit5("ignore5")
.bit1("ampDistortion")
.uint8("ampVelocitySense")
.uint8("ampKeyboardTrack")
.uint8("eg1Attack")
.uint8("eg1Decay")
.uint8("eg1Sustain")
.uint8("eg1Release")
.uint8("eg2Attack")
.uint8("eg2Decay")
.uint8("eg2Sustain")
.uint8("eg2Release")
.bit2("ignore6")
.bit2("lfo1KeySync")
.bit2("ignore7")
.bit2("lfo1Wave")
.uint8("lfo1Freq")
.bit1("lfo1TempoSync")
.bit2("ignore8")
.bit5("lfo1SyncNote")
.bit2("ignore9")
.bit2("lfo2KeySync")
.bit2("ignore10")
.bit2("lfo2Wave")
.uint8("lfo2Freq")
.bit1("lfo2TempoSync")
.bit2("ignore11")
.bit5("lfo2SyncNote")
.bit4("patch1Dest")
.bit4("patch1Src")
.uint8("patch1Intensity")
.bit4("patch2Dest")
.bit4("patch2Src")
.uint8("patch2Intensity")
.bit4("patch3Dest")
.bit4("patch3Src")
.uint8("patch3Intensity")
.bit4("patch4Dest")
.bit4("patch4Src")
.uint8("patch4Intensity");
const parser = new Parser()
.endianess("big")
.string("name", { encoding: "ASCII", length: 12 })
.seek(2)
.bit5("ignore12")
.bit3("arpTriggerLength")
.bit8("arpTriggerPattern")
.bit2("ignore13")
.bit2("voiceMode")
.bit4("ignore14")
.bit4("scaleKey")
.bit4("scaleType")
.seek(1)
.bit1("delayFxSync")
.bit3("ignore15")
.bit4("delayFXTimeBase")
.uint8("delayFXDelayTime")
.uint8("delayFXDepth")
.uint8("delayFXType")
.uint8("modFXLFOSpeed")
.uint8("modFXDepth")
.uint8("modFXType")
.uint8("eqHiFreq")
.uint8("eqHiGain")
.uint8("eqLowFreq")
.uint8("eqLowGain")
.uint8("arpTempo")
.uint8("arpSeqTempo")
.bit1("arpOnOff")
.bit1("arpLatchOnOff")
.bit2("arpTarget")
.bit1("ignore16")
.bit1("arpKeySync")
.bit4("arpRange")
.bit4("arpType")
.uint8("arpGateTime")
.uint8("arpResolution")
.uint8("arpSwing")
.uint8("kbdOctave")
.nest("timbre1", { type: timbre })
.seek(56)
.nest("timbre2", { type: timbre })
.seek(56);
console.log(parser.parse(unpaddedBinary));
}
function PatchEditor() {