about summary refs log tree commit diff stats
path: root/html/tuner
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-10-09 17:12:40 -0400
committerelioat <elioat@tilde.institute>2024-10-09 17:12:40 -0400
commit322e15fd5ca01d3dca485f6b33e59e56bbc84496 (patch)
tree2ed9525d82a45d8a31e120312a7f3e9cbe9e278b /html/tuner
parentfef378a7b14e39d0697bee448f5e74798a86103e (diff)
downloadtour-322e15fd5ca01d3dca485f6b33e59e56bbc84496.tar.gz
*
Diffstat (limited to 'html/tuner')
-rw-r--r--html/tuner/index.html16
1 files changed, 8 insertions, 8 deletions
diff --git a/html/tuner/index.html b/html/tuner/index.html
index 4fe848d..20bf125 100644
--- a/html/tuner/index.html
+++ b/html/tuner/index.html
@@ -65,7 +65,7 @@
         const noteDisplay = document.getElementById('note');
 
         let audioContext;
-        let analyser;
+        let analyzer;
         let dataArray;
         let bufferLength;
 
@@ -89,12 +89,12 @@
             audioContext = new (window.AudioContext || window.webkitAudioContext)();
             const source = audioContext.createMediaStreamSource(stream);
 
-            analyser = audioContext.createAnalyser();
-            analyser.fftSize = 2048;
-            bufferLength = analyser.frequencyBinCount;
+            analyzer = audioContext.createAnalyser();
+            analyzer.fftSize = 2048;
+            bufferLength = analyzer.frequencyBinCount;
             dataArray = new Uint8Array(bufferLength);
 
-            source.connect(analyser);
+            source.connect(analyzer);
             drawWaveform();
             setInterval(detectNote, 500);
         }).catch(err => {
@@ -111,7 +111,7 @@
         function drawWaveform() {
             requestAnimationFrame(drawWaveform);
 
-            analyser.getByteTimeDomainData(dataArray);
+            analyzer.getByteTimeDomainData(dataArray);
 
             canvasCtx.clearRect(0, 0, canvas.width, canvas.height);
             canvasCtx.beginPath();
@@ -138,8 +138,8 @@
 
         // Detect the dominant frequency and map it to a musical note
         function detectNote() {
-            const freqArray = new Float32Array(analyser.frequencyBinCount);
-            analyser.getFloatFrequencyData(freqArray);
+            const freqArray = new Float32Array(analyzer.frequencyBinCount);
+            analyzer.getFloatFrequencyData(freqArray);
 
             let maxAmp = -Infinity;
             let maxIndex = 0;