O
O
Olya Pilipenko2014-04-10 21:49:49
JavaScript
Olya Pilipenko, 2014-04-10 21:49:49

How to get the frequency?

I am using the Web Audio API.
I connect the microphone to the analyzer.

context = new AudioContext();
microphone = context.createMediaStreamSource(stream);
analyser = context.createAnalyser();
analyser.fftSize = 2048;
microphone.connect(analyser);

Then I get arrays
fFrequencyData = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteFrequencyData(fFrequencyData);

I need to get the frequency of the sound that enters the microphone.
I don't understand how to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-04-11
Protko @Fesor

Let's start with the fact that the sound into the microphone does not come at the same frequency. It's a whole range of frequencies. The getByteFrequencyData method returns this spectrum, more precisely ... it divides the spectrum into parts, each element of which determines, in other words, the average sound volume at these frequencies.
Can you tell me what you need to do? Display a spectrogram?

A
Andrew, 2014-04-10
@OLS

If the tone is "clean" enough, then just find which frequency has the highest amplitude value.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question