Reputation: 529
My sampleRate in AudioContext.SampleRate()
is always 48khz. Then I change the definitions in windows, going to "recording devices" and change there the SampleRate of the Mic. But, with any reason to happen, the AudioContext.SampleRate()
remains the same. Why? This value is related only to the device and not with the windows definitions?
Upvotes: 0
Views: 150
Reputation: 13908
The audio context sample rate is determined by the output device, not the input device. The input device is resampled to the output device rate.
Upvotes: 2
Reputation: 7588
You can use https://github.com/taisel/XAudioJS/blob/master/resampler.js
var resampler = new Resampler(44100, 48000, 1, 2229);
function startUsermedia(stream) {
var input = audio_context.createMediaStreamSource(stream);
recorder = audio_context.createScriptProcessor(2048);
recorder.onaudioprocess = recorderProcess;
recorder.connect(audio_context.destination);
}
function recorderProcess(e) {
var buffer = e.inputBuffer.getChannelData(0);
var resampled = resampler.resampler(buffer);
}
Note:
Creds for code: https://stackoverflow.com/a/30032095/1501285
Upvotes: -1