Skip to content
Snippets Groups Projects
Commit 4dfa89f0 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Use callback method and vendor prefix offline audio contexts

parent 70587a3f
Branches
Tags
No related merge requests found
......@@ -112,9 +112,9 @@ class SoundEditor extends React.Component {
}
handleEffect (name) {
const effects = new AudioEffects(this.audioBufferPlayer.buffer, name);
effects.process().then(newBuffer => {
const samples = newBuffer.getChannelData(0);
const sampleRate = newBuffer.sampleRate;
effects.process(({renderedBuffer}) => {
const samples = renderedBuffer.getChannelData(0);
const sampleRate = renderedBuffer.sampleRate;
this.submitNewSamples(samples, sampleRate);
this.handlePlay();
});
......
......@@ -38,7 +38,7 @@ class AudioEffects {
buffer.getChannelData(0).reverse();
break;
}
const OfflineAudioContext = window.OfflineAudioContext || window.webkitOfflineAudioContext;
this.audioContext = new OfflineAudioContext(1, sampleCount, buffer.sampleRate);
this.buffer = buffer;
this.source = this.audioContext.createBufferSource();
......@@ -46,7 +46,7 @@ class AudioEffects {
this.source.playbackRate.value = playbackRate;
this.name = name;
}
process () {
process (done) {
// Some effects need to use more nodes and must expose an input and output
let input;
let output;
......@@ -75,7 +75,8 @@ class AudioEffects {
this.source.start();
return this.audioContext.startRendering();
this.audioContext.startRendering();
this.audioContext.oncomplete = done;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment