Mercurial > hg > ugly-duckling
changeset 333:802fbba26afe
Round piano roll y domain to closest octave boundaries
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Fri, 19 May 2017 11:08:43 +0100 |
parents | 6ada6ca40baf |
children | f986426870d0 e213fdc33f46 2b374217d8a0 |
files | src/app/waveform/waveform.component.ts |
diffstat | 1 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts Wed May 17 16:38:30 2017 +0100 +++ b/src/app/waveform/waveform.component.ts Fri May 19 11:08:43 2017 +0100 @@ -798,9 +798,21 @@ ); break; case 'notes': + const notes = mapFeaturesToNotes(featureData, outputDescriptor); + let [min, max] = notes.reduce((acc, note) => { + const [min, max] = acc; + return [Math.min (min, note.pitch), Math.max (max, note.pitch)]; + }, [Infinity, -Infinity]); + if (min === Infinity || min < 0 || max < 0) { + min = 0; + max = 127; + } + // round min and max to octave boundaries (starting at C as in MIDI) + min = 12 * Math.floor(min / 12); + max = 12 * Math.ceil(max / 12); const pianoRollLayer = new wavesUI.helpers.PianoRollLayer( - mapFeaturesToNotes(featureData, outputDescriptor), - {height: height, color: colour} + notes, + {height: height, color: colour, yDomain: [min, max] } ); this.addLayer( pianoRollLayer, @@ -820,7 +832,7 @@ const startTime = collected.startTime; // !!! + make use of const stepDuration = collected.stepDuration; const matrixData = collected.data; - + if (matrixData.length === 0) { return; }