Prototype Core
This prototype translates the organology of brass instruments into a web interface structured around three axes:
- Lip + hand complex as interface
- Harmonic series + valves as pitch engine
- Brassness as a live timbral metric
The scene is designed with the lips centered and cropped, over a sensing grid (pressure, position, emission) and a visual cone along the Z-axis representing the virtual horn uncoiled.
I. Camera Space → Mask Space Mapping
The object-fit: cover Problem
MediaPipe FaceMesh returns landmarks in normalized coordinates [0,1]2 relative to the native video stream frame.
The <video> element, however, is rendered using object-fit: cover, which scales the stream to fill the element, symmetrically cropping edges. This introduces a non-trivial discontinuity between stream space and viewport space.
Let:
-(vw,vh) = native stream resolution in pixels
-(ew,eh) = video element size (= viewport size)
The cover scale factor is:
scover=max(vwew, vheh)
The cropped pixels per side are:
cx=2vw−ew/scover,cy=2vh−eh/scover
Normalized crop fractions:
fx=vwcx=2vwvw−ew/scover,fy=vhcy
The visible stream range in normalized coordinates is:
[fx, 1−fx]×[fy, 1−fy]
with visible width and height:
wvis=1−2fx,hvis=1−2fy
Given a MediaPipe landmark (m_x, m_y) \in [0,1]^2, the final canvas pixel position (p_x, p_y) is computed as follows:
Step 0 — Center Calibration
cx′=mx−δx,cy′=my−δy
where (δx,δy) is the calibration offset
Step 1 — Cover Crop Correction
ex=wviscx′−fx,ey=hviscy′−fy
This maps the visible stream region linearly to [0,1].
Step 2 — Horizontal Mirror (scaleX(-1))
μx=1−ex
Step 3 — Zoom Around Center
px=(0.5+(μx−0.5)⋅z)⋅W
py=(0.5+(ey−0.5)⋅z)⋅H
where:
- z = CSS zoom factor
- (W, H) = ew×eh
Why Work in Normalized Space?
All operations are performed entirely in normalized coordinates.
Previous incorrect formulations mixed pixel-space and normalized-space corrections, effectively applying the crop compensation twice.
The correct approach applies scaling exactly once as a fraction.
II. Lip Model — 1-DOF Oscillator
Physical Basis
The lips in brass playing can be modeled as a damped mass-spring oscillator:
y¨+Qlωly˙+ωl2(y−y0)=mlFeff
where:
- ωl=2πfl
- Ql = quality factor
- y0 = resting aperture
- Feff = net force (air pressure − muscular tension)
Embouchure as Continuous Parameter
Lip geometry yields:
ξ=d61,291d13,14
ξ∈[0,1]
Smallξ → tight lips → high register
Largeξ→ open lips → low/pedal register
Lip frequency follows:
fl=fl,0Tl/Tl,0
Tension Tl is approximated inversely to ξ.
Fractional Harmonic Interpolation
Harmonic series:
fn=nftube
User trains pairs (ξk,nk).
Interpolation:
- Sort by ξk
- Find interval
- Linear parameter:
t=ξk+1−ξkξ−ξk
- Smooth S-curve:
t~=t2(3−2t)
- Fractional partial:
nξ=nk+t~(nk+1−nk)
First-order smoothing:
n˙=τnξ−nτ=80 ms
Resulting synthesis frequency:
f0=ftube⋅n
This enables continuous glissandi.
III. Additive Synthesis Engine
Audio Graph
oscillators→HP→peak EQ→LP→master→analyser→{drywet
Register-Dependent Brassiness
Normalized partial:
pn=clamp(n/8, 0.125, 1.5)
Brassiness factor:
Bp=clamp(0.9e−2.5(pn−0.125)+0.2pn1.8+0.15)
Octave Darkening
Doct=clamp(1.5−0.8pn, 0.5, 1.5)
Lowpass Cutoff
fcut=280+Pm⋅3200Doct+Bs⋅800Bp+[boost]⋅1400
Spectral Roll-Off
αh=0.3+0.5Pm−0.25Bp
Ah∝h−αh
Odd Harmonic Emphasis
Ahadj={Ah(1+0.6Bp)Ah(1−0.2Bp)h oddh even
IV. Cubic-Root Companding for Mic Gate
Motivation
RMS values typically lie in:
[0.001,0.06]
Linear mapping compresses usable range.
Companding
ρcomp=RMS1/3
Intensity normalization:
ρint=clamp(1.8ρcomp−0.04, 0, 1)
Raw weight:
wraw=clamp(0.78ρint+0.22χ, 0, 1)
Adaptive Noise Floor
ηk+1=ηk+0.025(min(0.25,wraw)−ηk)
Final Gate
d0=clamp(wraw−η−0.005, 0, 1)
d=d00.65
User threshold T:
a=1−Td−T
Exponent:
ε=0.45+0.55T
gopen=aε
Soft pre-trigger:
p=0.4Td−0.6T
gbelow=0.18p1.4
V. Mouth Center Calibration
Calibration key [C]:
δx=xˉmouth−0.5
δy=yˉmouth−0.5
CSS shift:
Tx=δxzW
Ty=−δyzH
VI. Synthetic Impulse Response
IR(t)=(2u−1)e−6t/τr+∑kakδ(t−tk)
Early reflections:
| k | t_k ms | a_k L/R |
|---|
| 1 | 18 | 0.70 / 0.60 |
| 2 | 32 | 0.43 / 0.50 |
| 3 | 55 | 0.35 / 0.35 |
VII. Mobile Camera & Mic Acquisition
Fallback order:
exact deviceId
→ ideal deviceId
→ facingMode: user
→ video: true
Unified device listener:
navigator.mediaDevices.addEventListener('devicechange', async () => {
await this.refreshCameraInputs();
await this.refreshMicInputs();
});
VIII. Valve Mapping
Effective tube length:
Leff=L0∏k=142vksk/12
Tube frequency:
ftube=2Leffc
IX. Web Instrument Paradigm
The innovation is not additive synthesis.
The innovation is the control channel:
Camera → Lip Geometry → Fractional Harmonics → Timbral Field
The web browser becomes:
- A lip amplifier
- A high-dimensional gestural interface
- A programmable brass organology
X. Spectral Metrics
Centroid:
C=∑∣Xk∣2∑fk∣Xk∣2
Harmonicity:
H=total energyharmonic energy
Brassiness index:
Bs=0.6CrefC+0.4(1−H)
XI. Roadmap
- Full FaceMesh integration
- Calibrated tube-length tables
- Instrument switching (tuba / trumpet)
- Karplus–Strong mode
- Session export (JSON / extended MIDI)