# HG changeset patch # User Chris Cannam # Date 1495188523 -3600 # Node ID 802fbba26afec91edfbea3be2bc20769f6b9aa6b # Parent 6ada6ca40baf74e45b2ab8cb0bcb2ba19ca8dff1 Round piano roll y domain to closest octave boundaries diff -r 6ada6ca40baf -r 802fbba26afe src/app/waveform/waveform.component.ts --- 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; }