diff --git a/index.html b/index.html index 473e9b7..c59aec1 100644 --- a/index.html +++ b/index.html @@ -4163,8 +4163,8 @@
Binaural / Spatial DSP Multichannel HRTF rendering for Atmos & 3D Audio, crossfeed - for stereoMultichannel HRTF rendering for Atmos & 3D Audio, crossfeed for + stereo
- @@ -4248,16 +4231,11 @@
Stereo Width Adjust spatial width (0 = mono, 1 = neutral, 2 = - wide)Adjust spatial width (0 = mono, 1 = neutral, 2 = wide)
@@ -4265,9 +4243,7 @@
Width Amount - 1.0 + 1.0
{ - try { node?.disconnect(); } catch { /* */ } + try { + node?.disconnect(); + } catch { + /* */ + } }; sd(this.inputNode); @@ -340,14 +344,25 @@ export class BinauralDSP { _destroyCrossfeedNodes() { const nodes = [ - this._cfSplitter, this._cfMerger, - this._cfDirectL, this._cfDirectR, - this._cfCrossLR, this._cfCrossRL, - this._cfFilterLR, this._cfFilterRL, - this._cfDelayLR, this._cfDelayRL, + this._cfSplitter, + this._cfMerger, + this._cfDirectL, + this._cfDirectR, + this._cfCrossLR, + this._cfCrossRL, + this._cfFilterLR, + this._cfFilterRL, + this._cfDelayLR, + this._cfDelayRL, this._cfOutputNode, ]; - nodes.forEach((n) => { try { n?.disconnect(); } catch { /* */ } }); + nodes.forEach((n) => { + try { + n?.disconnect(); + } catch { + /* */ + } + }); this._cfSplitter = null; this._cfMerger = null; this._cfDirectL = null; @@ -416,7 +431,13 @@ export class BinauralDSP { } _destroyMultichannelNodes() { - const sd = (n) => { try { n?.disconnect(); } catch { /* */ } }; + const sd = (n) => { + try { + n?.disconnect(); + } catch { + /* */ + } + }; sd(this._mcSplitter); sd(this._mcMerger); sd(this._mcLfeGain); @@ -499,15 +520,31 @@ export class BinauralDSP { _destroyWidenerNodes() { const nodes = [ - this._wSplitter, this._wOutputMerger, - this._wMidL, this._wMidR, this._wSideL, this._wSideR, - this._wMidGain, this._wSideGain, - this._wMidMix, this._wSideMix, - this._wDecoderMidToL, this._wDecoderSideToL, - this._wDecoderMidToR, this._wDecoderSideToR, - this._wLMix, this._wRMix, this._wOutputNode, + this._wSplitter, + this._wOutputMerger, + this._wMidL, + this._wMidR, + this._wSideL, + this._wSideR, + this._wMidGain, + this._wSideGain, + this._wMidMix, + this._wSideMix, + this._wDecoderMidToL, + this._wDecoderSideToL, + this._wDecoderMidToR, + this._wDecoderSideToR, + this._wLMix, + this._wRMix, + this._wOutputNode, ]; - nodes.forEach((n) => { try { n?.disconnect(); } catch { /* */ } }); + nodes.forEach((n) => { + try { + n?.disconnect(); + } catch { + /* */ + } + }); this._wSplitter = null; this._wOutputMerger = null; this._wMidL = null; @@ -570,9 +607,11 @@ export class BinauralDSP { await this._ensureNodesCreated(); this._connectInternal(); - window.dispatchEvent(new CustomEvent('binaural-mode-changed', { - detail: { mode: this.mode, channels: channelCount }, - })); + window.dispatchEvent( + new CustomEvent('binaural-mode-changed', { + detail: { mode: this.mode, channels: channelCount }, + }) + ); } } diff --git a/js/hrtf-generator.js b/js/hrtf-generator.js index b12dcf5..ebd577a 100644 --- a/js/hrtf-generator.js +++ b/js/hrtf-generator.js @@ -91,8 +91,7 @@ export async function generateHRTF(audioContext, azimuthDeg, elevationDeg = 0) { const notchFreq = 8000 + elevationDeg * 50; // Shifts with elevation const notchWidth = 2000; const notchDepth = 0.15 * Math.abs(Math.sin(elevRad + 0.3)); - const notchFactor = - 1.0 - notchDepth * Math.exp(-Math.pow((freq - notchFreq) / notchWidth, 2)); + const notchFactor = 1.0 - notchDepth * Math.exp(-Math.pow((freq - notchFreq) / notchWidth, 2)); const phase = 2 * Math.PI * freq * (t - ipsiDelay / sampleRate); sum += ((ipsiGain * notchFactor) / halfFFT) * Math.cos(phase); @@ -109,7 +108,7 @@ export async function generateHRTF(audioContext, azimuthDeg, elevationDeg = 0) { const shadowGain = calculateHeadShadow(freq, azimuthRad); const phase = 2 * Math.PI * freq * (t - contraDelay / sampleRate); - sum += ((shadowGain) / halfFFT) * Math.cos(phase); + sum += (shadowGain / halfFFT) * Math.cos(phase); } contraData[i] = sum; } @@ -134,9 +133,9 @@ export async function generateHRTF(audioContext, azimuthDeg, elevationDeg = 0) { * HRTF angle presets for virtual speaker configurations. */ export const HRTF_PRESETS = { - intimate: { label: 'Intimate', angleScale: 0.73 }, // ±22° front - studio: { label: 'Studio', angleScale: 1.0 }, // ±30° front (standard) - wide: { label: 'Wide', angleScale: 1.5 }, // ±45° front + intimate: { label: 'Intimate', angleScale: 0.73 }, // ±22° front + studio: { label: 'Studio', angleScale: 1.0 }, // ±30° front (standard) + wide: { label: 'Wide', angleScale: 1.5 }, // ±45° front }; /** diff --git a/js/player.js b/js/player.js index 1e23b6a..d484fe6 100644 --- a/js/player.js +++ b/js/player.js @@ -1897,7 +1897,8 @@ export class Player { const binauralActive = audioContextManager.isBinauralActive(); badgeEl.className = 'quality-badge quality-atmos shaka-quality-badge'; - badgeEl.innerHTML = SVG_ATMOS(20) + (binauralActive ? ' Binaural' : ''); + badgeEl.innerHTML = + SVG_ATMOS(20) + (binauralActive ? ' Binaural' : ''); } else { // Notify binaural DSP that we're in stereo mode audioContextManager.notifyBinauralChannelCount(2); diff --git a/js/settings.js b/js/settings.js index 958feb7..204684d 100644 --- a/js/settings.js +++ b/js/settings.js @@ -1248,9 +1248,10 @@ export async function initializeSettings(scrobbler, player, api, ui) { const { mode, channels } = e.detail; const label = statusEl.querySelector('.binaural-mode-label'); if (label) { - label.textContent = mode === 'multichannel' - ? `Mode: Multichannel (${channels > 6 ? '7.1' : '5.1'} → Binaural)` - : 'Mode: Stereo'; + label.textContent = + mode === 'multichannel' + ? `Mode: Multichannel (${channels > 6 ? '7.1' : '5.1'} → Binaural)` + : 'Mode: Stereo'; } } });