This repository was archived by the owner on Jun 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
This repository was archived by the owner on Jun 9, 2019. It is now read-only.
Loading wav's from a file not working on Chrome(59.0.3071.86) and Opera(45.0.2552.888). #66
Copy link
Copy link
Open
Description
Posting this to help out anyone else, who stumbles upon this problem. I don't really know how to properly implement this, but here's a diff of a solution that helped me.
Breakage seems to have been caused by a changing in the web audio API.
--- a/timbre.dev.js
+++ b/timbre.dev.js
@@ -3527,34 +3527,39 @@
var buffer;
try {
- buffer = ctx.createBuffer(data.buffer, false);
+ buffer = ctx.decodeAudioData(data.buffer).then(success, failure);
} catch (e) {
return onloadedmetadata(false);
}
- samplerate = ctx.sampleRate;
- channels = buffer.numberOfChannels;
- if (channels === 2) {
- bufferL = buffer.getChannelData(0);
- bufferR = buffer.getChannelData(1);
- } else {
- bufferL = bufferR = buffer.getChannelData(0);
- }
- duration = bufferL.length / samplerate;
+ function success(buffer){
+ samplerate = ctx.sampleRate;
+ channels = buffer.numberOfChannels;
+ if (channels === 2) {
+ bufferL = buffer.getChannelData(0);
+ bufferR = buffer.getChannelData(1);
+ } else {
+ bufferL = bufferR = buffer.getChannelData(0);
+ }
+ duration = bufferL.length / samplerate;
- var mixdown = new Float32Array(bufferL);
- for (var i = 0, imax = mixdown.length; i < imax; ++i) {
- mixdown[i] = (mixdown[i] + bufferR[i]) * 0.5;
- }
+ var mixdown = new Float32Array(bufferL);
+ for (var i = 0, imax = mixdown.length; i < imax; ++i) {
+ mixdown[i] = (mixdown[i] + bufferR[i]) * 0.5;
+ }
- onloadedmetadata({
- samplerate: samplerate,
- channels : channels,
- buffer : [mixdown, bufferL, bufferR],
- duration : duration
- });
+ onloadedmetadata({
+ samplerate: samplerate,
+ channels : channels,
+ buffer : [mixdown, bufferL, bufferR],
+ duration : duration
+ });
- onloadeddata();
+ onloadeddata();
+ }
+ function failure(){
+ onloadedmetadata(false);
+ }
};
return function(src, onloadedmetadata, onloadeddata) {
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels