diff --git a/packages/core/pianoroll.mjs b/packages/core/pianoroll.mjs index 60b1dc7b..378480ba 100644 --- a/packages/core/pianoroll.mjs +++ b/packages/core/pianoroll.mjs @@ -4,11 +4,19 @@ Copyright (C) 2022 Strudel contributors - see . */ -import { Pattern, toMidi, getDrawContext } from './index.mjs'; +import { Pattern, toMidi, getDrawContext, freqToMidi } from './index.mjs'; const scale = (normalized, min, max) => normalized * (max - min) + min; const getValue = (e) => { - let value = typeof e.value === 'object' ? e.value.note ?? e.value.n : e.value; + let { value } = e; + if (typeof e.value !== 'object') { + value = { value }; + } + let { note, n, freq } = value; + if (freq) { + note = freqToMidi(freq); + } + value = note ?? n ?? e.value; if (typeof value === 'string') { value = toMidi(value); }