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
No related branches found
No related tags found
No related merge requests found
...@@ -112,9 +112,9 @@ class SoundEditor extends React.Component { ...@@ -112,9 +112,9 @@ class SoundEditor extends React.Component {
} }
handleEffect (name) { handleEffect (name) {
const effects = new AudioEffects(this.audioBufferPlayer.buffer, name); const effects = new AudioEffects(this.audioBufferPlayer.buffer, name);
effects.process().then(newBuffer => { effects.process(({renderedBuffer}) => {
const samples = newBuffer.getChannelData(0); const samples = renderedBuffer.getChannelData(0);
const sampleRate = newBuffer.sampleRate; const sampleRate = renderedBuffer.sampleRate;
this.submitNewSamples(samples, sampleRate); this.submitNewSamples(samples, sampleRate);
this.handlePlay(); this.handlePlay();
}); });
......
...@@ -38,7 +38,7 @@ class AudioEffects { ...@@ -38,7 +38,7 @@ class AudioEffects {
buffer.getChannelData(0).reverse(); buffer.getChannelData(0).reverse();
break; break;
} }
const OfflineAudioContext = window.OfflineAudioContext || window.webkitOfflineAudioContext;
this.audioContext = new OfflineAudioContext(1, sampleCount, buffer.sampleRate); this.audioContext = new OfflineAudioContext(1, sampleCount, buffer.sampleRate);
this.buffer = buffer; this.buffer = buffer;
this.source = this.audioContext.createBufferSource(); this.source = this.audioContext.createBufferSource();
...@@ -46,7 +46,7 @@ class AudioEffects { ...@@ -46,7 +46,7 @@ class AudioEffects {
this.source.playbackRate.value = playbackRate; this.source.playbackRate.value = playbackRate;
this.name = name; this.name = name;
} }
process () { process (done) {
// Some effects need to use more nodes and must expose an input and output // Some effects need to use more nodes and must expose an input and output
let input; let input;
let output; let output;
...@@ -75,7 +75,8 @@ class AudioEffects { ...@@ -75,7 +75,8 @@ class AudioEffects {
this.source.start(); 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