diff --git a/src/igua/igua-audio.ts b/src/igua/igua-audio.ts index 6307a82..8f1c390 100644 --- a/src/igua/igua-audio.ts +++ b/src/igua/igua-audio.ts @@ -10,6 +10,8 @@ class IguaAudioImpl { private readonly _sfxGainNode: GainNode; private readonly _jukeboxGainNode: GainNode; + private readonly _sfxDelayFeedbackNode: GainNode; + readonly jukebox: AsshatJukebox; constructor(private readonly _context: AudioContext) { @@ -18,12 +20,21 @@ class IguaAudioImpl { this._globalGainNode = new GainNode(_context); this._globalGainNode.connect(this._context.destination); + this._sfxDelayFeedbackNode = new GainNode(_context, { gain: 0 }); + const delay = new DelayNode(_context, { delayTime: 0.3 }); + delay.connect(this._sfxDelayFeedbackNode); + this._sfxDelayFeedbackNode.connect(delay); + delay.connect(this._context.destination); + this._sfxGainNode = new GainNode(_context); this._sfxGainNode.connect(this._globalGainNode); + this._sfxGainNode.connect(this._sfxDelayFeedbackNode); this._jukeboxGainNode = new GainNode(_context); this._jukeboxGainNode.connect(this._globalGainNode); + this._jukeboxGainNode.gain.value = 0.2; + this.jukebox = new AsshatJukebox(this._jukeboxGainNode); } @@ -34,6 +45,10 @@ class IguaAudioImpl { return new Sound(audio, this._sfxGainNode); } + set sfxDelayFeedback(value: Unit) { + this._sfxDelayFeedbackNode.gain.value = value; + } + set globalGain(value: Unit) { this._globalGainNode.gain.value = value; } diff --git a/src/igua/scenes/game.ts b/src/igua/scenes/game.ts index 550d37b..26d2db3 100644 --- a/src/igua/scenes/game.ts +++ b/src/igua/scenes/game.ts @@ -21,7 +21,7 @@ import { createDebugPanel } from "../../lib/game-engine/debug/debug-panel"; import { approachLinear } from "../../lib/math/number"; import { SceneLocal } from "../core/scene-local"; import { show } from "../cutscene/show"; -import { Jukebox } from "../igua-audio"; +import { IguaAudio, Jukebox } from "../igua-audio"; import { Mzk } from "../../assets/music"; const TailTextures = Tx.Iguana.Tail.split({ width: 28, trimFrame: true }); @@ -92,10 +92,11 @@ export function SceneTest() { } if (Key.justWentDown('ArrowUp')) { WarningToast.show('A sound', 'A sound was just played!'); - Sfx.BallBounce.with.rate(Rng.float(0.5, 2)).play(); + Sfx.ArrowKnock.with.rate(Rng.float(0.5, 2)).play(); } if (Key.justWentDown('Space')) { - Sfx.PorkRollEggAndCheese.with.rate(Rng.float(0.5, 2)).playInstance().linearRamp('rate', Rng.float(0.5, 2), Rng.float(1, 3)); + IguaAudio.sfxDelayFeedback = Rng.float(0.1, 0.9); + Sfx.BallonPop.with.rate(Rng.float(0.5, 2)).playInstance().linearRamp('rate', Rng.float(0.5, 2), Rng.float(1, 3)); throw new EscapeTickerAndExecute(() => sceneStack.push(SceneTest, { useGameplay: false })); }