Mercurial > hg > ugly-duckling
comparison src/app/waveform/waveform.component.ts @ 254:ff71da632fbb
Add highlight layer
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Thu, 27 Apr 2017 16:41:04 +0100 |
parents | 53ea6406d601 |
children | 6d128e43f4d5 |
comparison
equal
deleted
inserted
replaced
253:b65ab8b72cfa | 254:ff71da632fbb |
---|---|
166 private _audioBuffer: AudioBuffer; | 166 private _audioBuffer: AudioBuffer; |
167 private _isSubscribedToAudioService: boolean; | 167 private _isSubscribedToAudioService: boolean; |
168 private _isOneShotExtractor: boolean; | 168 private _isOneShotExtractor: boolean; |
169 private _isSeeking: boolean; | 169 private _isSeeking: boolean; |
170 private cursorLayer: any; | 170 private cursorLayer: any; |
171 private highlightLayer: any; | |
171 private layers: Layer[]; | 172 private layers: Layer[]; |
172 private featureExtractionSubscription: Subscription; | 173 private featureExtractionSubscription: Subscription; |
173 private playingStateSubscription: Subscription; | 174 private playingStateSubscription: Subscription; |
174 private seekedSubscription: Subscription; | 175 private seekedSubscription: Subscription; |
175 private onAudioDataSubscription: Subscription; | 176 private onAudioDataSubscription: Subscription; |
200 this.isSeeking = true; | 201 this.isSeeking = true; |
201 this.layers = []; | 202 this.layers = []; |
202 this.audioBuffer = undefined; | 203 this.audioBuffer = undefined; |
203 this.timeline = undefined; | 204 this.timeline = undefined; |
204 this.cursorLayer = undefined; | 205 this.cursorLayer = undefined; |
206 this.highlightLayer = undefined; | |
205 this.isPlaying = false; | 207 this.isPlaying = false; |
206 this.isLoading = true; | 208 this.isLoading = true; |
207 } | 209 } |
208 | 210 |
209 ngOnInit() { | 211 ngOnInit() { |
627 ); | 629 ); |
628 | 630 |
629 const plotData = [...featureData].map((feature, i) => { | 631 const plotData = [...featureData].map((feature, i) => { |
630 return { | 632 return { |
631 cx: i * stepDuration, | 633 cx: i * stepDuration, |
632 cy: feature * normalisationFactor | 634 cy: feature * normalisationFactor, |
635 value: feature | |
633 }; | 636 }; |
634 }); | 637 }); |
635 | 638 |
636 const lineLayer = new wavesUI.helpers.LineLayer(plotData, { | 639 const lineLayer = new wavesUI.helpers.LineLayer(plotData, { |
637 color: colour, | 640 color: colour, |
638 height: height | 641 height: height |
639 }); | 642 }); |
640 this.addLayer( | 643 this.addLayer( |
641 lineLayer, | 644 lineLayer, |
645 waveTrack, | |
646 this.timeline.timeContext | |
647 ); | |
648 this.highlightLayer = new wavesUI.helpers.HighlightLayer(lineLayer, { | |
649 color: colour, | |
650 opacity: 0.7, | |
651 height: height | |
652 }); | |
653 this.addLayer( | |
654 this.highlightLayer, | |
642 waveTrack, | 655 waveTrack, |
643 this.timeline.timeContext | 656 this.timeline.timeContext |
644 ); | 657 ); |
645 break; | 658 break; |
646 } | 659 } |
799 const updateSeekingCursor = () => { | 812 const updateSeekingCursor = () => { |
800 const currentTime = this.audioService.getCurrentTime(); | 813 const currentTime = this.audioService.getCurrentTime(); |
801 this.cursorLayer.currentPosition = currentTime; | 814 this.cursorLayer.currentPosition = currentTime; |
802 this.cursorLayer.update(); | 815 this.cursorLayer.update(); |
803 | 816 |
817 if (typeof(this.highlightLayer) !== 'undefined') { | |
818 this.highlightLayer.currentPosition = currentTime; | |
819 this.highlightLayer.update(); | |
820 } | |
821 | |
804 const currentOffset = this.timeline.timeContext.offset; | 822 const currentOffset = this.timeline.timeContext.offset; |
805 const offsetTimestamp = currentOffset | 823 const offsetTimestamp = currentOffset |
806 + currentTime; | 824 + currentTime; |
807 | 825 |
808 const visibleDuration = this.timeline.timeContext.visibleDuration; | 826 const visibleDuration = this.timeline.timeContext.visibleDuration; |