My goal is to generate audio at a specific frequency, and then check at what frequency the FFT result is used.
function speak() {
gb.src = gb.ctx.createOscillator();
gb.src.connect(gb.ctx.destination);
gb.src.start(gb.ctx.currentTime);
gb.src.frequency.value = 1000;
}
function listen() {
navigator.getUserMedia = (navigator.getUserMedia
|| navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
navigator.getUserMedia({
audio : true,
video : false
}, function(stream) {
gb.stream = stream;
var input = gb.ctx.createMediaStreamSource(stream);
gb.analyser = gb.ctx.createAnalyser();
gb.analyser.fftSize = gb.FFT_SIZE;
input.connect(gb.analyser);
gb.freqs = new Uint8Array(gb.analyser.frequencyBinCount);
setInterval(detect, gb.BIT_RATE / 2);
}, function(err) {
console.log('The following gUM error occured: ' + err);
});
}
See a working example at http://codepen.io/Ovilia/full/hFtrA/ . You may need to place a microphone next to the speaker to see the effect.
The problem is that when the frequency is somewhere above 15000 (for example, 16000), it seems that there is no reaction in the high frequency region anymore.
Is there any frequency limit with Web Audio, or is it the limit of my device?
What is the unit of each item when I receive from getByteFrequencyData?
source
share