comparison js/core.js @ 2643:52e51b15f808

Revert "#3: Added resampler from JS-xtract into resampler.js. Automatically use to match sample rates" This reverts commit 094db4c7aad651e6585839337c9b21fc628604ae.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 19 Jan 2017 15:00:15 +0000
parents 77204f78386a
children 130ae66c3b25
comparison
equal deleted inserted replaced
2642:77204f78386a 2643:52e51b15f808
1505 1505
1506 // Create callback to decode the data asynchronously 1506 // Create callback to decode the data asynchronously
1507 function processAudio(response) { 1507 function processAudio(response) {
1508 var self = this; 1508 var self = this;
1509 return audioContext.decodeAudioData(response, function (decodedData) { 1509 return audioContext.decodeAudioData(response, function (decodedData) {
1510 if (decodedData.sampleRate !== audioContext.sampleRate) {
1511 // Resample
1512 var num_channels = decodedData.numberOfChannels,
1513 num_samples = decodedData.length,
1514 r = audioContext.sampleRate / decodedData.sampleRate,
1515 new_buffer = audioContext.createBuffer(num_channels, Math.floor(num_samples * r), audioContext.sampleRate),
1516 channel;
1517 for (channel = 0; channel < num_channels; channel++) {
1518 var buffer = new Float32Array(decodedData.length);
1519 decodedData.copyFromChannel(buffer, channel);
1520 buffer = xtract_resample(buffer, audioContext.sampleRate, decodedData.sampleRate);
1521 new_buffer.copyToChannel(buffer, channel);
1522 }
1523 decodedData = new_buffer;
1524 buffer = new_buffer = undefined;
1525 }
1526 self.buffer = decodedData; 1510 self.buffer = decodedData;
1527 self.status = 2; 1511 self.status = 2;
1528 calculateLoudness(self, "I"); 1512 calculateLoudness(self, "I");
1529 return true; 1513 return true;
1530 }, function (e) { 1514 }, function (e) {