Tweak: blackout thresholds redo

This commit is contained in:
Dejvino 2026-01-04 17:42:06 +00:00
parent 997986917c
commit b2166fe26a

View File

@ -90,7 +90,7 @@ export class MusicVisualizer extends SceneFeature {
const loudness = state.music.loudnessLows || 0; const loudness = state.music.loudnessLows || 0;
const loudnessAvg = state.music.loudnessLowsAverage || 0; const loudnessAvg = state.music.loudnessLowsAverage || 0;
const songTime = state.music.player ? state.music.player.currentTime : 0; const songTime = state.music.player ? state.music.player.currentTime : 0;
this.averageLoudness = THREE.MathUtils.lerp(this.averageLoudness, loudnessAvg, deltaTime * (songTime < 5 ? 0.5 : 0.2)); this.averageLoudness = THREE.MathUtils.lerp(this.averageLoudness, loudnessAvg, deltaTime * (songTime < 5 ? 0.5 : 0.05));
state.music.averageLoudness = this.averageLoudness; state.music.averageLoudness = this.averageLoudness;
// --- Beat Detection & Auto-BPM --- // --- Beat Detection & Auto-BPM ---
@ -157,23 +157,17 @@ export class MusicVisualizer extends SceneFeature {
} }
// Dynamic Thresholds // Dynamic Thresholds
// The threshold to EXIT blackout. It should be a significant spike above the average loudness. // Enter blackout if loudness falls below 80% of average
// It starts high and decays, making it easier to exit the longer we're in blackout. let quietThreshold = this.averageLoudness * 0.8;
const loudSpikeModif = 1.2; // How much louder than average a "drop" needs to be.
let loudThreshold = this.averageLoudness * loudSpikeModif;
// loudThreshold = Math.max(this.averageLoudness + 0.1, loudThreshold - (timeInStateQuiet * 0.05));
// The threshold to ENTER blackout, based on a percentage of the song's average loudness. // Exit blackout if loudness returns to normal (average) or above
let quietThreshold = this.averageLoudness * 0.7; let loudThreshold = this.averageLoudness;
// quietThreshold = THREE.MathUtils.clamp(quietThreshold, 0.02, 0.3); // Clamp to a reasonable range.
// --- Auto-Blackout Logic --- // --- Auto-Blackout Logic ---
// If blackout is active, monitor for loud events (The Drop) to disable it. // If blackout is active, monitor for loud events (The Drop) to disable it.
if (state.config.blackout) { if (state.config.blackout) {
const beatThreshold = 0.7;
if (state.blackoutMode) { if (state.blackoutMode) {
if (loudness > loudThreshold && state.music.beatIntensity > beatThreshold) { if (loudness >= loudThreshold) {
state.blackoutMode = false; state.blackoutMode = false;
} }
} else { } else {