display frequency resolution

This commit is contained in:
Lewis Moten
2024-05-02 21:46:13 -04:00
parent d508dd700b
commit 2bc4f9879d
2 changed files with 3 additions and 0 deletions

View File

@@ -15,6 +15,7 @@
Frequency Low: <input id="frequency-low-text" type="number" min="20" max="20000" value="1200"><br> Frequency Low: <input id="frequency-low-text" type="number" min="20" max="20000" value="1200"><br>
Last Bit Percent: <input id="last-bit-percent" type="number" min="0" max="100" value="90">%<br> 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> 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>
Smoothing Time Constant: <input id="smoothing-time-constant-text" type="number" min="0.00" max="1.00" step="0.01" value="0.00"><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"> <input type="text" id="text-to-send">
<button id="send-button">Send</button> <button id="send-button">Send</button>

View File

@@ -79,8 +79,10 @@ function handleWindowLoad() {
document.getElementById('fft-size-power-text').addEventListener('input', (event) => { document.getElementById('fft-size-power-text').addEventListener('input', (event) => {
FFT_POWER = parseInt(event.target.value); FFT_POWER = parseInt(event.target.value);
if(analyser) analyser.fftSize = 2 ** FFT_POWER; if(analyser) analyser.fftSize = 2 ** FFT_POWER;
document.getElementById('frequency-resolution').innerText = (getAudioContext().sampleRate / 2 ** FFT_POWER).toFixed(2);
resetGraphData(); resetGraphData();
}); });
document.getElementById('frequency-resolution').innerText = (getAudioContext().sampleRate / 2 ** FFT_POWER).toFixed(2);
document.getElementById('smoothing-time-constant-text').addEventListener('input', event => { document.getElementById('smoothing-time-constant-text').addEventListener('input', event => {
SMOOTHING_TIME_CONSTANT = parseFloat(event.target.value); SMOOTHING_TIME_CONSTANT = parseFloat(event.target.value);
if(analyser) analyser.smoothingTimeConstant = SMOOTHING_TIME_CONSTANT; if(analyser) analyser.smoothingTimeConstant = SMOOTHING_TIME_CONSTANT;