changeset 412:89674c064cda

Set duration on the LayerTimeContext to the length of the underlying audio file.
author Lucas Thompson <dev@lucas.im>
date Mon, 05 Jun 2017 14:25:54 +0100
parents 7e6b9b557179
children 24df6a0d61c8
files src/app/analysis-item/analysis-item.component.html src/app/analysis-item/analysis-item.component.ts src/app/visualisations/curve/curve.component.ts src/app/visualisations/waves-base.component.ts
diffstat 4 files changed, 27 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/analysis-item/analysis-item.component.html	Mon Jun 05 10:56:15 2017 +0100
+++ b/src/app/analysis-item/analysis-item.component.html	Mon Jun 05 14:25:54 2017 +0100
@@ -24,6 +24,7 @@
             [audioBuffer]="item.audioData"
             [onSeek]="onSeek"
             [colour]="'#0868ac'"
+            [duration]="getDuration()"
           ></ugly-waveform>
         </ugly-waves-play-head>
 
@@ -46,6 +47,7 @@
               [width]="contentWidth"
               [onSeek]="onSeek"
               [curve]="item.collected"
+              [duration]="getDuration()"
             ></ugly-curve>
           </ugly-cross-hair-inspector>
           <ugly-cross-hair-inspector
@@ -59,6 +61,7 @@
               [width]="contentWidth"
               [onSeek]="onSeek"
               [tracks]="item.collected"
+              [duration]="getDuration()"
             ></ugly-tracks>
           </ugly-cross-hair-inspector>
           <ugly-cross-hair-inspector
@@ -72,6 +75,7 @@
               [width]="contentWidth"
               [onSeek]="onSeek"
               [notes]="item.collected"
+              [duration]="getDuration()"
             ></ugly-notes>
           </ugly-cross-hair-inspector>
           <ugly-instants
@@ -81,6 +85,7 @@
             [width]="contentWidth"
             [onSeek]="onSeek"
             [instants]="item.collected"
+            [duration]="getDuration()"
           ></ugly-instants>
           <ugly-grid
             *ngSwitchCase="'matrix'"
@@ -88,6 +93,7 @@
             [width]="contentWidth"
             [onSeek]="onSeek"
             [grid]="item.collected"
+            [duration]="getDuration()"
           ></ugly-grid>
 
           <div *ngSwitchDefault>Feature cannot be visualised.</div>
--- a/src/app/analysis-item/analysis-item.component.ts	Mon Jun 05 10:56:15 2017 +0100
+++ b/src/app/analysis-item/analysis-item.component.ts	Mon Jun 05 14:25:54 2017 +0100
@@ -146,6 +146,15 @@
     isAnalysisItem(this.item) ? this.item.shape : null;
   }
 
+  getDuration(): number | null {
+    if (isRootAudioItem(this.item)) {
+      return this.item.audioData.duration;
+    }
+    if (isAnalysisItem(this.item)) {
+      return this.item.parent.audioData.duration;
+    }
+  }
+
   getNextColour(): string {
     return defaultColourGenerator.next().value;
   }
--- a/src/app/visualisations/curve/curve.component.ts	Mon Jun 05 10:56:15 2017 +0100
+++ b/src/app/visualisations/curve/curve.component.ts	Mon Jun 05 14:25:54 2017 +0100
@@ -26,6 +26,7 @@
       [onSeek]="onSeek"
       [colour]="colour"
       [tracks]="[curve]"
+      [duration]="duration"
     ></ugly-tracks>`,
   changeDetection: ChangeDetectionStrategy.OnPush,
   providers: [
@@ -41,6 +42,7 @@
   @Input() width: number;
   @Input() curve: VectorFeature;
   @Input() colour: string;
+  @Input() duration: number;
   @ViewChild(TracksComponent) tracksComponent: TracksComponent;
 
   renderInspector(range: [number, number], unit?: string): void {
--- a/src/app/visualisations/waves-base.component.ts	Mon Jun 05 10:56:15 2017 +0100
+++ b/src/app/visualisations/waves-base.component.ts	Mon Jun 05 14:25:54 2017 +0100
@@ -42,6 +42,7 @@
   @Input() timeline: Timeline;
   @Input() onSeek: OnSeekHandler;
   @Input() colour: string;
+  @Input() duration: number;
   @Input() set feature(feature: T) {
     this.mFeature = feature;
     this.update();
@@ -60,7 +61,6 @@
   protected abstract get featureLayers(): Layer[];
   protected cachedFeatureLayers: Layer[];
   protected postAddMap: (value: Layer, index: number, array: Layer[]) => void;
-  protected duration: number;
   height: number;
 
   constructor() {
@@ -155,8 +155,15 @@
            isAxis: boolean = false): LayerRemover {
     const timeContext = this.timeline.timeContext;
     if (!layer.timeContext) {
-      layer.setTimeContext(isAxis ?
-        timeContext : new Waves.core.LayerTimeContext(timeContext));
+      if (isAxis) {
+        layer.setTimeContext(timeContext);
+      } else {
+        const layerTimeContext = new Waves.core.LayerTimeContext(timeContext);
+        if (this.duration) {
+          layerTimeContext.duration = this.duration;
+        }
+        layer.setTimeContext(layerTimeContext);
+      }
     }
     this.waveTrack.add(layer);
     this.layers.push(layer);