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">
|
||||
<span class="label">Binaural / Spatial DSP</span>
|
||||
<span class="description"
|
||||
>Multichannel HRTF rendering for Atmos & 3D Audio, crossfeed
|
||||
for stereo</span
|
||||
>Multichannel HRTF rendering for Atmos & 3D Audio, crossfeed for
|
||||
stereo</span
|
||||
>
|
||||
</div>
|
||||
<label class="toggle-switch">
|
||||
|
|
@ -4173,11 +4173,7 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="binaural-dsp-container"
|
||||
id="binaural-dsp-container"
|
||||
style="display: none"
|
||||
>
|
||||
<div class="binaural-dsp-container" id="binaural-dsp-container" style="display: none">
|
||||
<div class="binaural-status" id="binaural-status">
|
||||
<span class="binaural-mode-label">Mode: Stereo</span>
|
||||
</div>
|
||||
|
|
@ -4186,16 +4182,11 @@
|
|||
<div class="info">
|
||||
<span class="label">Auto-enable for Spatial Audio</span>
|
||||
<span class="description"
|
||||
>Automatically activate when Atmos or 3D content is
|
||||
detected</span
|
||||
>Automatically activate when Atmos or 3D content is detected</span
|
||||
>
|
||||
</div>
|
||||
<label class="toggle-switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="binaural-auto-spatial-toggle"
|
||||
checked
|
||||
/>
|
||||
<input type="checkbox" id="binaural-auto-spatial-toggle" checked />
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
|
@ -4203,16 +4194,10 @@
|
|||
<div class="binaural-sub-setting">
|
||||
<div class="info">
|
||||
<span class="label">Crossfeed</span>
|
||||
<span class="description"
|
||||
>Simulate speaker presentation on headphones</span
|
||||
>
|
||||
<span class="description">Simulate speaker presentation on headphones</span>
|
||||
</div>
|
||||
<label class="toggle-switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="binaural-crossfeed-toggle"
|
||||
checked
|
||||
/>
|
||||
<input type="checkbox" id="binaural-crossfeed-toggle" checked />
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
|
@ -4237,9 +4222,7 @@
|
|||
</div>
|
||||
<select id="binaural-hrtf-preset">
|
||||
<option value="intimate">Intimate (±22°)</option>
|
||||
<option value="studio" selected>
|
||||
Studio (±30°)
|
||||
</option>
|
||||
<option value="studio" selected>Studio (±30°)</option>
|
||||
<option value="wide">Wide (±45°)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
@ -4248,16 +4231,11 @@
|
|||
<div class="info">
|
||||
<span class="label">Stereo Width</span>
|
||||
<span class="description"
|
||||
>Adjust spatial width (0 = mono, 1 = neutral, 2 =
|
||||
wide)</span
|
||||
>Adjust spatial width (0 = mono, 1 = neutral, 2 = wide)</span
|
||||
>
|
||||
</div>
|
||||
<label class="toggle-switch">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="binaural-widening-toggle"
|
||||
checked
|
||||
/>
|
||||
<input type="checkbox" id="binaural-widening-toggle" checked />
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
|
@ -4265,9 +4243,7 @@
|
|||
<div class="binaural-sub-setting" id="widening-slider-row">
|
||||
<div class="info">
|
||||
<span class="label">Width Amount</span>
|
||||
<span class="binaural-width-value" id="binaural-width-value"
|
||||
>1.0</span
|
||||
>
|
||||
<span class="binaural-width-value" id="binaural-width-value">1.0</span>
|
||||
</div>
|
||||
<input
|
||||
type="range"
|
||||
|
|
|
|||
|
|
@ -507,10 +507,7 @@ class AudioContextManager {
|
|||
|
||||
// Enable multichannel passthrough for Atmos/spatial content
|
||||
try {
|
||||
this.audioContext.destination.channelCount = Math.min(
|
||||
this.audioContext.destination.maxChannelCount,
|
||||
8
|
||||
);
|
||||
this.audioContext.destination.channelCount = Math.min(this.audioContext.destination.maxChannelCount, 8);
|
||||
this.audioContext.destination.channelCountMode = 'explicit';
|
||||
this.audioContext.destination.channelInterpretation = 'discrete';
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -232,7 +232,11 @@ export class BinauralDSP {
|
|||
*/
|
||||
_disconnectAll() {
|
||||
const sd = (node) => {
|
||||
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 },
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 ? ' <span class="binaural-badge">Binaural</span>' : '');
|
||||
badgeEl.innerHTML =
|
||||
SVG_ATMOS(20) + (binauralActive ? ' <span class="binaural-badge">Binaural</span>' : '');
|
||||
} else {
|
||||
// Notify binaural DSP that we're in stereo mode
|
||||
audioContextManager.notifyBinauralChannelCount(2);
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue