diff --git a/packages/tone/draw.mjs b/packages/tone/draw.mjs index c0af49b2..1ef54a6f 100644 --- a/packages/tone/draw.mjs +++ b/packages/tone/draw.mjs @@ -36,8 +36,7 @@ Pattern.prototype.draw = function (callback, { from, to, onQuery }) { const begin = currentCycle + from; const end = currentCycle + to; setTimeout(() => { - events = this._asNumber(true) // true = silent error - .query(new State(new TimeSpan(begin, end))) + events = this.query(new State(new TimeSpan(begin, end))) //._asNumber(true) // true = silent error .filter(Boolean) .filter((event) => event.part.begin.equals(event.whole.begin)); onQuery?.(events); diff --git a/packages/tone/pianoroll.mjs b/packages/tone/pianoroll.mjs index 4035b14e..1fd4ef7e 100644 --- a/packages/tone/pianoroll.mjs +++ b/packages/tone/pianoroll.mjs @@ -7,6 +7,13 @@ This program is free software: you can redistribute it and/or modify it under th import { Pattern } from '@strudel.cycles/core'; const scale = (normalized, min, max) => normalized * (max - min) + min; +const getValue = (e) => { + let value = typeof e.value === 'object' ? e.value.n : e.value; + if (typeof value === 'string') { + value = toMidi(value); + } + return value; +}; Pattern.prototype.pianoroll = function ({ cycles = 4, @@ -75,9 +82,9 @@ Pattern.prototype.pianoroll = function ({ ctx.stroke(); const timePx = scale((event.whole.begin - (flipTime ? to : from)) / timeExtent, ...timeRange); let durationPx = scale(event.duration / timeExtent, 0, timeAxis); - + const value = getValue(event); const valuePx = scale( - fold ? foldValues.indexOf(event.value) / foldValues.length : (Number(event.value) - minMidi) / valueExtent, + fold ? foldValues.indexOf(value) / foldValues.length : (Number(value) - minMidi) / valueExtent, ...valueRange, ); let margin = 0; @@ -105,7 +112,6 @@ Pattern.prototype.pianoroll = function ({ from: from - overscan, to: to + overscan, onQuery: (events) => { - const getValue = (e) => Number(e.value); const { min, max, values } = events.reduce( ({ min, max, values }, e) => { const v = getValue(e);