Add short fade-in ramp to local movement footsteps
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// Maintainer-controlled web client version.
|
// Maintainer-controlled web client version.
|
||||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||||
window.CHGRID_WEB_VERSION = "2026.02.22 R173";
|
window.CHGRID_WEB_VERSION = "2026.02.22 R174";
|
||||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ export class AudioEngine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async playSample(url: string, gain = 1): Promise<void> {
|
async playSample(url: string, gain = 1, fadeInMs = 0): Promise<void> {
|
||||||
await this.ensureContext();
|
await this.ensureContext();
|
||||||
const { audioCtx, sfxGainNode } = this;
|
const { audioCtx, sfxGainNode } = this;
|
||||||
if (!audioCtx || !sfxGainNode) return;
|
if (!audioCtx || !sfxGainNode) return;
|
||||||
@@ -380,7 +380,13 @@ export class AudioEngine {
|
|||||||
const source = audioCtx.createBufferSource();
|
const source = audioCtx.createBufferSource();
|
||||||
source.buffer = buffer;
|
source.buffer = buffer;
|
||||||
const gainNode = audioCtx.createGain();
|
const gainNode = audioCtx.createGain();
|
||||||
|
const safeFadeMs = Number.isFinite(fadeInMs) ? Math.max(0, fadeInMs) : 0;
|
||||||
|
if (safeFadeMs > 0) {
|
||||||
|
gainNode.gain.setValueAtTime(0, audioCtx.currentTime);
|
||||||
|
gainNode.gain.linearRampToValueAtTime(gain, audioCtx.currentTime + safeFadeMs / 1000);
|
||||||
|
} else {
|
||||||
gainNode.gain.value = gain;
|
gainNode.gain.value = gain;
|
||||||
|
}
|
||||||
source.connect(gainNode).connect(sfxGainNode);
|
source.connect(gainNode).connect(sfxGainNode);
|
||||||
source.start();
|
source.start();
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -1136,7 +1136,7 @@ function handleMovement(): void {
|
|||||||
persistPlayerPosition();
|
persistPlayerPosition();
|
||||||
state.player.lastMoveTime = now;
|
state.player.lastMoveTime = now;
|
||||||
void refreshAudioSubscriptions(true);
|
void refreshAudioSubscriptions(true);
|
||||||
void audio.playSample(randomFootstepUrl(), FOOTSTEP_GAIN);
|
void audio.playSample(randomFootstepUrl(), FOOTSTEP_GAIN, 40);
|
||||||
signaling.send({ type: 'update_position', x: nextX, y: nextY });
|
signaling.send({ type: 'update_position', x: nextX, y: nextY });
|
||||||
|
|
||||||
const namesOnTile = getPeerNamesAtPosition(nextX, nextY);
|
const namesOnTile = getPeerNamesAtPosition(nextX, nextY);
|
||||||
|
|||||||
Reference in New Issue
Block a user