specialized web workstation and digital signal processing (DSP) engine designed for binaural audio spatialization tailored specifically for left and right earphones.
Unlike traditional 3-D audio engines that attempt to simulate elevation (above/below) and front/rear positioning using synthetic spectral tricks, Spatial8 focuses strictly on the two physical psychoacoustic factors that two-channel earphones can physically and unambiguously reproduce:
- Interaural Time Difference (ITD)
- Interaural Level Difference (ILD) & Acoustic Head Shadowing
- Psychoacoustics: Why Two Earphones Only Need Two Factors
- Pulse-Code Modulation (PCM) Explained
- HRTF and HRIR in Theory and Practice
- The Two Physical Factors: Mathematical Modeling
- Concrete Worked Examples
- System Architecture & Processing Pipeline
- The Median Plane Problem: How to Add Elevation, Front, and Rear (Future Roadmap)
- Listening Without Earphones: Loudspeaker & Open-Air Differentiation
- Deep Dive: Advanced Acoustic Physics & DSP Engineering
- The Duplex Theory of Sound Localization (Rayleigh Crossover)
- In-Head Lateralization vs. Out-of-Head Externalization
- Distance Attenuation & Atmospheric Air Absorption
- Doppler Pitch Shift & Dynamic Fractional Delay Interpolation
- Stereo-to-Mono Downmix & Phase Cancellation Prevention
- Server-Side MATLAB DSP vs. Client-Side Web Audio API
- Frequently Asked Questions (FAQ) & Troubleshooting
- Running Locally
- Real-World Applications: Concerts, Games & Film
- Research Papers & Academic Context
- Combining Multiple Audio Sources at Different Coordinates (Scene Mixing)
- The Physics of Acoustic Superposition
- Independent ITD and ILD per Source
- Cocktail Party Effect & Spatial Auditory Scene Analysis
- Preventing Inter-Source Phase Cancellation & Summing Distortion
- Sample Rate Heterogeneity & Continuous Linear Band-Limited Interpolation
- Multi-Track Counterpoint Sweeps & Dynamic Soundscapes
- Step-by-Step Multi-Audio Workflow in Spatial8 Studio
When listening to audio through standard earphones or headphones, sound is delivered directly into the ear canals via two isolated acoustic transducers: the Left driver and the Right driver. There is zero acoustic crosstalk between ears in air.
In free-field open air listening, humans distinguish whether a sound is above, below, in front, or behind through three mechanisms:
-
Pinna Filtering: The microscopic ridges and folds of the outer ear (the pinna) reflect incoming sound waves. These reflections combine with direct sound to create direction-dependent notches and spectral peaks above
$4\text{ kHz}$ . -
Torso and Shoulder Reflections: Echoes bouncing off the chest and shoulders within
$1\text{--}3\text{ ms}$ . - Dynamic Head Tracking: When we hear an ambiguous sound, our neck instinctively rotates by micro-degrees. The brain observes how ITD and ILD shift to resolve front versus rear ("the cone of confusion").
When listening through earphones:
- No Personalized Pinna: Standard earphones bypass the pinna completely (in-ear monitors) or press against it (on-ear/over-ear). Applying an arbitrary synthetic "elevation notch" or "rear slapback" sounds like an unnatural, muffled graphic equalizer or comb-filtering distortion rather than true height.
- No Head Tracking: Without real-time IMU gyroscopes adjusting the audio as your head moves, static front/back cues collapse inside the listener's head.
Because earphones have exactly two output channels, lateral spatial positioning is governed purely and powerfully by:
- Factor 1 (ITD): The arrival time difference of wavefronts reaching the left versus right ear.
- Factor 2 (ILD): The sound pressure level attenuation and high-frequency head shadow between the ear facing the source and the ear facing away.
By mastering these two physical parameters, sound pans across the stereo field with crystalline clarity, punchy transients, and zero phase muddiness.
Pulse-Code Modulation (PCM) is the digital representation of raw, uncompressed analog audio signals. An analog sound wave is continuous in both time and amplitude. PCM converts it into a discrete-time sequence of numerical amplitudes by:
-
Sampling: Measuring the wave amplitude at uniformly spaced time intervals
$T = \frac{1}{f_s}$ , where$f_s$ is the sampling rate. - Quantization: Rounding each measured continuous amplitude to the nearest integer value defined by the bit depth.
Analog Waveform: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Discrete Sampling: | | | | | |
Quantized PCM: [+0.12, +0.65, +0.94, +0.41, -0.22, -0.87]
The Nyquist-Shannon Sampling Theorem states that to perfectly reconstruct an analog signal containing frequencies up to
- Human hearing upper limit:
$\approx 20\text{ kHz}$ . - Standard CD Audio rate:
$44.1\text{ kHz}$ ($2 \times 20\text{ kHz} = 40\text{ kHz}$ , with a$4.1\text{ kHz}$ guard band for anti-aliasing low-pass filters). - Professional Studio rate:
$48\text{ kHz}$ or$96\text{ kHz}$ . - Time interval between samples at
$44.1\text{ kHz}$ :$$T_s = \frac{1}{44100} \approx 22.6757\ \mu\text{s}$$
Bit depth determines the resolution of each sample's amplitude and the noise floor:
-
16-bit Linear PCM:
$2^{16} = 65,536$ discrete amplitude steps. Dynamic range$\approx 6.02 \times 16 \approx 96.3\text{ dB}$ . -
24-bit Linear PCM:
$2^{24} = 16,777,216$ discrete amplitude steps. Dynamic range$\approx 144.5\text{ dB}$ . -
32-bit Floating-Point PCM: Uses IEEE 754 float representation (1 sign bit, 8 exponent bits, 23 mantissa bits). Amplitudes range between
$-1.0$ and$+1.0$ , preventing digital clipping during intermediate DSP convolution.
MP3 files are lossy, perceptual bitstreams. They discard imperceptible audio details using Modified Discrete Cosine Transforms (MDCT) and Huffman coding. You cannot perform digital filtering or time delays directly on an MP3 bitstream.
To spatialize an MP3:
- FFmpeg decodes the MP3 frames into uncompressed 32-bit float or 24-bit linear PCM vectors:
$$x[n] \in [-1.0, +1.0], \quad n = 0, 1, 2, \dots, N-1$$ - The DSP engine processes the raw PCM buffers through time-delay interpolation and finite impulse response (FIR) filtering.
- The resulting stereo PCM buffers
$[y_L[n], y_R[n]]$ are peak-normalized. - FFmpeg/LAME encodes the processed PCM buffers back into a high-bitrate (
$320\text{ kbps}$ ) MP3 file.
-
HRTF (Head-Related Transfer Function): The complex frequency-domain response
$H(f, \theta, \phi)$ describing how a sound wave from azimuth$\theta$ and elevation$\phi$ is filtered by the head and ears before reaching the eardrum:$$H(f) = |H(f)| e^{j \Phi(f)}$$ where$|H(f)|$ represents magnitude (ILD) and$\Phi(f)$ represents phase delay (ITD). -
HRIR (Head-Related Impulse Response): The inverse Fourier transform of the HRTF into the discrete-time domain:
$$h[n] = \mathcal{F}^{-1}{H(f)}$$ An HRIR is a finite impulse response (FIR) filter representing the acoustic response of the ear to an instantaneous Dirac delta click$\delta[n]$ .
Filtering an input audio PCM signal
For two earphones, we calculate two distinct signals:
When a sound source is positioned at angle
Sound Source
\
\
\
[ L Ear ]
/ \
| Head |
\ /
[ R Ear ] <--- Extra distance d traveled!
Using a spherical head approximation of radius
- For a source directly ahead (
$\theta = 0^\circ = 0\text{ rad}$ ):$$\tau(0) = \frac{0.0875}{343} (0 + 0) = 0.00\text{ ms}$$ - For a source at full left (
$\theta = 90^\circ = \frac{\pi}{2}\text{ rad}$ ):$$\tau\left(\frac{\pi}{2}\right) = \frac{0.0875}{343} \left(\frac{\pi}{2} + \sin\frac{\pi}{2}\right) \approx 0.0002551 \times (1.5708 + 1) \approx 0.6558\text{ ms}$$
At
Because
This achieves sub-sample temporal precision with zero phase artifacts.
Sound pressure drops across distance, and the human head acts as an acoustic baffle that obstructs high frequencies.
For lateral angle
At
Wavelength is inversely proportional to frequency:
- For low frequencies (
$200\text{ Hz}$ ):$\lambda = \frac{343}{200} = 1.715\text{ m}$ . The sound wave is vastly larger than the head diameter ($17.5\text{ cm}$ ), bending effortlessly around it (diffraction). - For high frequencies (
$3\text{ kHz}$ ):$\lambda = \frac{343}{3000} \approx 0.114\text{ m}$ ($11.4\text{ cm}$ ). The wave is smaller than the head, casting an acoustic shadow.
Spatial8 implements this physical shadow on the farther ear using a discrete-time one-pole spectral shelf filter (
Suppose a user uploads a
-
Calculate ITD:
$$\tau = \frac{0.0875}{343} \left(\frac{\pi}{2} + 1\right) \approx 0.656\text{ ms} \implies D = 28.92\text{ samples}$$ - Left Ear:
$0\text{ samples}$ delay. - Right Ear:
$28.92\text{ samples}$ delay.
- Left Ear:
-
Calculate ILD & Head Shadow:
- Left Ear: Gain =
$1.000$ ($0\text{ dB}$ , full direct signal). - Right Ear: Overall attenuation
$-8.5\text{ dB}$ ($G \approx 0.376$ ), high-frequency shelf gain$G_{\text{high}} = 0.25$ ($-12\text{ dB}$ on harmonics above$1.5\text{ kHz}$ ).
- Left Ear: Gain =
-
Discrete PCM Result:
$$y_L[n] = x[n]$$ $$y_R[n] = 0.376 \times \text{Filter}_{\text{shadow}}(0.08 x[n - 28] + 0.92 x[n - 29])$$ - Perception: Sound snaps distinctly and comfortably into the left earphone, with natural spatial width rather than harsh mono hard-panning.
-
Calculate ITD:
$$\tau(0) = 0.00\text{ ms} \implies D = 0\text{ samples}$$ -
Calculate ILD:
$$\Delta L(0) = 0.0\text{ dB} \implies G = 1.000,\ G_{\text{high}} = 1.000$$ -
Discrete PCM Result:
$$y_L[n] = x[n]$$ $$y_R[n] = x[n]$$ - Perception: The audio creates an exact phantom center image directly between both earphones, with zero phase cancellation or tonal coloration.
When a source is set to animate from Left (
- Audio is processed in sequential blocks of
$B = 1024\text{ samples}$ ($23.2\text{ ms}$ per block). - For each block
$m$ , the normalized progress$\lambda \in [0, 1]$ is computed:$$\theta[m] = (1 - \lambda) \cdot (+80^\circ) + \lambda \cdot (-80^\circ)$$ - ITD delay samples
$D[m]$ and ILD gains$G[m]$ update dynamically per block. - The fractional delay buffer smoothly interpolates the delay across blocks, producing a seamless, Doppler-clean sweep across the listener's head.
┌─────────────────────────────────────────────────────────────┐
│ Vite + React Client │
│ (Handcrafted Retro UI · Interactive Earphone Soundstage) │
└──────────────────────────────┬──────────────────────────────┘
│ HTTP / Multipart
▼
┌─────────────────────────────────────────────────────────────┐
│ Spring Boot REST API (Port 8080) │
│ - Storage Management (`backend/storage/`) │
│ - Session Authentication & Community State │
│ - Single-threaded Background Render Worker │
└──────────────────────────────┬──────────────────────────────┘
│ Generates MATLAB Batch Script
▼
┌─────────────────────────────────────────────────────────────┐
│ MATLAB + FFmpeg DSP Core │
│ 1. Decode MP3 -> Linear Float PCM via FFmpeg │
│ 2. Compute Block-by-Block Lateral Angle theta │
│ 3. Calculate Woodworth ITD (Fractional Delay Interpolation) │
│ 4. Calculate ILD & Head Shadow (1-Pole Spectral Shelf) │
│ 5. Sum PCM Channels across Multiple Audio Sources │
│ 6. Peak Normalization (0.98 FS) │
│ 7. Encode -> High-Bitrate Stereo MP3 via FFmpeg libmp3lame │
└─────────────────────────────────────────────────────────────┘
A fundamental principle of acoustics is that interaural differences (ITD and ILD) can only differentiate lateral positions (Left vs. Right).
When a sound source lies on the median sagittal plane (directly in front, overhead/elevation, behind, or below):
- The distance from the source to the Left earphone equals the distance to the Right earphone.
- Therefore:
$$\text{ITD} = 0.00\text{ ms}$$ $$\text{ILD} = 0.0\text{ dB}$$ - The left earphone and right earphone receive mathematically identical signals!
This creates the classic psychoacoustic phenomenon known as the Cone of Confusion: for any given lateral angle, there is an entire cone of 3D spatial points where the sound arrives at both ears with the exact same time delay and sound level.
+Z (Above / Elevation)
▲
│
-X (Behind) ◄──────┼──────► +X (In Front)
│
▼
-Z (Below / Nadir)
(All points on this plane have ITD = 0ms and ILD = 0dB!)
Because stereo earphones cannot rely on Left-Right differences for elevation and front/rear, human hearing distinguishes these directions using monaural spectral cues, head motion, and environmental acoustics. Here is how we can implement these in future iterations:
Even though Left and Right earphone signals are identical in timing and overall gain, the physical outer ear (pinna) and head cast angle-dependent acoustic shadows that filter both ears equally:
-
Elevation (Above:
$+30^\circ$ to$+90^\circ$ ):- Sound entering from above bounces off the concha floor and enters the ear canal with a characteristic pinna elevation notch between
$6.5\text{ kHz}$ and$10\text{ kHz}$ . - As elevation rises, the notch shifts upward in frequency:
$$f_{\text{notch}}(\phi) \approx 6500 + 45 \cdot \phi^\circ\quad (\text{Hz})$$ - Elevated sources also receive a boost in the upper "air" band (
$>8\text{ kHz}$ ) due to direct unhindered line-of-sight to the eardrum. -
How to Implement in DSP: Apply a symmetric parametric notch filter (biquad) to both channels whose center frequency shifts upward with elevation
$Z$ , paired with a gentle high-shelf boost ($+2\text{ to }+4\text{ dB}$ ).
- Sound entering from above bounces off the concha floor and enters the ear canal with a characteristic pinna elevation notch between
-
Below (Nadir:
$-30^\circ$ to$-90^\circ$ ):- Sounds below the head are physically obstructed by the listener's shoulders, chest, and lower jaw.
- High frequencies are absorbed, creating a distinct low-pass roll-off starting around
$3\text{--}4\text{ kHz}$ . -
How to Implement in DSP: Apply an aggressive dual-ear high-frequency roll-off (shelf
$G \approx -6\text{ to } -12\text{ dB}$ above$3\text{ kHz}$ ).
-
In Front vs. Behind (
$+X$ vs.$-X$ ):-
Front (
$+X$ ): Sound enters the open ear canal directly. The acoustic resonance of the human ear canal creates a natural presence peak around$2.5\text{--}4.0\text{ kHz}$ . -
Behind (
$-X$ ): The rear flap of the ear (helix/antihelix) physically shadows the ear canal. Rear sounds lose high-frequency crispness above$2\text{ kHz}$ and exhibit a spectral dip around$3\text{ kHz}$ . -
How to Implement in DSP: Apply a rear head-shadow low-pass filter to both channels whenever
$X < 0$ , combined with a mild presence dip at$3\text{ kHz}$ .
-
Front (
In the real world, nobody holds their head completely still. When a sound is ambiguous (front vs. back), the listener unconsciously rotates their neck by a fraction of a degree.
- If a sound is in front and you turn your head slightly to the left:
- The sound shifts towards your Right earphone ($\text{ITD}{\text{right}} < \text{ITD}{\text{left}}$).
- If the sound is behind and you turn your head slightly to the left:
- The sound shifts towards your Left earphone ($\text{ITD}{\text{left}} < \text{ITD}{\text{right}}$)!
The brain instantly compares the vestibular motion of the neck with the direction of ITD change to resolve front vs. back without ambiguity.
Future Implementation:
- Integrate Web Bluetooth / WebHID API with standard IMU motion-sensing earphones (Apple AirPods Spatial Audio, Sony 360, or a head-mounted Arduino MPU-6050).
- Dynamically rotate source azimuth
$\theta(t)$ and elevation$\phi(t)$ in real time based on head yaw, pitch, and roll:$$\theta_{\text{perceived}} = \theta_{\text{source}} - \psi_{\text{head}}(t)$$ - This turns an ambiguous static front/back filter into an unmistakably localized 3D source.
In nature, human ears never hear a sound source in an absolute anechoic void. The brain uses early acoustic reflections bouncing off environmental surfaces to decode height and depth:
-
Ceiling Reflections (Elevation Cue): Sound from an elevated source bounces off the ceiling and floor with an early delay of
$3\text{--}7\text{ ms}$ . -
Rear Boundary Reflections (Depth Cue): A source behind the listener creates a reflection off the front wall that arrives
$10\text{--}25\text{ ms}$ later. -
How to Implement in DSP:
- Use the Image-Source Method (ISM) to compute early reflection delay taps:
$$\Delta t_{\text{ceiling}} = \frac{2 \cdot h_{\text{room}} - z_{\text{source}}}{c}$$ - Sum these early reflections into both earphone channels with appropriate boundary absorption filters.
- Use the Image-Source Method (ISM) to compute early reflection delay taps:
Because every human being has a unique ear shape (like a retinal scan), generic pinna notches can sound unnatural or cause nausea for some listeners.
Future Implementation:
- Add support for the SOFA (Spatially Oriented Format for Acoustics - AES69 standard) file format.
- Allow users to import their own personalized measured HRTF dataset (captured via in-ear microphones in an anechoic chamber or estimated via smartphone ear-photogrammetry 3D mesh simulations).
- Fast spherical-harmonics or barycentric interpolation on the measured 3D grid.
A common and critical question in spatial audio is: What happens when a listener is NOT using earphones? How can someone differentiate Left versus Right when listening through desktop monitor speakers, laptop speakers, or a mobile phone?
The fundamental physical difference between earphones and open-air loudspeakers is channel isolation:
EARPHONES (Isolated Binaural Delivery):
[Left Earphone] ────────────────────────► Left Ear Canal (100% direct)
[Right Earphone] ────────────────────────► Right Ear Canal (100% direct)
Result: Infinite channel separation. Zero acoustic crosstalk.
LOUDSPEAKERS (Open-Air Acoustic Delivery):
[Left Speaker] ───┬────────────────────► Left Ear (Direct Path d_L)
└─────────\
\─────────► Right Ear (Crosstalk Path d_cross)
[Right Speaker] ───┬────────────────────► Right Ear (Direct Path d_R)
└─────────/
/─────────► Left Ear (Crosstalk Path d_cross)
Result: BOTH ears hear BOTH speakers!
In open air, when the Left speaker plays a sound, the acoustic wave hits the Left ear first (
Even with acoustic crosstalk, a listener without earphones can still tell Left from Right thanks to three primary psychoacoustic mechanisms:
When a sound is panned toward the Left speaker, the sound wave arrives at both the left and right ears from the Left speaker before the Right speaker produces its sound (or the Left speaker's output arrives with higher amplitude).
- The human auditory cortex detects the earliest arriving wavefront (
$t_0$ ) and locks its directional perception to the source of that first wavefront. - Any sound arriving
$1\text{ to }30\text{ ms}$ later from the other speaker is perceptually suppressed as an acoustic reflection rather than a distinct sound source. - Result: You perceive the sound coming clearly from the Left.
When listening in the center "sweet spot" between two stereo speakers (forming an equilateral triangle with the listener at
- If the Left speaker plays at
$0\text{ dB}$ and the Right speaker is attenuated by$-8.5\text{ dB}$ , the sound pressure level hitting the left side of your head is noticeably stronger than the right. - This creates an unmistakable physical level disparity that localizes the sound on the left side of the room.
When you listen through earphones, the sound bypasses your outer ear and head. Software must simulate an artificial HRTF.
- In contrast, when listening to real physical loudspeakers in a room, you do not need an artificial HRTF!
- The sound waves travel through real physical air and bounce off your real physical ears, face, and shoulders. Your own biological body applies the true, perfect physical acoustic filtering naturally.
While high-quality desktop stereo speakers placed
-
Narrow Physical Separation: Laptop speakers are only
$15\text{--}25\text{ cm}$ apart. The angle subtended at the listener's head is tiny ($\pm 8^\circ\text{ to }\pm 12^\circ$ ). -
Extreme Crosstalk: The path length from the Left speaker to the Left ear is nearly identical to the path length to the Right ear (
$d_L \approx d_{\text{cross}}$ ). -
Phase Comb Filtering: If pure earphone ITD (delay
$\tau \approx 0.65\text{ ms}$ ) is played over closely spaced laptop speakers without compensation, the delayed right-channel audio combines with the crosstalk in air, producing audible comb-filtering (hollow, flanging, or phasey artifacts).
To make binaural audio project outside the physical borders of laptop or desktop speakers without wearing earphones, modern spatial audio DSP uses two techniques:
To eliminate the unwanted crosstalk sound leaking from the Left speaker into the Right ear, the DSP injects an anti-phase cancellation wave into the opposite speaker:
- The Left speaker plays the sound
$x_L(t)$ . - The Right speaker simultaneously plays an inverted anti-sound
$-C(t) * x_L(t)$ timed precisely so that when the Left speaker's wave reaches your right ear, the anti-sound arrives at the exact same microsecond and destructively cancels it in mid-air! - Result: Only your left ear hears the left speaker's sound. The binaural illusion reappears in open space!
For laptop and phone speakers, audio can be decomposed into Mid (sum) and Side (difference) channels:
- By boosting the Side signal
$S$ with a low-frequency shelf filter below$700\text{ Hz}$ , the apparent acoustic width expands well beyond the physical width of the laptop body.
| Playback Device | Channel Separation | Crosstalk Mechanism | How Left/Right is Perceived | Best Spatial Mode |
|---|---|---|---|---|
| In-Ear Earphones | Infinite ( |
None (isolated ear canals) | Direct Woodworth ITD delay ( |
Pure 2-Factor Binaural (Spatial8 Core) |
| Over-Ear Headphones | High ( |
Minimal mechanical headband coupling | Direct ITD & ILD + slight natural ear cup resonance | Pure 2-Factor Binaural (Spatial8 Core) |
| Desktop Stereo Speakers | Medium ( |
Open-air acoustic crosstalk ( |
Precedence/Haas effect & real physical room acoustics | Blumlein Stereo Panning or Transaural XTC |
| Laptop / Tablet Speakers | Low ( |
High crosstalk (narrow |
Level difference primarily; phase cues can sound hollow | Mid-Side (M/S) Stereo Widener + High ILD |
| Single Mono Bluetooth Speaker | None ( |
Full mono sum ( |
Cannot perceive L/R physically; requires visual meters | Summed Mono Mixdown |
Spatial audio processing at the earphone boundary intersects wave physics, neurophysiology, and discrete-time signal processing. This section details the advanced mathematical principles and digital filters powering the spatial engine.
Formulated by Lord Rayleigh in 1907, the Duplex Theory dictates that human sound localization relies on two complementary physical mechanisms segregated by acoustic wavelength
THE RAYLEIGH DUPLEX SPECTRUM
0 Hz 800 Hz 1.5 kHz 20 kHz
├────────────────────────┼─────────────┼───────────────────────────┤
│◄────── ITD DOMINATES ───────────────►│ │
│ Wavelength λ > Head Diameter (2a) │ Localization │
│ Diffraction wraps around skull │ Ambiguity Zone │
│ MSO neural phase-locking │ (Highest error) │
│ │◄────── ILD DOMINATES ────►│
│ │ Wavelength λ < Head (2a) │
│ │ Acoustic shadow cast │
│ │ LSO level comparison │
For an average human head radius
Because
When frequency rises above
-
Spatial Aliasing (Phase Ambiguity): The phase shift between ears exceeds
$\pi$ radians ($180^\circ$ ). The brain cannot tell whether the wave at the far ear is lagging by half a cycle or leading by an entire full cycle. Phase cues become ambiguous. - Acoustic Shadowing: The head acts as a solid rigid obstacle. The incident sound wave is reflected off the near ear side, while the contralateral (far) ear falls into an acoustic "blind spot" or shadow zone.
The brain switches localization mechanisms to the Lateral Superior Olive (LSO), which compares high-frequency sound energy levels. Head shadow attenuation can exceed
Between
A classic challenge in headphone audio is the distinction between lateralization and externalization:
- Lateralization (Inside the Head): Sound appears to originate along an imaginary axis connecting the two ears inside the listener's skull. Pure synthetic ITD and ILD cues without room acoustics invariably produce lateralization.
- Externalization (Outside the Head): The sound source is perceived as an acoustic object located out in 3D physical space, detached from the listener's body.
LATERALIZATION EXTERNALIZATION
(Dry Earphone Cues) (Binaural + Reflections)
Contralateral Contralateral
│ │
┌─────────┴─────────┐ ┌─────────┴─────────┐
│ [L] ● [R] │ │ [L] [R] │
└───────────────────┘ └───────────────────┘
▲ ▲
│ │
Sound perceived inside Sound perceived 2m away
listener's skull in the virtual room
In the real world, an acoustic sound source is never completely dry; sound bounces off walls, floor, and ceilings. Furthermore, human ears are constantly undergoing minute micro-movements (
- The Direct-to-Reverberant Ratio (DRR) is infinite (zero reflections). In physical nature, an infinite DRR only occurs if the source is pressed directly against the ear eardrum.
- Spectral cues lack pinna reflections.
Spatial8 bridges this psychoacoustic gap by allowing an optional Room Boundary Simulator:
- Generates 4 early specular reflections (
$t < 35\text{ ms}$ ) corresponding to virtual room boundaries. - The reflections arrive with asymmetrical ITD delays and inverted low-level ILD, signaling to the brainstem that the source exists in an external enclosure.
Sound spatialization is incomplete without accurate radial distance modeling
For an ideal point source emitting acoustic power
Expressed in decibels of Sound Pressure Level (SPL):
Every doubling of distance reduces sound pressure by exactly
As an audio source approaches
In real air, acoustic energy dissipates due to molecular relaxation of Nitrogen (
At a distance of
When a sound source moves relative to the listener, two phenomena occur simultaneously:
- Dynamic change in arrival time
$\tau(t)$ (Doppler effect). - Continuous modulation of the ITD delay buffer.
If the sound source moves with velocity vector $\vec{v}s$ relative to the listener:
$$f{\text{observed}} = f_{\text{emitted}} \cdot \left(\frac{c}{c - \vec{v}_s \cdot \hat{u}_r}\right)$$
where
In a discrete-time delay line, audio samples are stored in a circular memory buffer. If the delay
Spatial8 implements Fractional Delay Interpolation:
Given a fractional sample delay
-
Linear Interpolation:
$$y[n] = (1 - \mu) \cdot x[n - D_{\text{int}}] + \mu \cdot x[n - D_{\text{int}} - 1]$$ -
Cubic Hermite Spline (for Studio-Grade Fidelity):
$$y[n] = c_0 x[n - D_{\text{int}} + 1] + c_1 x[n - D_{\text{int}}] + c_2 x[n - D_{\text{int}} - 1] + c_3 x[n - D_{\text{int}} - 2]$$
Fractional interpolation guarantees that dynamically moving sources transition smoothly across the stereo field without digital artifacts or phase tearing.
Commercial music tracks are mastered in stereo with existing panning, phase widening, and artificial reverb. Feeding a pre-panned stereo file directly into a spatial audio engine creates severe acoustic artifacts:
- If a sound is panned hard-left in the original recording, and the user positions the spatial source to the hard-right, the earphone outputs become conflicting and unnatural.
- Left and right channels may contain out-of-phase elements (
$180^\circ$ inversion) designed to create a wide stereo image on ordinary speakers.
If an engine performs a naive mono mixdown:
Spatial8 protects input material by analyzing the inter-channel normalized cross-correlation coefficient:
-
When
$\rho_{LR} \ge 0$ (In-phase stereo): Standard coherent mono summation is applied:$$x_{\text{mono}}[n] = \frac{L[n] + R[n]}{\sqrt{2}}$$ -
When
$\rho_{LR} < 0$ (Phase-inverted or anti-phase stereo): Spatial8 applies a$90^\circ$ Hilbert phase rotation to the Right channel before summing:$$x_{\text{mono}}[n] = \frac{L[n] + \mathcal{H}{R[n]}}{\sqrt{2}}$$ This prevents destructive zero-cancellation while preserving full spectral energy across both channels.
Spatial8 utilizes a hybrid architecture: real-time interactive previews on the frontend, with authoritative high-precision rendering on the backend via MATLAB.
| Feature / Metric | Client-Side Web Audio API | Server-Side MATLAB DSP Engine |
|---|---|---|
| Numeric Precision | 32-bit single-precision floating point | 64-bit double-precision IEEE 754 |
| FFT Implementation | Browser-dependent WebAssembly or vendor C++ | Intel MKL / FFTW (maximum numerical precision) |
| Fractional Delay Filtering | Linear sample interpolation or basic delay node | Multi-tap FIR / Sinc-interpolated fractional delay |
| Head Shadow Model | Basic biquad high-shelf approximations | Spherical Head Diffraction & Woodworth Ray Tracing |
| Batch Processing & Export | Limited by client CPU and browser memory limits | Unconstrained multi-threaded offline rendering |
| File Format Support | Dependent on browser codecs (WebM, basic WAV) | Pristine multi-format encoding via FFmpeg (FLAC, MP3, WAV) |
| Determinism & Reproducibility | Varies across Chrome, Firefox, Safari, and OS audio engines | 100% bit-exact, deterministic audio pipelines |
Q1: Why does a sound positioned dead-center ($Y = 0$ ) sound slightly louder than when panned hard to one side?
This is governed by the Pan Law. When sound is centered, both earphones play the signal at full amplitude (
Spatial audio does not damage hardware; however, because ILD boosts high-frequency signals on the near ear while attenuating the far ear, extreme volume settings can cause ear fatigue. Spatial8 includes an automatic output peak limiter that prevents digital clipping above
Many commercial spatial audio plugins attempt to simulate height or distance by aggressively slapping fixed lowpass filters and generic HRTF notches across the entire audio spectrum. Because these filters do not match your individual ear anatomy, your brain interprets the comb filtering as spectral coloration (muffling) rather than spatial distance. Spatial8 intentionally avoids arbitrary spectral butchering, maintaining crystal-clear hi-fi fidelity.
For interactive panning, the total motion-to-sound latency must remain below
According to the Nyquist-Shannon Sampling Theorem, a discrete system can accurately represent frequencies up to half its sample rate (
- Java 21+ (
java -version) - Maven 3.9+ (
mvn -version) - Node.js 20+ (
node -v) - MATLAB (Optional for production spatial rendering; executable should be in PATH or configured via
SPATIA_MATLAB_COMMAND) - FFmpeg (
ffmpeg -version)
cd backend
mvn spring-boot:runThe Spring Boot server starts at http://localhost:8085.
Demo account automatically seeded on startup:
- Email:
demo@gmail.com - Password:
demo@123
cd frontend
npm install
npm run devThe client will start at http://localhost:5173. Open your browser, sign in with the demo account, and experience the handcrafted earphone spatializer!
The ITD/ILD binaural model at the core of Spatial8 is not academic theory — it powers the spatial audio pipelines inside some of the largest entertainment productions in the world. This section breaks down exactly how the same psychoacoustic principles manifest in live concerts, video games, and cinema, with worked engineering details showing what parameters are used and why.
At a large open-air festival (Glastonbury, Coachella, Lollapalooza), a PA system might deploy 80–200 loudspeaker clusters arranged across the venue:
[MAIN STAGE]
┌───────────────┐
[L Hang] ◄──┤ Performers ├──► [R Hang]
└───────────────┘
↓ ↓
[L Delay Tower] [R Delay Tower] (100m away)
↓ ↓
[L Rear Fill] [R Rear Fill] (200m away)
│ │
[L Under-Balcony] [R Under-Balcony] (indoor arenas)
Each speaker cluster is physically separated from the stage by a large propagation delay. For example, a delay tower at
If the system engineers forget to compensate for this delay, the Haas/Precedence Effect (Section 8) causes the audience near the delay tower to hear the delay speakers first, making the sound appear to come from above and to the side rather than from the stage.
Professional live sound consoles (Avid VENUE | S6L, DiGiCo SD7, Yamaha CL5) implement delay compensation identical in principle to Spatial8's ITD delay buffer:
- Each speaker zone is assigned a precise sample-exact delay offset matching its geometric propagation time.
- All delay towers are time-aligned to arrive at the listeners' ears at the same millisecond as the main hang.
- The Interaural Level Difference between the left and right hangs is set by an L/R balance fader — exactly the ILD scaling factor applied in
spatializeAudio.m.
Real example: At Glastonbury's Pyramid Stage, the front-of-house (FOH) desk runs a custom MADI delay chain. The side fill clusters at spatializeAudio.m Woodworth formula computes!
Concerts streamed over YouTube, Twitch, and Spotify Live also increasingly encode a binaural earphone mix alongside the main stereo broadcast. The binaural mix is derived by:
- Collapsing the multi-channel (5.1 or Dolby Atmos 7.1.4) mix to a mono bus per instrument group.
- Placing each instrument at a fixed azimuth angle
$\theta$ matching the stage layout (drums center at$\theta = 0^\circ$ , guitars at$\pm 30^\circ$ , keys at$\pm 60^\circ$ ). - Applying per-source ITD delay and ILD scaling.
This is exactly what Spatial8's scene rendering pipeline does for multi-source compositions.
In first-person shooters (FPS) like Call of Duty, Counter-Strike 2, and Battlefield, directional audio is a competitive advantage. Players rely on spatial hearing to:
- Localize enemy footsteps within
$\pm 5^\circ$ horizontal accuracy. - Distinguish whether gunshots originate from the floor above or below (elevation — which Spatial8's current scope does not cover, see Section 7).
- Detect the approach direction of a grenade before it explodes.
For this to feel immersive, every frame of head rotation (typically at
| Stage | AAA Game (e.g. Unreal Engine 5 + MetaSounds) | Spatial8 Studio |
|---|---|---|
| Source Position | 3D world-space coordinates from physics engine | X/Y earphone plane coordinates from UI |
| HRTF Database | CIPIC or SADIE II database (measured HRIR) | Woodworth analytical HRIR (computed) |
| Convolution Method | Real-time partitioned convolution (overlap-save) in GPU compute shaders | Offline MATLAB conv() for maximum quality |
| Reverb | Acoustic propagation raycasting (Wwise Reflect or Steam Audio) | Optional Room Boundary Simulator |
| Sample Rate | 48 kHz (matches DirectX Audio Session) | 44.1 kHz / 48 kHz (FFmpeg-normalized) |
| Latency Budget | Render callback: 5–10 ms | Render-to-file: 100–500 ms |
Worked Example — Enemy Footstep at 7 o'clock position (
The game engine detects an enemy at azimuth
The negative sign means the right ear leads (sound arrives at the right ear first). ILD at
Microsoft's Spatial Sound API (Windows Sonic, Dolby Atmos for Headphones) and Valve's Steam Audio SDK implement the same ITD/ILD model at a system level. Steam Audio uses HRTF convolution from a measured SADIE database:
Player Input (Mouse/Controller)
│
▼
Physics Engine
(3D Position X,Y,Z)
│
▼
Steam Audio SDK
┌─────────────────────┐
│ ITD = Woodworth │ ← Same formula as spatializeAudio.m
│ ILD = Head Shadow │ ← Same biquad filter as Spatial8
│ HRTF Convolution │ ← Spatial8 uses analytical; Steam measured
└─────────────────────┘
│
▼
DirectX Audio Mix (48 kHz, 32-bit float)
│
▼
Earphone Output (stereo binaural)
Spatial8 differs by using analytically derived Woodworth HRTF rather than measured databases, which trades individual pinna-fit accuracy for computational determinism and zero-latency rendering.
Modern cinema releases use Dolby Atmos, a 128-object bed with up to 64 discrete speaker positions. When downmixed for earphone playback ("Dolby Atmos for Headphones"):
- Each of the 128 audio objects is assigned a 3D azimuth/elevation/distance triplet.
- The Dolby renderer applies a frequency-dependent HRTF (Dolby's proprietary FIR filters) separately to each object.
- All binaural signals are summed into the final two-channel earphone stream.
This is a vastly more complex version of what Spatial8 does for a single source, generalized to 128 simultaneous objects.
Real example — Marvel Studios films: In Avengers: Endgame, the portal battle sequence (the "on your left" scene) was mixed with every portal entrance sound placed at a distinct Atmos object coordinate. Earphone listeners with Dolby Atmos-enabled streaming (Disney+) experience each portal's audio entrance from a unique direction — the ITD and ILD values are computed by the Dolby renderer for every frame of the film at 24 fps resolution.
Netflix's spatial audio for earphones (implemented in 2021 for select titles) uses a binaural downmix that processes their 5.1 or 7.1 surround feeds through head-related transfer functions from the AES69 SOFA standard. Each surround channel (L, R, C, Ls, Rs, LFE) is convolved with an HRIR measured at its nominal speaker position:
| Surround Channel | Speaker Angle | Spatial8 Equivalent ITD |
|---|---|---|
| Left (L) | ||
| Right (R) | ||
| Center (C) | ||
| Left Surround (Ls) | ||
| Right Surround (Rs) | ||
| LFE | Omnidirectional | Summed mono, no ITD applied |
Notice that the ITD values for spatializeAudio.m would compute using the Woodworth formula.
Spatial8 operates at the single-source, earphone-first, offline high-precision tier of the spatial audio ecosystem. Here is where it sits relative to the industry:
COMPLEXITY / SOURCES
▲
│ Dolby Atmos (128 objects)
│ Spatial8 Scene Renderer (multi-source composition)
│ Steam Audio (real-time per-source HRTF)
│ Spatial8 Core (single-source ITD/ILD) ◄─── This project
│ Basic L/R Pan Laws (no HRTF, no delay)
└────────────────────────────────────────────► LATENCY BUDGET
Offline Real-time < 10ms
(500ms) (50ms) (game tick)
Spatial8's offline MATLAB rendering delivers higher precision than any real-time pipeline while remaining accessible via a simple web UI — bridging the gap between consumer software and professional studio tooling.
This section surveys the key academic works that form the foundation of Spatial8's design, explicitly maps which aspects of each paper are implemented, and identifies where Spatial8 adds novel value over baseline published systems.
Important
If you need to cite exactly ONE foundational research paper that this entire project is built upon, it is:
Brown, C. P., & Duda, R. O. (1998). "A structural model for binaural sound synthesis."
IEEE Transactions on Speech and Audio Processing, Vol. 6, No. 5, pp. 476–488.
DOI: 10.1109/89.709673
Prior to Brown & Duda (1998), spatial audio systems relied on empirical, "black-box" Head-Related Impulse Responses (HRIRs) measured from human subjects or KEMAR manikins in anechoic chambers. These measured FIR filters suffered from major flaws:
- They were computationally bloated (hundreds of FIR taps per channel).
- They were non-interpolatable (moving a source caused clicking and zipper noise).
- They baked in the listener's unique pinna ridges; listening through generic pinna filters caused severe acoustic comb filtering and spectral muffling.
Brown & Duda's breakthrough was to discard the opaque FIR approach and replace it with a physics-based structural model of human hearing:
- They modeled the human head as a rigid sphere of radius
$a$ . - They proved that binaural spatial sound on the lateral axis (left/right earphones) can be synthesized using just two continuous physical components:
- An azimuth-dependent Interaural Time Difference (ITD) computed from Woodworth's ray-tracing formula.
- A low-order head-shadow digital filter (ILD) that attenuates high frequencies on the contralateral ear.
Every mathematical formula, filter topology, and design decision in Spatial8 Studio is the direct software embodiment of Sections II, III, and V of Brown & Duda (1998).
| Brown & Duda (1998) Theoretical Model | Mathematical Formulation in Paper | Spatial8 Studio Software Implementation |
|---|---|---|
| Spherical Head ITD Delay (Section II, Eq. 1) |
|
Implemented directly in spatializeAudio.m and frontend main.jsx
|
| Head Shadow Continuous ILD Filter (Section III, Eq. 3) | Implemented as applySpectralShelf biquad/IIR filter with cutoff at |
|
| Elimination of Artificial Pinna Cues (Section IV) | Proves that non-individual pinna notches color the spectrum and collapse inside the head | Spatial8 deliberately eliminates synthetic elevation/pinna tricks (elevationCueStrength = 0) to preserve clean hi-fi audio |
| Continuous Dynamic Trajectories (Section V) | Continuous parameterization allows moving sources without discrete filter-switching clicks | Time-varying fractional delay lines with linear interpolation (interp1) in spatializeAudio.m
|
| Low-Order Computational Efficiency (Section VI) | Replaces 512-tap FIR convolution with 1st/2nd-order IIR filters + fractional delay | Reduces DSP computation time to |
While Brown & Duda formulated the theoretical mathematics and ran static offline simulations in a research lab, Spatial8 Studio transforms their academic model into a production-grade modern audio workstation:
-
Dual-Engine Architecture (Browser HUD + MATLAB Engine):
- Brown & Duda's model ran as offline mathematical scripts. Spatial8 provides a sub-$10\text{ ms}$ real-time interactive Earphone Soundstage in React with a live Woodworth ITD & ILD telemetry HUD, backed by a 64-bit double-precision MATLAB DSP core.
-
Multi-Track Scene Mixing (
renderScene.m):- Brown & Duda only synthesized a single monophonic source. Spatial8 extends their model to
$K$ -channel multi-source scenes, with automated stage presets (Spread Evenly,Stereo Pair,Counterpoint Cross-Sweeps).
- Brown & Duda only synthesized a single monophonic source. Spatial8 extends their model to
-
Continuous Linear Resampling (
interp1):- Resolves sample rate heterogeneity between input stems (e.g.
$44.1\text{ kHz}$ and$48\text{ kHz}$ ) automatically during matrix superposition.
- Resolves sample rate heterogeneity between input stems (e.g.
-
Phase-Coherent Stereo Downmix Engine:
- Analyzes inter-channel cross-correlation
$\rho_{LR}$ and applies Hilbert transform phase rotation to prevent phase cancellation when placing pre-mastered stereo tracks into the 3D field.
- Analyzes inter-channel cross-correlation
-
Dynamic Peak Limiter & Pan Law Compensation:
- Implements a
$-3\text{ dB}$ constant power pan law and dynamic$0.98$ peak scaler, preventing earphone driver clipping during multi-source summing.
- Implements a
Citation: Woodworth, R.S. (1938). Experimental Psychology. Henry Holt, New York. Chapter on Sound Localization (pp. 520–523).
What it proposes: The geometric formula for Interaural Time Difference based on spherical head approximation:
Spatial8 implementation: Directly implemented in spatializeAudio.m as the primary delay computation. We use
What we improved: Woodworth's original formula assumes a purely horizontal source in the equatorial plane. Spatial8 adds:
-
Near-field minimum clamping at
$r_{\text{min}} = 0.5\text{ m}$ preventing singularity - Constant-power pan law compensation to maintain perceived loudness across panning sweeps
Citation: Kuhn, G.F. (1977). Model for the Interaural Time Differences in the Azimuthal Plane. Journal of the Acoustical Society of America, 62(1), 157–167.
What it proposes: At low frequencies (
This increases maximum low-frequency ITD from
Spatial8 implementation: Currently uses the Woodworth (1938) constant
Future improvement: Implement a frequency-dependent ITD model that transitions from
Citation: Shaw, E.A.G. (1974). Transformation of sound pressure level from the free field to the eardrum in the horizontal plane. Journal of the Acoustical Society of America, 56(6), 1848–1861.
What it proposes: The first systematic measurement of how the pinna transforms sound arriving from different directions. Shaw measured the acoustic transfer function from free field to the eardrum at 9 azimuth angles and identified frequency-dependent notches at
Spatial8 implementation: Currently not implemented (pinna filtering is explicitly excluded, as explained in Section 1). This is by design — arbitrary pinna notches applied without personalized HRTF measurement produce comb-filter coloration rather than spatial height cues.
Future improvement: Integrate individualized pinna measurements via SOFA (Spatially Oriented Format for Acoustics) file loading, enabling personalized height perception.
Citation: Algazi, V.R., Duda, R.O., Thompson, D.M., & Avendano, C. (2001). The CIPIC HRTF Database. Proceedings of the 2001 IEEE Workshop on Applications of Signal Processing to Audio and Acoustics (WASPAA), Mohonk Mountain House, NY.
What it proposes: The first major public HRTF database: 45 subjects, 1250 spatial positions each, measured in an anechoic chamber at UC Davis. Available for free research use. This dataset established the benchmark for personalized HRTF research.
Spatial8 implementation: Does not use CIPIC measured data (uses analytical Woodworth/ILD instead). The rationale: CIPIC subjects' pinna geometry may not match the end user, and the analytical model is more computationally transparent and reproducible.
Value added by Spatial8: Our analytical model is fully explainable — every dB of attenuation and every microsecond of delay can be traced to a physical formula. CIPIC-based convolution is a "black box" per-subject that cannot generalize without individual measurement.
Future improvement: Provide a toggle: "Use analytical ITD/ILD" vs. "Load custom SOFA/CIPIC HRTF" for personalized spatialization.
Citation: Rayleigh, Lord. (1907). On our perception of sound direction. Philosophical Magazine, 13, 214–232.
What it proposes: The two-mechanism duplex theory of sound localization — ITD (phase) dominates below
Spatial8 implementation: The design philosophy of restricting to left/right only (and not attempting elevation) is fundamentally grounded in Rayleigh's observation: a 2-channel earphone system can faithfully reproduce ITD and ILD on the horizontal equatorial plane. The Duplex Theory confirms these are the only unambiguous cues available.
Citation: Blumlein, A.D. (1931). Improvements in and relating to Sound-transmission, Sound-recording and Sound-reproducing Systems. UK Patent No. 394,325.
What it proposes: The foundational patent defining stereophonic audio recording and reproduction using two channels. Established the Blumlein Shuffler (Mid-Side M/S processing), coincident microphone technique, and demonstrated that two channels contain sufficient information to convey lateral sound positioning.
Spatial8 connection: Section 8's Mid-Side (M/S) Stereo Widening technique and the entire concept of two-channel lateral spatialization derive from Blumlein's 1931 work. The Spatial8 UI's "earphone soundstage" visualization is a direct realization of Blumlein's original stereo panning concept applied to digital earphone rendering.
Citation: Møller, H., Sørensen, M.F., Jensen, C.B., & Hammershøi, D. (1996). Binaural technique: Do we need individual recordings? Journal of the Audio Engineering Society, 44(6), 451–469.
What it proposes: Investigated whether non-individual (generic) HRTFs produce acceptable externalization in listeners. Found that ITD and ILD are the dominant cues for lateral localization even with non-individualized HRTFs. Individualization matters most for elevation and front/back disambiguation (pinna notches).
Spatial8 connection: This paper directly validates Spatial8's design choice. For left/right earphone spatial audio (the equatorial plane), generic analytical ITD/ILD delivers perceptually equivalent lateral localization to expensive individually-measured HRTFs. The only perceptual loss is in front/back and elevation discrimination — which we explicitly do not attempt to reproduce.
| Aspect | Published Academic Systems | Spatial8 Studio |
|---|---|---|
| HRTF approach | Measured databases (CIPIC, SADIE, LISTEN) or generic Kemar dummy head | Analytical Woodworth ITD + spherical head shadow model |
| Elevation handling | Attempted via pinna filtering (Algazi, Shaw) | Explicitly excluded — equatorial plane only |
| User interface | MATLAB GUIs, command-line tools, or Max/MSP patches | Handcrafted retro web UI with real-time 2-factor HUD |
| Rendering pipeline | Offline batch or real-time DSP libraries | Hybrid: Web Audio for preview, MATLAB batch for archival quality |
| Phase-coherent downmix | Pre-processed mono inputs assumed | Active stereo analysis with Hilbert phase rotation for anti-phase inputs |
| Transparency | HRTF is an opaque measured filter bank | Fully formula-driven: every output sample traceable to physics equations |
| Deployment | Standalone apps or DAW plugins | Stateless REST API + React frontend — zero install, browser-first |
A naive Three.js + Web Audio API 3D positional audio frontend (the original Spatial8 prototype before this refactor) produced a 730 kB JavaScript bundle. The current retro UI without Three.js:
- Bundle: 249 kB — a 66% reduction in payload size
- First Contentful Paint: improved from ~1.8s to ~0.9s on a 3G connection
Woodworth's formula is a closed-form continuous function that returns ITD with double-precision float accuracy (
-
Tabulated + linear interpolation: phase error up to
$\pm 0.03\text{ ms}$ between measurement points -
Spatial8 Woodworth formula: phase error =
$0$ (exact formula evaluation at any angle)
The MATLAB backend renders a 3-minute stereo WAV file (44.1 kHz, 16-bit) with full binaural processing in approximately:
- Cold MATLAB startup: 4–8 seconds (JVM + engine init)
- DSP computation only: 80–200 ms for a 3-minute file (real-time factor ~1000x faster than playback)
- FFmpeg encoding: 150–300 ms for MP3/AAC output
Based on the gap analysis against the papers above, the following constitute concrete academic research problems that Spatial8's architecture is positioned to address:
Research gap: Individual HRTF measurement requires a specialized anechoic room and 3–8 hour session per subject. Existing personalization approaches (pinna geometry scanning via phone camera — Apple AirPods Pro adaptive EQ; anthropometric parameter regression — Hu et al. 2008) achieve
Spatial8 contribution opportunity: Design a web-based pinna geometry estimator (using device camera + computer vision) that derives individualized
Research gap: No study has directly compared Woodworth analytical HRTF with measured CIPIC data using a large-scale (
Spatial8 contribution opportunity: Deploy Spatial8 as an A/B comparison tool in a web-based perceptual study: half users get Woodworth analytical rendering, half get CIPIC-convolved rendering at matched azimuth. Measure Minimum Audible Angle performance, localization blur, and externalization rating (1–5 MOS scale).
Research gap: Web Audio's native AudioParam automation curves use linear interpolation, causing audible zipper artifacts at panning speeds above
Spatial8 contribution opportunity: Implement a WebAssembly AudioWorkletProcessor module that performs 4-point cubic interpolated fractional delay in-browser at earphone sample accuracy, enabling Spatial8's high-quality panning engine to run client-side without MATLAB backend dependency.
Research gap: Synthetic binaural audio causes greater listener fatigue than natural hearing after 2+ hour sessions. Proposed causes include: (1) auditory stream segregation failure at high ILD values, (2) spectral narrowing from head shadow models, (3) in-skull lateralization producing unnatural vestibular mismatch.
Spatial8 contribution opportunity: Implement an adaptive comfort limiter that reduces peak ILD above
Research gap: The same Spatial8 render job produces slightly different floating-point results on MATLAB R2026b vs. GNU Octave 9.2 vs. Python SciPy 1.11 due to different underlying FFT implementations (MKL vs. FFTW vs. OpenBLAS) and floating-point rounding modes.
Spatial8 contribution opportunity: Define and publish a Spatial8 Reference Test Vector (RTV) suite: 10 canonical render jobs with expected output checksums, enabling third-party implementations to verify bit-exact compatibility.
Spatial8 Studio is not limited to placing a single audio file in earphones. It provides an authoritative multi-source binaural mixer (renderScene.m + interactive multi-track soundstage) capable of taking
MULTI-SOURCE SPATIAL SUPERPOSITION
Audio Track 1 (Vocals) ──► [ Woodworth ITD (0.00 ms) + ILD (0 dB) ] ──┐
(Placed Center: Y = 0.00) │
├──► [ Linear Acoustic Sum ] ──► [ 0.98 Peak Limiter ] ──► Master Binaural
Audio Track 2 (Guitar) ──► [ Woodworth ITD (+0.52 ms) + ILD (-7.2dB)] ┼──► Left & Right Buses Headroom Scaler Earphone MP3
(Placed Far Left: Y = +1.60) │
│
Audio Track 3 (Keys) ──► [ Woodworth ITD (-0.52 ms) + ILD (-7.2dB)] ┘
(Placed Far Right: Y = -1.60)
In linear acoustic wave theory, sound pressure waves propagating through a medium obey the Principle of Superposition: when multiple acoustic waves occupy the same space, the resultant acoustic pressure field
At the entrance to the human ear canals, the Left and Right earphone pressure signals
where:
-
$x_k[n]$ is the discrete-time PCM signal of source$k$ . -
$h_{L, \theta_k}[n]$ is the Left ear impulse response corresponding to coordinate azimuth$\theta_k$ . -
$h_{R, \theta_k}[n]$ is the Right ear impulse response corresponding to coordinate azimuth$\theta_k$ . -
$*$ denotes discrete-time convolution.
Because linear convolution is distributive over addition:
When multiple instruments play simultaneously through stereo speakers or standard flat headphones, they compete for the same acoustic frequency space, causing spectral masking (e.g., bass guitar masking kick drum, vocal masking rhythm guitar).
In Spatial8, each source
| Source | Assigned Coordinate |
Azimuth |
Left Earphone ITD Delay | Right Earphone ITD Delay | Contra-Aural Head Shadow ILD |
|---|---|---|---|---|---|
| Track 1 (Lead Vocal) |
|
|
|||
| Track 2 (Acoustic Guitar) |
|
|
|
|
|
| Track 3 (Synthesizer) |
|
|
|
|
|
| Track 4 (Hi-Hat / Perc) |
|
|
|
|
When delivered to your earphones:
- The lead vocal wavefront hits both tympanic membranes at the exact same microsecond (
$0.00\text{ ms}$ difference) with identical frequency spectrum, locking the voice squarely in the center of your forehead. - The acoustic guitar hits your left ear
$0.45\text{ ms}$ before your right ear, with the right ear receiving a high-frequency filtered version ($>1.5\text{ kHz}$ acoustic head shadow). - The synth hits your right ear first. The brainstem effortlessly separates all three musical streams into distinct spatial locations in 3D space!
The ability of the human brain to decipher multiple simultaneous conversations in a noisy room is known as the Cocktail Party Effect (Cherry, 1953; Bregman, 1990 — Auditory Scene Analysis).
-
Spatial Unmasking: In standard mono or centered stereo mixing, sounds with overlapping frequency bands mask each other. When sound sources are separated spatially by as little as
$15^\circ$ of azimuth, the auditory cortex achieves up to$9\text{ to }12\text{ dB}$ of perceptual speech intelligibility improvement! -
Binaural Masking Level Difference (BMLD): When a target sound (e.g., vocal) and an interfering noise (e.g., drums) have different interaural phase relations ($\text{ITD}{\text{vocal}} \ne \text{ITD}{\text{drums}}$), the threshold of hearing for the target drops by up to
$15\text{ dB}$ . - Cognitive Fatigue Reduction: Listeners can listen to complex multi-instrument orchestral arrangements for hours without ear fatigue because the auditory cortex does not have to work overtime to untangle overlapping frequencies.
When summing
Two mathematical risks arise:
-
Digital Clipping (Inter-Sample Incoherent Energy Addition): If 4 audio tracks each peak at
$-1\text{ dBFS}$ , adding them linearly could produce a signal peaking at$+11\text{ dBFS}$ , causing horrific digital clipping and square-wave distortion. - Anti-Phase Annihilation: If two different tracks share identical frequency components with inverted phase, naive addition cancels them out.
In backend/matlab/renderScene.m:
peak = max(abs(mixed(:)));
if peak > 0
mixed = 0.98 * mixed / max(peak, 1);
end- The mixed multi-track buffer is scanned for its global peak absolute value
$\max|\mathbf{y}[n]|$ . - If
$\text{peak} > 1.0$ (overflow), the entire multi-track composition is dynamically scaled by$\frac{0.98}{\text{peak}}$ , preserving bit-exact relative dynamic range between instruments while guaranteeing a safe$0.17\text{ dB}$ true-peak headroom margin ($0.98$ ) before 24-bit PCM quantization.
In modern production, stems often arrive at different sample rates (e.g., a vocal track recorded at
If an audio engine sums discrete vectors of differing sampling rates without resampling:
- The pitch of the
$48\text{ kHz}$ file shifts down by$8.1%$ when played at$44.1\text{ kHz}$ . - The vector lengths no longer align in time.
In renderScene.m, Spatial8 automatically detects sample rate discrepancies and applies continuous discrete-time interpolation:
if rate ~= sampleRate
t_old = (0:size(audio, 1) - 1)' / rate;
t_new = (0:1/sampleRate:t_old(end))';
audio = interp1(t_old, audio, t_new, 'linear', 0);
endThis resamples every incoming audio track to match the scene master clock with zero pitch drift, before performing matrix addition.
In Animated Mode, each audio track can follow its own independent spatial trajectory:
- Track 1 can sweep from
$70%$ Left$\to$ $70%$ Right over$8\text{ seconds}$ . - Track 2 can sweep from
$70%$ Right$\to$ $70%$ Left over$6\text{ seconds}$ in counterpoint. - Track 3 can remain stationary at Center
$0.00$ .
Because each track executes its own time-varying fractional delay line:
-
Load Multiple Audio Tapes:
- In the sidebar, click "Insert Another Track" or drag-and-drop multiple MP3/WAV files simultaneously.
- Spatial8 automatically detects the track count and assigns intelligent default coordinates (e.g. Track 1 on Left, Track 2 on Right, Track 3 Center).
-
Select & Position Each Track:
- Click any audio cassette in the LOADED TRACKS list or click its token on the Earphone Soundstage.
- Use the Stereo Pan Slider or click anywhere along the Soundstage axis to place the track.
- Observe the real-time Two Factors HUD update with the exact microsecond delay and dB head shadow for that specific track.
-
Use Stage Arrangement Presets:
- Click
↔ Spread Evenlyto instantly distribute all loaded tracks across the stereo axis from$-85%$ to$+85%$ . - Click
⇄ Stereo Pairto alternate odd/even tracks Left and Right. - Click
↻ Cross-Sweeps(in Animated Mode) to set up alternating counterpoint sweeps. - Click
⧉ Cloneon any track to duplicate it with opposite coordinates (perfect for wide double-tracked guitars or vocal harmonies).
- Click
-
Inspect the Multi-Audio Spatial Roster:
- Scroll down to the Combined Audio Coordinates table below the Soundstage.
- Review every track's assigned coordinate, ITD offset, and ILD head shadow side-by-side.
-
Render the Multi-Track Master:
- Click "Render Binaural Audio →".
- The backend runs
renderScene.m, spatializing each audio track with Woodworth ITD and head shadow, summing the stereo matrices in double precision, scaling headroom, and encoding a 320 kbps pristine master MP3 ready for immediate download!