diff --git a/htdocs/lib/AudioEngine.js b/htdocs/lib/AudioEngine.js index 6226825..132df15 100644 --- a/htdocs/lib/AudioEngine.js +++ b/htdocs/lib/AudioEngine.js @@ -18,7 +18,8 @@ function AudioEngine(maxBufferLength, audioReporter) { this.compression = 'none'; this.setupResampling(); - this.resampler = new sdrjs.RationalResamplerFF(this.resamplingFactor, 1); + //this.resampler = new sdrjs.RationalResamplerFF(this.resamplingFactor, 1); + this.resampler = new Interpolator(this.resamplingFactor); this.maxBufferSize = maxBufferLength * this.getSampleRate(); } @@ -203,7 +204,7 @@ AudioEngine.prototype.pushAudio = function(data) { } else { buffer = new Int16Array(data); } - buffer = this.resampler.process(sdrjs.ConvertI16_F(buffer)); + buffer = this.resampler.process(buffer); if (this.audioNode.port) { // AudioWorklets supported this.audioNode.port.postMessage(buffer); @@ -278,4 +279,16 @@ ImaAdpcmCodec.prototype.decodeNibble = function(nibble) { this.step = ImaAdpcmCodec.imaStepTable[this.stepIndex]; return this.predictor; -}; \ No newline at end of file +}; + +function Interpolator(factor) { + this.factor = factor; +} + +Interpolator.prototype.process = function(data) { + var output = new Float32Array(data.length * this.factor); + for (var i = 0; i < data.length; i++) { + output[i * this.factor] = (data[i] + 0.5) / 32768; + } + return output; +} \ No newline at end of file