Overview
The BioniChaos Singing Game & Vocal Pitch Detection Lab is an interactive digital audio workstation and biophysical simulator designed to analyze human vocal frequencies in real-time. Human vocalization originates when pulmonary air pressure drives the elastic vocal folds within the larynx into periodic self-sustained vibrations. The resulting rate of vocal fold opening and closing sets the fundamental frequency ($f_0$), expressed in Hertz ($\text{Hz}$).
To compute vocal pitch accurately from digitized microphone audio, this application executes real-time time-domain autocorrelation coupled with a 2nd-order Biquad bandpass filter ($80\text{ Hz} - 1200\text{ Hz}$) that isolates human voice harmonics while stripping DC offsets, ambient microphone rumble, and high-frequency acoustic hiss. Audio signals $x[n]$ sampled at $f_s \approx 44.1\text{ kHz}$ are transformed via the discrete autocorrelation function $R(\tau)$:
$$R(\tau) = \sum_{n=0}^{N-1-\tau} x[n] \cdot x[n+\tau]$$
By determining the predominant non-zero lag $\tau_{\max}$ that maximizes $R(\tau)$, the exact fundamental vocal pitch is derived via $f_0 = \frac{f_s}{\tau_{\max}}$. Additionally, pitch accuracy is mapped against equal-temperament musical note scales using logarithmic Cents tuning offsets:
$$\text{Cents Offset} = 1200 \cdot \log_2 \left( \frac{f_{\text{detected}}}{f_{\text{target}}} \right)$$
This laboratory provides vocalists, audio engineers, and speech-language pathologists with a comprehensive tool to evaluate intonation precision, vocal range bounds, and signal waveform dynamics.
How to Use
- Activate Microphone & Game Session: Click "Start Game Session" to grant microphone access and queue the target song notes across the visualizer arena.
- Toggle Audio Synth Guide: Click "Sound OFF / Sound ON" to enable or mute the Web Audio synthesizer guide tone, providing an audible pitch target during practice sessions.
- Set Your Vocal Range Scale: Choose your vocal classification (Tenor/Alto, Bass/Baritone, Soprano, or Wide Range) from the dropdown to automatically calibrate the vertical pitch axis for your vocal anatomy.
- Sing on Target: Vocalize into your microphone. Watch the live pitch marker and neon trailing ribbon move vertically to hit the scrolling target note blocks at the vertical strike bar ($x = 100\text{ px}$).
- Monitor Real-Time Intonation: Check the Cents Tuning Meter to see if your vocal tone is perfectly in-tune ($\pm 10\text{ Cents}$), flat, or sharp. Accumulate consecutive note hits to trigger Score Multipliers ($2\times, 3\times, 4\times$) and particle hit explosions.
- Interactive Demo Sandbox: Click "Start Demo" to observe an automated synthetic singing demonstration featuring vibrato modulation and particle hit bursts without requiring microphone input.
Technical Details
The system is constructed entirely on client-side Web Audio API and HTML5 Canvas technology. Audio input buffers ($N = 2048$ Float32 samples) pass through a 2nd-order Butterworth bandpass filter before reaching the `AnalyserNode`. Prior to lag correlation searching, the engine calculates Root Mean Square ($\text{RMS}$) volume amplitude to safeguard against processing silence or unvoiced breath noise:
$$\text{RMS} = \sqrt{\frac{1}{N} \sum_{n=0}^{N-1} x[n]^2}$$
If $\text{RMS}$ falls below the configurable noise gate threshold (default $0.015$), lag searches are bypassed to preserve CPU resources. When valid vocal energy is present, lag searches are bounded within musical boundaries ($\text{lag} \in [20, 550]$), covering fundamental pitches between $80\text{ Hz}$ and $2200\text{ Hz}$.
The canvas rendering engine relies on high-density buffer scaling (`window.devicePixelRatio`) to deliver crisp, pixelated-free graphics on Retina and high-DPI monitors. The visualizer layers an oscilloscope grid matrix ($\text{rgba}(4, 119, 191, 0.15)$), dynamic time-domain waveforms, pitch trail ribbons, particle explosion vectors, and Cents intonation meters at a smooth 60 FPS update rate.
Future Directions
Future iterations of the BioniChaos Vocal Analysis Engine will incorporate clinical voice perturbation analysis to quantify **Jitter** (short-term cycle-to-cycle frequency variation) and **Shimmer** (short-term cycle-to-cycle amplitude variation):
$$\text{Jitter (\%)} = \frac{\frac{1}{M-1} \sum_{i=1}^{M-1} |T_i - T_{i+1}|}{\frac{1}{M} \sum_{i=1}^M T_i} \times 100\%$$
$$\text{Shimmer (dB)} = \frac{1}{M-1} \sum_{i=1}^{M-1} \left| 20 \log_{10} \left( \frac{A_{i+1}}{A_i} \right) \right|$$
These biomedical biomarkers enable non-invasive screening for vocal cord strain, glottal incompetence, and laryngeal pathologies. Upcoming functional modules will also feature Web Audio `AudioWorkletProcessor` offloading, YIN pitch detection kernels compiled to WebAssembly (WASM), and automated formant tracking ($F_1, F_2, F_3$) for vowel articulation feedback.