# HG changeset patch # User Lucas Thompson # Date 1496669154 -3600 # Node ID 89674c064cda9f914fcea5a18a98df84bfa9faf0 # Parent 7e6b9b557179e0a7c05ea8b87f0d99e72d676d0c Set duration on the LayerTimeContext to the length of the underlying audio file. diff -r 7e6b9b557179 -r 89674c064cda src/app/analysis-item/analysis-item.component.html --- 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()" > @@ -46,6 +47,7 @@ [width]="contentWidth" [onSeek]="onSeek" [curve]="item.collected" + [duration]="getDuration()" >
Feature cannot be visualised.
diff -r 7e6b9b557179 -r 89674c064cda src/app/analysis-item/analysis-item.component.ts --- 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; } diff -r 7e6b9b557179 -r 89674c064cda src/app/visualisations/curve/curve.component.ts --- 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" >`, 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 { diff -r 7e6b9b557179 -r 89674c064cda src/app/visualisations/waves-base.component.ts --- 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);