style: auto-fix linting issues
This commit is contained in:
parent
5bbc36cdb1
commit
ab23c3e64e
6 changed files with 81 additions and 68 deletions
46
index.html
46
index.html
|
|
@ -4163,8 +4163,8 @@
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<span class="label">Binaural / Spatial DSP</span>
|
<span class="label">Binaural / Spatial DSP</span>
|
||||||
<span class="description"
|
<span class="description"
|
||||||
>Multichannel HRTF rendering for Atmos & 3D Audio, crossfeed
|
>Multichannel HRTF rendering for Atmos & 3D Audio, crossfeed for
|
||||||
for stereo</span
|
stereo</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<label class="toggle-switch">
|
<label class="toggle-switch">
|
||||||
|
|
@ -4173,11 +4173,7 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div class="binaural-dsp-container" id="binaural-dsp-container" style="display: none">
|
||||||
class="binaural-dsp-container"
|
|
||||||
id="binaural-dsp-container"
|
|
||||||
style="display: none"
|
|
||||||
>
|
|
||||||
<div class="binaural-status" id="binaural-status">
|
<div class="binaural-status" id="binaural-status">
|
||||||
<span class="binaural-mode-label">Mode: Stereo</span>
|
<span class="binaural-mode-label">Mode: Stereo</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -4186,16 +4182,11 @@
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<span class="label">Auto-enable for Spatial Audio</span>
|
<span class="label">Auto-enable for Spatial Audio</span>
|
||||||
<span class="description"
|
<span class="description"
|
||||||
>Automatically activate when Atmos or 3D content is
|
>Automatically activate when Atmos or 3D content is detected</span
|
||||||
detected</span
|
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<label class="toggle-switch">
|
<label class="toggle-switch">
|
||||||
<input
|
<input type="checkbox" id="binaural-auto-spatial-toggle" checked />
|
||||||
type="checkbox"
|
|
||||||
id="binaural-auto-spatial-toggle"
|
|
||||||
checked
|
|
||||||
/>
|
|
||||||
<span class="slider"></span>
|
<span class="slider"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -4203,16 +4194,10 @@
|
||||||
<div class="binaural-sub-setting">
|
<div class="binaural-sub-setting">
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<span class="label">Crossfeed</span>
|
<span class="label">Crossfeed</span>
|
||||||
<span class="description"
|
<span class="description">Simulate speaker presentation on headphones</span>
|
||||||
>Simulate speaker presentation on headphones</span
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
<label class="toggle-switch">
|
<label class="toggle-switch">
|
||||||
<input
|
<input type="checkbox" id="binaural-crossfeed-toggle" checked />
|
||||||
type="checkbox"
|
|
||||||
id="binaural-crossfeed-toggle"
|
|
||||||
checked
|
|
||||||
/>
|
|
||||||
<span class="slider"></span>
|
<span class="slider"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -4237,9 +4222,7 @@
|
||||||
</div>
|
</div>
|
||||||
<select id="binaural-hrtf-preset">
|
<select id="binaural-hrtf-preset">
|
||||||
<option value="intimate">Intimate (±22°)</option>
|
<option value="intimate">Intimate (±22°)</option>
|
||||||
<option value="studio" selected>
|
<option value="studio" selected>Studio (±30°)</option>
|
||||||
Studio (±30°)
|
|
||||||
</option>
|
|
||||||
<option value="wide">Wide (±45°)</option>
|
<option value="wide">Wide (±45°)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -4248,16 +4231,11 @@
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<span class="label">Stereo Width</span>
|
<span class="label">Stereo Width</span>
|
||||||
<span class="description"
|
<span class="description"
|
||||||
>Adjust spatial width (0 = mono, 1 = neutral, 2 =
|
>Adjust spatial width (0 = mono, 1 = neutral, 2 = wide)</span
|
||||||
wide)</span
|
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<label class="toggle-switch">
|
<label class="toggle-switch">
|
||||||
<input
|
<input type="checkbox" id="binaural-widening-toggle" checked />
|
||||||
type="checkbox"
|
|
||||||
id="binaural-widening-toggle"
|
|
||||||
checked
|
|
||||||
/>
|
|
||||||
<span class="slider"></span>
|
<span class="slider"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -4265,9 +4243,7 @@
|
||||||
<div class="binaural-sub-setting" id="widening-slider-row">
|
<div class="binaural-sub-setting" id="widening-slider-row">
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<span class="label">Width Amount</span>
|
<span class="label">Width Amount</span>
|
||||||
<span class="binaural-width-value" id="binaural-width-value"
|
<span class="binaural-width-value" id="binaural-width-value">1.0</span>
|
||||||
>1.0</span
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="range"
|
||||||
|
|
|
||||||
|
|
@ -507,10 +507,7 @@ class AudioContextManager {
|
||||||
|
|
||||||
// Enable multichannel passthrough for Atmos/spatial content
|
// Enable multichannel passthrough for Atmos/spatial content
|
||||||
try {
|
try {
|
||||||
this.audioContext.destination.channelCount = Math.min(
|
this.audioContext.destination.channelCount = Math.min(this.audioContext.destination.maxChannelCount, 8);
|
||||||
this.audioContext.destination.maxChannelCount,
|
|
||||||
8
|
|
||||||
);
|
|
||||||
this.audioContext.destination.channelCountMode = 'explicit';
|
this.audioContext.destination.channelCountMode = 'explicit';
|
||||||
this.audioContext.destination.channelInterpretation = 'discrete';
|
this.audioContext.destination.channelInterpretation = 'discrete';
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,11 @@ export class BinauralDSP {
|
||||||
*/
|
*/
|
||||||
_disconnectAll() {
|
_disconnectAll() {
|
||||||
const sd = (node) => {
|
const sd = (node) => {
|
||||||
try { node?.disconnect(); } catch { /* */ }
|
try {
|
||||||
|
node?.disconnect();
|
||||||
|
} catch {
|
||||||
|
/* */
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sd(this.inputNode);
|
sd(this.inputNode);
|
||||||
|
|
@ -340,14 +344,25 @@ export class BinauralDSP {
|
||||||
|
|
||||||
_destroyCrossfeedNodes() {
|
_destroyCrossfeedNodes() {
|
||||||
const nodes = [
|
const nodes = [
|
||||||
this._cfSplitter, this._cfMerger,
|
this._cfSplitter,
|
||||||
this._cfDirectL, this._cfDirectR,
|
this._cfMerger,
|
||||||
this._cfCrossLR, this._cfCrossRL,
|
this._cfDirectL,
|
||||||
this._cfFilterLR, this._cfFilterRL,
|
this._cfDirectR,
|
||||||
this._cfDelayLR, this._cfDelayRL,
|
this._cfCrossLR,
|
||||||
|
this._cfCrossRL,
|
||||||
|
this._cfFilterLR,
|
||||||
|
this._cfFilterRL,
|
||||||
|
this._cfDelayLR,
|
||||||
|
this._cfDelayRL,
|
||||||
this._cfOutputNode,
|
this._cfOutputNode,
|
||||||
];
|
];
|
||||||
nodes.forEach((n) => { try { n?.disconnect(); } catch { /* */ } });
|
nodes.forEach((n) => {
|
||||||
|
try {
|
||||||
|
n?.disconnect();
|
||||||
|
} catch {
|
||||||
|
/* */
|
||||||
|
}
|
||||||
|
});
|
||||||
this._cfSplitter = null;
|
this._cfSplitter = null;
|
||||||
this._cfMerger = null;
|
this._cfMerger = null;
|
||||||
this._cfDirectL = null;
|
this._cfDirectL = null;
|
||||||
|
|
@ -416,7 +431,13 @@ export class BinauralDSP {
|
||||||
}
|
}
|
||||||
|
|
||||||
_destroyMultichannelNodes() {
|
_destroyMultichannelNodes() {
|
||||||
const sd = (n) => { try { n?.disconnect(); } catch { /* */ } };
|
const sd = (n) => {
|
||||||
|
try {
|
||||||
|
n?.disconnect();
|
||||||
|
} catch {
|
||||||
|
/* */
|
||||||
|
}
|
||||||
|
};
|
||||||
sd(this._mcSplitter);
|
sd(this._mcSplitter);
|
||||||
sd(this._mcMerger);
|
sd(this._mcMerger);
|
||||||
sd(this._mcLfeGain);
|
sd(this._mcLfeGain);
|
||||||
|
|
@ -499,15 +520,31 @@ export class BinauralDSP {
|
||||||
|
|
||||||
_destroyWidenerNodes() {
|
_destroyWidenerNodes() {
|
||||||
const nodes = [
|
const nodes = [
|
||||||
this._wSplitter, this._wOutputMerger,
|
this._wSplitter,
|
||||||
this._wMidL, this._wMidR, this._wSideL, this._wSideR,
|
this._wOutputMerger,
|
||||||
this._wMidGain, this._wSideGain,
|
this._wMidL,
|
||||||
this._wMidMix, this._wSideMix,
|
this._wMidR,
|
||||||
this._wDecoderMidToL, this._wDecoderSideToL,
|
this._wSideL,
|
||||||
this._wDecoderMidToR, this._wDecoderSideToR,
|
this._wSideR,
|
||||||
this._wLMix, this._wRMix, this._wOutputNode,
|
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._wSplitter = null;
|
||||||
this._wOutputMerger = null;
|
this._wOutputMerger = null;
|
||||||
this._wMidL = null;
|
this._wMidL = null;
|
||||||
|
|
@ -570,9 +607,11 @@ export class BinauralDSP {
|
||||||
await this._ensureNodesCreated();
|
await this._ensureNodesCreated();
|
||||||
this._connectInternal();
|
this._connectInternal();
|
||||||
|
|
||||||
window.dispatchEvent(new CustomEvent('binaural-mode-changed', {
|
window.dispatchEvent(
|
||||||
detail: { mode: this.mode, channels: channelCount },
|
new CustomEvent('binaural-mode-changed', {
|
||||||
}));
|
detail: { mode: this.mode, channels: channelCount },
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,7 @@ export async function generateHRTF(audioContext, azimuthDeg, elevationDeg = 0) {
|
||||||
const notchFreq = 8000 + elevationDeg * 50; // Shifts with elevation
|
const notchFreq = 8000 + elevationDeg * 50; // Shifts with elevation
|
||||||
const notchWidth = 2000;
|
const notchWidth = 2000;
|
||||||
const notchDepth = 0.15 * Math.abs(Math.sin(elevRad + 0.3));
|
const notchDepth = 0.15 * Math.abs(Math.sin(elevRad + 0.3));
|
||||||
const notchFactor =
|
const notchFactor = 1.0 - notchDepth * Math.exp(-Math.pow((freq - notchFreq) / notchWidth, 2));
|
||||||
1.0 - notchDepth * Math.exp(-Math.pow((freq - notchFreq) / notchWidth, 2));
|
|
||||||
|
|
||||||
const phase = 2 * Math.PI * freq * (t - ipsiDelay / sampleRate);
|
const phase = 2 * Math.PI * freq * (t - ipsiDelay / sampleRate);
|
||||||
sum += ((ipsiGain * notchFactor) / halfFFT) * Math.cos(phase);
|
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 shadowGain = calculateHeadShadow(freq, azimuthRad);
|
||||||
|
|
||||||
const phase = 2 * Math.PI * freq * (t - contraDelay / sampleRate);
|
const phase = 2 * Math.PI * freq * (t - contraDelay / sampleRate);
|
||||||
sum += ((shadowGain) / halfFFT) * Math.cos(phase);
|
sum += (shadowGain / halfFFT) * Math.cos(phase);
|
||||||
}
|
}
|
||||||
contraData[i] = sum;
|
contraData[i] = sum;
|
||||||
}
|
}
|
||||||
|
|
@ -134,9 +133,9 @@ export async function generateHRTF(audioContext, azimuthDeg, elevationDeg = 0) {
|
||||||
* HRTF angle presets for virtual speaker configurations.
|
* HRTF angle presets for virtual speaker configurations.
|
||||||
*/
|
*/
|
||||||
export const HRTF_PRESETS = {
|
export const HRTF_PRESETS = {
|
||||||
intimate: { label: 'Intimate', angleScale: 0.73 }, // ±22° front
|
intimate: { label: 'Intimate', angleScale: 0.73 }, // ±22° front
|
||||||
studio: { label: 'Studio', angleScale: 1.0 }, // ±30° front (standard)
|
studio: { label: 'Studio', angleScale: 1.0 }, // ±30° front (standard)
|
||||||
wide: { label: 'Wide', angleScale: 1.5 }, // ±45° front
|
wide: { label: 'Wide', angleScale: 1.5 }, // ±45° front
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1897,7 +1897,8 @@ export class Player {
|
||||||
|
|
||||||
const binauralActive = audioContextManager.isBinauralActive();
|
const binauralActive = audioContextManager.isBinauralActive();
|
||||||
badgeEl.className = 'quality-badge quality-atmos shaka-quality-badge';
|
badgeEl.className = 'quality-badge quality-atmos shaka-quality-badge';
|
||||||
badgeEl.innerHTML = SVG_ATMOS(20) + (binauralActive ? ' <span class="binaural-badge">Binaural</span>' : '');
|
badgeEl.innerHTML =
|
||||||
|
SVG_ATMOS(20) + (binauralActive ? ' <span class="binaural-badge">Binaural</span>' : '');
|
||||||
} else {
|
} else {
|
||||||
// Notify binaural DSP that we're in stereo mode
|
// Notify binaural DSP that we're in stereo mode
|
||||||
audioContextManager.notifyBinauralChannelCount(2);
|
audioContextManager.notifyBinauralChannelCount(2);
|
||||||
|
|
|
||||||
|
|
@ -1248,9 +1248,10 @@ export async function initializeSettings(scrobbler, player, api, ui) {
|
||||||
const { mode, channels } = e.detail;
|
const { mode, channels } = e.detail;
|
||||||
const label = statusEl.querySelector('.binaural-mode-label');
|
const label = statusEl.querySelector('.binaural-mode-label');
|
||||||
if (label) {
|
if (label) {
|
||||||
label.textContent = mode === 'multichannel'
|
label.textContent =
|
||||||
? `Mode: Multichannel (${channels > 6 ? '7.1' : '5.1'} → Binaural)`
|
mode === 'multichannel'
|
||||||
: 'Mode: Stereo';
|
? `Mode: Multichannel (${channels > 6 ? '7.1' : '5.1'} → Binaural)`
|
||||||
|
: 'Mode: Stereo';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue