From 4d156074d2286b20519bde4e4b1e80ad3ff646de Mon Sep 17 00:00:00 2001 From: Vivek Rajput Date: Mon, 23 Nov 2026 22:26:12 +0530 Subject: [PATCH 1/3] fix: soften distorted Force Surge sound effect --- src/assets/js/script.js | 61 +++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 23 deletions(-) diff --git a/src/assets/js/script.js b/src/assets/js/script.js index 234c576a..c8845bb8 100644 --- a/src/assets/js/script.js +++ b/src/assets/js/script.js @@ -123,7 +123,7 @@ window.playSound = function playSound(type) { osc.start(now); osc.stop(now + 1.5); } else { - const config = LAYERED_SOUND_CONFIGS[type]; + const config = LAYERED_SOUND_CONFIGS[type]; if (!config) return; osc.type = config.oscillatorType; @@ -486,37 +486,52 @@ function playForceSoundtrack(duration = 8000) { initAudio(); if (!audioCtx) return; - // 1. Create a Master Compressor to prevent distortion + const now = audioCtx.currentTime; + const seconds = duration / 1000; + + // Master compressor: gentle settings to avoid pumping/crackle const compressor = audioCtx.createDynamicsCompressor(); - compressor.threshold.setValueAtTime(-24, audioCtx.currentTime); - compressor.knee.setValueAtTime(40, audioCtx.currentTime); - compressor.ratio.setValueAtTime(12, audioCtx.currentTime); - compressor.attack.setValueAtTime(0, audioCtx.currentTime); - compressor.release.setValueAtTime(0.25, audioCtx.currentTime); + compressor.threshold.setValueAtTime(-24, now); + compressor.knee.setValueAtTime(30, now); + compressor.ratio.setValueAtTime(4, now); + compressor.attack.setValueAtTime(0.01, now); + compressor.release.setValueAtTime(0.25, now); compressor.connect(audioCtx.destination); - const now = audioCtx.currentTime; - const masterGain = audioCtx.createGain(); - masterGain.connect(compressor); + // Lowpass filter: removes harsh high frequencies + const filter = audioCtx.createBiquadFilter(); + filter.type = "lowpass"; + filter.frequency.setValueAtTime(800, now); + filter.connect(compressor); - // Smooth volume swell - masterGain.gain.setValueAtTime(0, now); - masterGain.gain.linearRampToValueAtTime(0.6, now + 1.5); - masterGain.gain.setValueAtTime(0.6, now + duration / 1000 - 2); - masterGain.gain.exponentialRampToValueAtTime(0.001, now + duration / 1000); + // Master volume: smooth swell in and fade out + const masterGain = audioCtx.createGain(); + masterGain.connect(filter); + masterGain.gain.setValueAtTime(0.0001, now); + masterGain.gain.linearRampToValueAtTime(0.25, now + 1.5); + masterGain.gain.setValueAtTime(0.25, now + seconds - 2); + masterGain.gain.exponentialRampToValueAtTime(0.001, now + seconds); + + // Harmonic stack: each oscillator has its own small gain so the sum never clips + const layers = [ + { freq: 55, type: "triangle", level: 0.5 }, + { freq: 110, type: "triangle", level: 0.3 }, + { freq: 164.81, type: "sine", level: 0.3 }, + ]; - // Create the "Harmonic Stack" (Multiple notes for a rich sound) - [55, 110, 164.81].forEach((freq, i) => { + layers.forEach(({ freq, type, level }, i) => { const osc = audioCtx.createOscillator(); - osc.type = i === 0 ? "sawtooth" : "triangle"; // Mix textures - osc.frequency.setValueAtTime(freq, now); + const oscGain = audioCtx.createGain(); - // Add a slight "wobble" (detune) for realism - osc.detune.setValueAtTime(i * 5, now); + osc.type = type; + osc.frequency.setValueAtTime(freq, now); + osc.detune.setValueAtTime(i * 5, now); // slight wobble + oscGain.gain.setValueAtTime(level, now); - osc.connect(masterGain); + osc.connect(oscGain); + oscGain.connect(masterGain); osc.start(now); - osc.stop(now + duration / 1000); + osc.stop(now + seconds); }); } From ff7ddfbfdb2e30e81137b584abb1126409e5d197 Mon Sep 17 00:00:00 2001 From: Vivek Rajput Date: Mon, 23 Nov 2026 22:49:50 +0530 Subject: [PATCH 2/3] fix DeepSource JS-0067 --- src/assets/js/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assets/js/script.js b/src/assets/js/script.js index c8845bb8..0073ee32 100644 --- a/src/assets/js/script.js +++ b/src/assets/js/script.js @@ -482,7 +482,7 @@ function updateThemeIcon(theme) { /** * 5. EASTER EGG LOGIC & TRIGGERS */ -function playForceSoundtrack(duration = 8000) { +window.playForceSoundtrack = function (duration = 8000) { initAudio(); if (!audioCtx) return; @@ -535,7 +535,7 @@ function playForceSoundtrack(duration = 8000) { }); } -function triggerForceSurge() { +window.triggerForceSurge = function () { if (isSurging) return; isSurging = true; From c3df5dda99320bbb81e3d30ca9d222878cb992fe Mon Sep 17 00:00:00 2001 From: Vivek Rajput Date: Mon, 23 Nov 2026 23:22:07 +0530 Subject: [PATCH 3/3] fix global function references --- src/assets/js/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assets/js/script.js b/src/assets/js/script.js index 0073ee32..328cf6b9 100644 --- a/src/assets/js/script.js +++ b/src/assets/js/script.js @@ -540,7 +540,7 @@ window.triggerForceSurge = function () { isSurging = true; // 1. Audio - playForceSoundtrack(8000); + window.playForceSoundtrack(8000); // 2. Add Overlay const overlay = document.createElement("div"); @@ -1412,7 +1412,7 @@ function handleFooterDotClick() { // 3. Update the global unlockedEggs array if (!unlockedEggs.includes("secret_footer_surge")) { // Trigger the main function - triggerForceSurge(); + window.triggerForceSurge(); unlockedEggs.push("secret_footer_surge"); localStorage.setItem("unlockedEggs", JSON.stringify(unlockedEggs));