Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.52k stars 983 forks source link

ToneAudioBuffer does not return a buffer when using AudioContext.decodeAudioData after v14.8.6 #991

Closed abswiz closed 2 years ago

abswiz commented 2 years ago

Hi There

We are trying to upgrade to the latest version of Tone JS, which appears to be 14.8.32, according to cdnjs. We are currently using 14.8.6. All versions above 14.8.6 fail on the following lines of code:

var audioContext = new (window.AudioContext || window.webkitAudioContext)();
var request = new XMLHttpRequest();
request.open('GET', 'https://mdn.github.io/webaudio-examples/decode-audio-data/viper.mp3', true);
request.responseType = 'arraybuffer';
request.onload = function() {
    let audioData = request.response;
    audioContext.decodeAudioData(audioData, (buffer) => {
        var toneAudioBuffer = new Tone.ToneAudioBuffer(buffer);
        console.log(toneAudioBuffer.length, toneAudioBuffer.duration);
    })
};
request.send();

The line that yields different results is:

new Tone.ToneAudioBuffer(buffer)

In this line the ToneAudioBuffer returns a valid buffer with duration and length in 14.8.6, but all versions above that return 0 for the duration and length. We have tested this on Chrome and Safari, both of which yield the same results.

Thank you for your help. Abs www.dappledark.com

thadeusoares commented 2 years ago

Has anyone fixed it?