# HG changeset patch # User Lucas Thompson # Date 1481022776 0 # Node ID 92c139e16b51c637cfe28efb897c13bb68b5f28e # Parent af0b4b05311cc63c72e5215f207496bb9eec3dc1 Disable button whilst extracting (for now) - quick fix to stop multiple process requests being sent (as they aren't queued / no request-response matching is done / process requests are synchronous) diff -r af0b4b05311c -r 92c139e16b51 src/app/app.component.html --- a/src/app/app.component.html Tue Dec 06 11:03:38 2016 +0000 +++ b/src/app/app.component.html Tue Dec 06 11:12:56 2016 +0000 @@ -24,7 +24,7 @@ + [disabled]="!canExtract"> diff -r af0b4b05311c -r 92c139e16b51 src/app/app.component.ts --- a/src/app/app.component.ts Tue Dec 06 11:03:38 2016 +0000 +++ b/src/app/app.component.ts Tue Dec 06 11:12:56 2016 +0000 @@ -10,15 +10,15 @@ }) export class AppComponent { audioBuffer: AudioBuffer; // TODO consider revising - hasAudioBuffer: boolean; + canExtract: boolean; constructor(private audioService: AudioPlayerService, private piperService: FeatureExtractionService) { - this.hasAudioBuffer = false; + this.canExtract = false; } onFileOpened(file: File) { - this.hasAudioBuffer = false; + this.canExtract = false; const reader: FileReader = new FileReader(); const mimeType = file.type; reader.onload = (event: any) => { @@ -29,14 +29,15 @@ this.audioService.decodeAudioData(event.target.result).then(audioBuffer => { this.audioBuffer = audioBuffer; if (this.audioBuffer) - this.hasAudioBuffer = true; + this.canExtract = true; }); }; reader.readAsArrayBuffer(file); } extractFeatures(outputInfo: ExtractorOutputInfo): void { - if (!this.hasAudioBuffer) return; + if (!this.canExtract) return; + this.canExtract = false; this.piperService.process({ audioData: [...Array(this.audioBuffer.numberOfChannels).keys()] .map(i => this.audioBuffer.getChannelData(i)), @@ -46,6 +47,9 @@ }, key: outputInfo.extractorKey, outputId: outputInfo.outputId - }).then(data => console.log(data)).catch(err => console.error(err)); + }).then(data => { + this.canExtract = true; + console.log(data); + }).catch(err => console.error(err)); } }