show number of frequencies for given fft size
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
Last Bit Percent: <input id="last-bit-percent" type="number" min="0" max="100" value="90">%<br>
|
||||
FFT Size: 2^<input id="fft-size-power-text" type="number" min="5" max="15" value="90"><br>
|
||||
Frequency Resolution: <span id="frequency-resolution">N/A</span><br>
|
||||
Frequency Count: <span id="frequency-count">N/A</span><br>
|
||||
Smoothing Time Constant: <input id="smoothing-time-constant-text" type="number" min="0.00" max="1.00" step="0.01" value="0.00"><br>
|
||||
<input type="text" id="text-to-send">
|
||||
<button id="send-button">Send</button>
|
||||
|
||||
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