mirror of
https://github.com/lewismoten/data-over-audio.git
synced 2026-04-20 05:06:24 +08:00
show number of frequencies for given fft size
This commit is contained in:
13
index.js
13
index.js
@@ -79,10 +79,10 @@ function handleWindowLoad() {
|
||||
document.getElementById('fft-size-power-text').addEventListener('input', (event) => {
|
||||
FFT_POWER = parseInt(event.target.value);
|
||||
if(analyser) analyser.fftSize = 2 ** FFT_POWER;
|
||||
document.getElementById('frequency-resolution').innerText = (getAudioContext().sampleRate / 2 ** FFT_POWER).toFixed(2);
|
||||
updateFrequencyResolution();
|
||||
resetGraphData();
|
||||
});
|
||||
document.getElementById('frequency-resolution').innerText = (getAudioContext().sampleRate / 2 ** FFT_POWER).toFixed(2);
|
||||
updateFrequencyResolution();
|
||||
document.getElementById('smoothing-time-constant-text').addEventListener('input', event => {
|
||||
SMOOTHING_TIME_CONSTANT = parseFloat(event.target.value);
|
||||
if(analyser) analyser.smoothingTimeConstant = SMOOTHING_TIME_CONSTANT;
|
||||
@@ -95,6 +95,15 @@ function handleWindowLoad() {
|
||||
showSpeed();
|
||||
}
|
||||
|
||||
function updateFrequencyResolution() {
|
||||
const sampleRate = getAudioContext().sampleRate;
|
||||
const fftSize = 2 ** FFT_POWER;
|
||||
const frequencyResolution = sampleRate / fftSize;
|
||||
const frequencyCount = (sampleRate/2) / frequencyResolution;
|
||||
document.getElementById('frequency-resolution').innerText = frequencyResolution.toFixed(2);
|
||||
document.getElementById('frequency-count').innerText = frequencyCount.toFixed(2);
|
||||
}
|
||||
|
||||
function showSpeed() {
|
||||
const baud = 1000 / FREQUENCY_DURATION;
|
||||
const bytes = baud / 8;
|
||||
|
||||
Reference in New Issue
Block a user