Answer the question
In order to leave comments, you need to log in
How to get the sampleRate for a microphone?
Hi all. There was a need to receive sampleRate for a microphone through JS.
Tried these approaches approach:
//Example 1
var context = new window.AudioContext();
var sampleRate = context.sampleRate;
//Example 2
var audioTimer = 0;
var sampleRate = 0;
recorder.onaudioprocess = function() {
var time = new Date().getTime();
if (audioTimer) {
sampleRate = (1000 * 2048) / (time - audioTimer); //2048 - buffer size
}
audioTimer = time;
}
Answer the question
In order to leave comments, you need to log in
The microphone is an analog device. The signal from it to the sound interface is analog. The same is generally true for speakers - they have an analog signal coming through the wires. The inputs and outputs of the audio interface are analog-to-digital and digital-to-analogue converters, respectively (ADC and DAC). Thus, only the interface has a sampling rate.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question