comparison src/app/waveform/waveform.component.ts @ 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 64dee0c156b1
children f986426870d0 e213fdc33f46
comparison
equal deleted inserted replaced
332:6ada6ca40baf 333:802fbba26afe
796 height, 796 height,
797 colour 797 colour
798 ); 798 );
799 break; 799 break;
800 case 'notes': 800 case 'notes':
801 const notes = mapFeaturesToNotes(featureData, outputDescriptor);
802 let [min, max] = notes.reduce((acc, note) => {
803 const [min, max] = acc;
804 return [Math.min (min, note.pitch), Math.max (max, note.pitch)];
805 }, [Infinity, -Infinity]);
806 if (min === Infinity || min < 0 || max < 0) {
807 min = 0;
808 max = 127;
809 }
810 // round min and max to octave boundaries (starting at C as in MIDI)
811 min = 12 * Math.floor(min / 12);
812 max = 12 * Math.ceil(max / 12);
801 const pianoRollLayer = new wavesUI.helpers.PianoRollLayer( 813 const pianoRollLayer = new wavesUI.helpers.PianoRollLayer(
802 mapFeaturesToNotes(featureData, outputDescriptor), 814 notes,
803 {height: height, color: colour} 815 {height: height, color: colour, yDomain: [min, max] }
804 ); 816 );
805 this.addLayer( 817 this.addLayer(
806 pianoRollLayer, 818 pianoRollLayer,
807 waveTrack, 819 waveTrack,
808 this.timeline.timeContext 820 this.timeline.timeContext
818 case 'matrix': { 830 case 'matrix': {
819 const collected = features.collected as MatrixFeature; 831 const collected = features.collected as MatrixFeature;
820 const startTime = collected.startTime; // !!! + make use of 832 const startTime = collected.startTime; // !!! + make use of
821 const stepDuration = collected.stepDuration; 833 const stepDuration = collected.stepDuration;
822 const matrixData = collected.data; 834 const matrixData = collected.data;
823 835
824 if (matrixData.length === 0) { 836 if (matrixData.length === 0) {
825 return; 837 return;
826 } 838 }
827 839
828 console.log('matrix data length = ' + matrixData.length); 840 console.log('matrix data length = ' + matrixData.length);