changeset 222:990b0fc68653

Add highlight layer
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 27 Apr 2017 16:41:04 +0100
parents f3ff5ee994a1
children 6d128e43f4d5
files src/app/waveform/waveform.component.ts
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/waveform/waveform.component.ts	Thu Mar 30 16:46:48 2017 +0100
+++ b/src/app/waveform/waveform.component.ts	Thu Apr 27 16:41:04 2017 +0100
@@ -158,6 +158,7 @@
   private _isOneShotExtractor: boolean;
   private _isSeeking: boolean;
   private cursorLayer: any;
+  private highlightLayer: any;
   private layers: Layer[];
   private featureExtractionSubscription: Subscription;
   private playingStateSubscription: Subscription;
@@ -178,6 +179,7 @@
     this.audioBuffer = undefined;
     this.timeline = undefined;
     this.cursorLayer = undefined;
+    this.highlightLayer = undefined;
     this.isPlaying = false;
     this.isLoading = true;
   }
@@ -582,7 +584,8 @@
         const plotData = [...featureData].map((feature, i) => {
           return {
             cx: i * stepDuration,
-            cy: feature * normalisationFactor
+            cy: feature * normalisationFactor,
+            value: feature
           };
         });
 
@@ -595,6 +598,16 @@
           waveTrack,
           this.timeline.timeContext
         );
+        this.highlightLayer = new wavesUI.helpers.HighlightLayer(lineLayer, {
+          color: colour,
+          opacity: 0.7,
+          height: height
+        });
+        this.addLayer(
+          this.highlightLayer,
+          waveTrack,
+          this.timeline.timeContext
+        );
         break;
       }
       case 'list': {
@@ -748,6 +761,11 @@
         this.cursorLayer.currentPosition = currentTime;
         this.cursorLayer.update();
 
+        if (typeof(this.highlightLayer) !== 'undefined') {
+          this.highlightLayer.currentPosition = currentTime;
+          this.highlightLayer.update();
+        }
+        
         const currentOffset = this.timeline.timeContext.offset;
         const offsetTimestamp = currentOffset
           + currentTime;