comparison src/app/waveform/waveform.component.ts @ 296:cda9307d9eb7

Start updating code to piper-js api with updated FeatureCollection
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 10 May 2017 13:41:18 +0100
parents 71f9286da66f
children bc67503ea8c6 fff3a4fba992
comparison
equal deleted inserted replaced
295:f16705a58887 296:cda9307d9eb7
18 FeatureExtractionService 18 FeatureExtractionService
19 } from '../services/feature-extraction/feature-extraction.service'; 19 } from '../services/feature-extraction/feature-extraction.service';
20 import {Subscription} from 'rxjs/Subscription'; 20 import {Subscription} from 'rxjs/Subscription';
21 import { 21 import {
22 FeatureCollection, 22 FeatureCollection,
23 FixedSpacedFeatures, 23 SimpleResponse,
24 SimpleResponse 24 VectorFeatures,
25 MatrixFeatures,
26 TrackFeature,
27 TrackFeatures
25 } from 'piper/HigherLevelUtilities'; 28 } from 'piper/HigherLevelUtilities';
26 import {toSeconds} from 'piper'; 29 import {toSeconds} from 'piper';
27 import {FeatureList, Feature} from 'piper/Feature'; 30 import {FeatureList, Feature} from 'piper/Feature';
28 import * as Hammer from 'hammerjs'; 31 import * as Hammer from 'hammerjs';
29 import {WavesSpectrogramLayer} from '../spectrogram/Spectrogram'; 32 import {WavesSpectrogramLayer} from '../spectrogram/Spectrogram';
628 const height = this.trackDiv.nativeElement.getBoundingClientRect().height; 631 const height = this.trackDiv.nativeElement.getBoundingClientRect().height;
629 const waveTrack = this.timeline.getTrackById(`wave-${this.trackIdPrefix}`); 632 const waveTrack = this.timeline.getTrackById(`wave-${this.trackIdPrefix}`);
630 633
631 // TODO refactor all of this 634 // TODO refactor all of this
632 switch (features.shape) { 635 switch (features.shape) {
633 case 'vector': { 636 case 'vector': {
634 const stepDuration = (features as FixedSpacedFeatures).stepDuration; 637 const collected = features.collected as VectorFeatures;
635 const featureData = (features.data as Float32Array); 638 const stepDuration = collected.stepDuration;
639 const featureData = collected.data;
636 if (featureData.length === 0) { 640 if (featureData.length === 0) {
637 return; 641 return;
638 } 642 }
639 const plotData = [...featureData].map((feature, i) => { 643 const plotData = [...featureData].map((feature, i) => {
640 return { 644 return {
688 this.timeline.timeContext 692 this.timeline.timeContext
689 ); 693 );
690 break; 694 break;
691 } 695 }
692 case 'list': { 696 case 'list': {
693 const featureData = (features.data as FeatureList); 697 const featureData = features.collected as FeatureList;
694 if (featureData.length === 0) { 698 if (featureData.length === 0) {
695 return; 699 return;
696 } 700 }
697 // TODO look at output descriptor instead of directly inspecting features 701 // TODO look at output descriptor instead of directly inspecting features
698 const hasDuration = outputDescriptor.configured.hasDuration; 702 const hasDuration = outputDescriptor.configured.hasDuration;
790 ); 794 );
791 } 795 }
792 break; 796 break;
793 } 797 }
794 case 'matrix': { 798 case 'matrix': {
795 const stepDuration = (features as FixedSpacedFeatures).stepDuration; 799 const collected = features.collected as MatrixFeatures;
800 const stepDuration = collected.stepDuration;
796 // !!! + start time 801 // !!! + start time
797 const matrixData = (features.data as Float32Array[]); 802 const matrixData = collected.data;
798 803
799 if (matrixData.length === 0) { 804 if (matrixData.length === 0) {
800 return; 805 return;
801 } 806 }
802 807