Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
How to get the sample rate of a microphone/input device using Javascript?

When you create a new AudioContext it sets the sample rate to the default output device. This is expected default behavior. Does anyone know if there is there any way to get the sample rate of the input device in Javascript?

We can see in the docs for AudioContext it says this about sampleRate

The value will typically be between 8,000 Hz and 96,000 Hz; the default will vary depending on the output device, but the sample rate 44,100 Hz is the most common. If the sampleRate property is not included in the options, or the options are not specified when creating the audio context, the new context's output device's preferred sample rate is used by default.

Example of how I'm using it:

const stream = await navigator.mediaDevices.getUserMedia({audio: true, video: false});
const context = new AudioContext();
context.sampleRate // This is the default output device's sample rate. I need the default input sampleRate

I've been scouring the docs and the internet for a way to do this but have not found anything useful. Appreciate any help.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can get the sampleRate of the audio track within the stream like this:

const sampleRate = stream.getAudioTracks()[0].getSettings().sampleRate;

You can then use that to create the AudioContext.

const context = new AudioContext({ sampleRate });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda