From 55e879929cc53bd78b864d544ce4d896b325acc2 Mon Sep 17 00:00:00 2001 From: Aoife Date: Tue, 20 Apr 2021 00:54:15 +0200 Subject: [PATCH] Fix parsing individual bits --- src/features/io/convert/parse.js | 37 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/features/io/convert/parse.js b/src/features/io/convert/parse.js index 2877587..e4178c2 100644 --- a/src/features/io/convert/parse.js +++ b/src/features/io/convert/parse.js @@ -40,7 +40,7 @@ function build_patch(patch) { scale_key: getBits(patch[17], 4, 7), scale_type: getBits(patch[17], 0, 3), /* BYTE 18 SKIPPED */ - delay_sync: patch[19] & 0x80, + delay_sync: (patch[19] & (1 << 7)) !== 0, delay_timebase: getBits(patch[19], 0, 3), delay_time: patch[20], delay_depth: patch[21], @@ -53,10 +53,10 @@ function build_patch(patch) { eq_low_freq: patch[28], eq_low_gain: patch[29], arp_tempo: (patch[30] << 8) + patch[31], - arp_on_off: patch[32] & 0x80, - arp_latch: patch[32] & 0x40, + arp_on_off: (patch[32] & (1 << 7)) !== 0, + arp_latch: (patch[32] & (1 << 6)) !== 0, arp_target: getBits(patch[32], 4, 5), - arp_key_sync: patch[32] & 0x01, + arp_key_sync: (patch[32] & (1 << 0)) !== 0, arp_type: getBits(patch[33], 0, 3), arp_range: getBits(patch[33], 4, 7), arp_gate_time: patch[34], @@ -67,12 +67,13 @@ function build_patch(patch) { } function build_timbre(num, timbre) { + console.log(timbre[0]); return { [`t${num}_midi_channel`]: timbre[0], [`t${num}_assign_mode`]: getBits(timbre[1], 6, 7), - [`t${num}_eg_2_reset`]: timbre[1] & 0x20, - [`t${num}_eg_1_reset`]: timbre[1] & 0x10, - [`t${num}_trigger_mode`]: timbre[1] & 0x08, + [`t${num}_eg_2_reset`]: (timbre[1] & (1 << 5)) !== 0, + [`t${num}_eg_1_reset`]: (timbre[1] & (1 << 4)) !== 0, + [`t${num}_trigger_mode`]: (timbre[1] & (1 << 3)) !== 0, [`t${num}_key_priority`]: getBits(timbre[1], 0, 1), [`t${num}_unison_detune`]: timbre[2], [`t${num}_tune`]: timbre[3], @@ -100,8 +101,8 @@ function build_timbre(num, timbre) { [`t${num}_filter_key_track`]: timbre[24], [`t${num}_amp_level`]: timbre[25], [`t${num}_amp_panpot`]: timbre[26], - [`t${num}_amp_switch`]: timbre[27] & 0x40, - [`t${num}_amp_distortion`]: timbre[27] & 0x01, + [`t${num}_amp_switch`]: (timbre[27] & (1 << 6)) !== 0, + [`t${num}_amp_distortion`]: (timbre[27] & (1 << 0)) !== 0, [`t${num}_amp_vel_sense`]: timbre[28], [`t${num}_amp_key_track`]: timbre[29], [`t${num}_eg_1_attack`]: timbre[30], @@ -115,12 +116,12 @@ function build_timbre(num, timbre) { [`t${num}_lfo_1_key_sync`]: getBits(timbre[38], 4, 5), [`t${num}_lfo_1_wave`]: getBits(timbre[38], 0, 1), [`t${num}_lfo_1_frequency`]: timbre[39], - [`t${num}_lfo_1_tempo_sync`]: timbre[40] & 0x80, + [`t${num}_lfo_1_tempo_sync`]: (timbre[40] & (1 << 7)) !== 0, [`t${num}_lfo_1_sync_note`]: getBits(timbre[40], 0, 4), [`t${num}_lfo_2_key_sync`]: getBits(timbre[41], 4, 5), [`t${num}_lfo_2_wave`]: getBits(timbre[41], 0, 1), [`t${num}_lfo_2_frequency`]: timbre[42], - [`t${num}_lfo_2_tempo_sync`]: timbre[43] & 0x80, + [`t${num}_lfo_2_tempo_sync`]: (timbre[43] & (1 << 7)) !== 0, [`t${num}_lfo_2_sync_note`]: getBits(timbre[43], 0, 4), [`t${num}_patch_1_dest`]: getBits(timbre[44], 4, 7), [`t${num}_patch_1_src`]: getBits(timbre[44], 0, 3), @@ -141,9 +142,9 @@ function build_vocoder(vocoder) { return { v_midi_channel: vocoder[0], v_assign_mode: getBits(vocoder[1], 6, 7), - v_eg_2_reset: vocoder[1] & 0x20, - v_eg_1_reset: vocoder[1] & 0x10, - v_trigger_mode: vocoder[1] & 0x08, + v_eg_2_reset: (vocoder[1] & (1 << 5)) !== 0, + v_eg_1_reset: (vocoder[1] & (1 << 4)) !== 0, + v_trigger_mode: (vocoder[1] & (1 << 3)) !== 0, v_key_priority: getBits(vocoder[1], 0, 1), v_unison_detune: vocoder[2], v_tune: vocoder[3], @@ -155,7 +156,7 @@ function build_vocoder(vocoder) { v_osc_ctrl_2: vocoder[9], v_osc_dgws: vocoder[10], /* BYTE 11 SKIPPED */ - v_audio_in_hpf_gate: vocoder[12] & 0x01, + v_audio_in_hpf_gate: (vocoder[12] & (1 << 0)) !== 0, /* BYTE 13 SKIPPED */ v_portamento_time: getBits(vocoder[14], 0, 6), v_osc_level: vocoder[15], @@ -172,7 +173,7 @@ function build_vocoder(vocoder) { v_filter_e_f_sense: vocoder[26], v_amp_level: vocoder[27], v_amp_direct_level: vocoder[28], - v_amp_distortion: vocoder[29] & 0x01, + v_amp_distortion: (vocoder[29] & (1 << 0)) !== 0, v_amp_vel_sense: vocoder[30], v_amp_key_track: vocoder[31], v_eg_1_attack: vocoder[32], @@ -186,12 +187,12 @@ function build_vocoder(vocoder) { v_lfo_1_key_sync: getBits(vocoder[40], 4, 5), v_lfo_1_wave: getBits(vocoder[40], 0, 1), v_lfo_1_frequency: vocoder[41], - v_lfo_1_tempo_sync: vocoder[42] & 0x80, + v_lfo_1_tempo_sync: (vocoder[42] & (1 << 7)) !== 0, v_lfo_1_sync_note: getBits(vocoder[42], 0, 4), v_lfo_2_key_sync: getBits(vocoder[43], 4, 5), v_lfo_2_wave: getBits(vocoder[43], 0, 1), v_lfo_2_frequency: vocoder[44], - v_lfo_2_tempo_sync: vocoder[45] & 0x80, + v_lfo_2_tempo_sync: (vocoder[45] & (1 << 7)) !== 0, v_lfo_2_sync_note: getBits(vocoder[45], 0, 4), v_level_1: vocoder[46], v_level_2: vocoder[47],