I have the following function
function calculateMFCC (wavFile, clipID) {
var audioData = loadAudioData(wavFile);
clipId = clipID;
passToWavReader(audioData);
}
The function loadAudioData(wavFile) should load a wav file using Ajax and return result as an arraybuffer. This is how it looks like:
function loadAudioData(wavFile) {
var request = new XMLHttpRequest();
request.open('GET', wavFile, false);
//request.responseType = 'arraybuffer';
request.onload = function() {
var audioData = stringToArrayBuffer(request.response);
//passToWavReader(audioData);
return audioData;
}
request.send();
}
When I debug the script, I see that in loadAudioData(wavFile) function the variable audioData gets the value it should get, but then when it returns to the function calculateMFCC (wavFile, clipID) the value audioData is undefined, so when it calls passToWavReader(audioData) the script breaks. So, the audioData variable from calculateMFCC somehow didn't get the value from loadAudioData.