diff --git a/party-stage/src/scene/music-visualizer.js b/party-stage/src/scene/music-visualizer.js index d268005..d2480a1 100644 --- a/party-stage/src/scene/music-visualizer.js +++ b/party-stage/src/scene/music-visualizer.js @@ -90,7 +90,7 @@ export class MusicVisualizer extends SceneFeature { const loudness = state.music.loudnessLows || 0; const loudnessAvg = state.music.loudnessLowsAverage || 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; // --- Beat Detection & Auto-BPM --- @@ -157,23 +157,17 @@ export class MusicVisualizer extends SceneFeature { } // Dynamic Thresholds - // The threshold to EXIT blackout. It should be a significant spike above the average loudness. - // It starts high and decays, making it easier to exit the longer we're in blackout. - 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)); + // Enter blackout if loudness falls below 80% of average + let quietThreshold = this.averageLoudness * 0.8; - // The threshold to ENTER blackout, based on a percentage of the song's average loudness. - let quietThreshold = this.averageLoudness * 0.7; - // quietThreshold = THREE.MathUtils.clamp(quietThreshold, 0.02, 0.3); // Clamp to a reasonable range. + // Exit blackout if loudness returns to normal (average) or above + let loudThreshold = this.averageLoudness; // --- Auto-Blackout Logic --- // If blackout is active, monitor for loud events (The Drop) to disable it. if (state.config.blackout) { - const beatThreshold = 0.7; - if (state.blackoutMode) { - if (loudness > loudThreshold && state.music.beatIntensity > beatThreshold) { + if (loudness >= loudThreshold) { state.blackoutMode = false; } } else {