From efac5f62dde9508d71b5dc86818b0647f06db882 Mon Sep 17 00:00:00 2001 From: Marc Sabat Date: Thu, 18 Apr 2024 15:34:20 +0200 Subject: [PATCH] Make multichannel-to-equave settings and color mapping dependent on mode PR #657 --- src/App.vue | 8 ++- src/components/MidiPiano.vue | 3 +- src/views/MidiView.vue | 116 +++++++++++++++++++---------------- 3 files changed, 70 insertions(+), 57 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1d49371a..e408f6a0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -72,8 +72,10 @@ function sendNoteOn(frequency: number, rawAttack: number) { } function midiNoteOn(index: number, rawAttack?: number, channel?: number) { + const multichannel = midi.multichannelToEquave + // in multichannel-to-equave mode calculate an offset based on the incoming channel - if (midi.multichannelToEquave && channel !== undefined) { + if (multichannel && channel !== undefined) { let offset = mmod( channel - midi.multichannelCenter + midi.multichannelEquavesDown, @@ -99,7 +101,7 @@ function midiNoteOn(index: number, rawAttack?: number, channel?: number) { const whiteMode = midi.whiteMode const indices = scale.whiteIndices - if (whiteMode === 'off') { + if (whiteMode === 'off' || multichannel) { tuningTableKeyOn(index) } else if (whiteMode === 'simple') { if (info.whiteNumber === undefined) { @@ -156,7 +158,7 @@ function midiNoteOn(index: number, rawAttack?: number, channel?: number) { if (!midi.velocityOn) { rawRelease = 80 } - if (whiteMode === 'simple') { + if (whiteMode === 'simple' || multichannel) { if (info.whiteNumber !== undefined) { tuningTableKeyOff(info.whiteNumber) } diff --git a/src/components/MidiPiano.vue b/src/components/MidiPiano.vue index 37f4f99c..ce69d352 100644 --- a/src/components/MidiPiano.vue +++ b/src/components/MidiPiano.vue @@ -7,6 +7,7 @@ const props = defineProps<{ baseMidiNote: number whiteModeOffset: number midiWhiteMode: 'off' | 'simple' | 'blackAverage' | 'keyColors' + multichannel: boolean keyColors: string[] activeKeys: Set }>() @@ -30,7 +31,7 @@ const whiteIndices = computed(() => computeWhiteIndices(props.baseMidiNote, prop function keyLabel(chromaticNumber: number) { const info = midiKeyInfo(chromaticNumber) - if (props.midiWhiteMode === 'off') { + if (props.midiWhiteMode === 'off' || props.multichannel) { return [(chromaticNumber - props.baseMidiNote).toString()] } else if (props.midiWhiteMode === 'simple') { if (info.whiteNumber !== undefined) { diff --git a/src/views/MidiView.vue b/src/views/MidiView.vue index c1f72127..ae497a72 100644 --- a/src/views/MidiView.vue +++ b/src/views/MidiView.vue @@ -186,67 +186,77 @@ onUnmounted(() => { - -
-
- Center channel - -
-
- Total equaves - + +