diff --git a/src/App.vue b/src/App.vue index 3fc61718..bff3ccac 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,6 +11,7 @@ import { NEWLINE_TEST, NUMBER_OF_NOTES, UNIX_NEWLINE, + WHITE_MODE_OFFSET, } from "@/constants"; import { ScaleWorkshopOneData } from "@/scale-workshop-one"; import type { Input, Output } from "webmidi"; @@ -386,9 +387,6 @@ function sendNoteOn(frequency: number, rawAttack: number) { return off; } -// Offset such that default base MIDI note doesn't move -const WHITE_MODE_OFFSET = 69 - 40; - function midiNoteOn(index: number, rawAttack?: number) { if (rawAttack === undefined) { rawAttack = 80; diff --git a/src/components/MidiPiano.vue b/src/components/MidiPiano.vue new file mode 100644 index 00000000..592aaf06 --- /dev/null +++ b/src/components/MidiPiano.vue @@ -0,0 +1,184 @@ + + + + + + + diff --git a/src/constants.ts b/src/constants.ts index 2a0ceb32..5ee4013c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -13,3 +13,6 @@ export const NUMBER_OF_NOTES = 128; // Browser interaction export const LEFT_MOUSE_BTN = 0; + +// Offset such that default base MIDI note doesn't move in "simple" white mode. +export const WHITE_MODE_OFFSET = 69 - 40; diff --git a/src/midi.ts b/src/midi.ts index f57f4f7c..c754d281 100644 --- a/src/midi.ts +++ b/src/midi.ts @@ -18,7 +18,7 @@ export function computeWhiteIndices(baseMidiNote: number, colors: string[]) { info.whiteNumber === undefined ? info.sharpOf + 1 : info.whiteNumber; let colorIndex = 0; const result = []; - while (whiteIndex > 0 && index > -1024) { + while (whiteIndex >= 0 && index > -1024) { if (colors[mmod(colorIndex--, colors.length)] !== "black") { result[whiteIndex--] = index; } diff --git a/src/views/MidiView.vue b/src/views/MidiView.vue index 8f41a609..9fde4a39 100644 --- a/src/views/MidiView.vue +++ b/src/views/MidiView.vue @@ -1,14 +1,23 @@ @@ -205,6 +251,14 @@ onUnmounted(() => { +