diff --git a/client/public/version.js b/client/public/version.js index 29627ad..3b88f0a 100644 --- a/client/public/version.js +++ b/client/public/version.js @@ -1,5 +1,5 @@ // Maintainer-controlled web client version. // Format: YYYY.MM.DD Rn (example: 2026.02.20 R2) -window.CHGRID_WEB_VERSION = "2026.02.22 R184"; +window.CHGRID_WEB_VERSION = "2026.02.22 R185"; // Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid. window.CHGRID_TIME_ZONE = "America/Detroit"; diff --git a/client/src/audio/itemEmitRuntime.ts b/client/src/audio/itemEmitRuntime.ts index aed906d..6eed849 100644 --- a/client/src/audio/itemEmitRuntime.ts +++ b/client/src/audio/itemEmitRuntime.ts @@ -4,6 +4,7 @@ import { AudioEngine } from './audioEngine'; import { connectEffectChain, disconnectEffectRuntime, type EffectId, type EffectRuntime } from './effects'; import { normalizeRadioEffect, normalizeRadioEffectValue } from './radioStationRuntime'; import { resolveSpatialMix } from './spatial'; +import { volumePercentToGain } from './volume'; type EmitOutput = { soundUrl: string; @@ -23,7 +24,7 @@ type EmitSpatialConfig = { facingDeg: number; }; -const ITEM_EMIT_BASE_GAIN = 0.3; +const ITEM_EMIT_BASE_GAIN = 1; const SUBSCRIBE_PRELOAD_SQUARES = 5; const UNSUBSCRIBE_HYSTERESIS_SQUARES = 8; @@ -218,8 +219,7 @@ export class ItemEmitRuntime { }); const gainValue = mix?.gain ?? 0; const panValue = mix?.pan ?? 0; - const emitVolumeRaw = Number(item.params.emitVolume ?? 100); - const emitVolume = Number.isFinite(emitVolumeRaw) ? Math.max(0, Math.min(100, emitVolumeRaw)) / 100 : 1; + const emitVolume = volumePercentToGain(item.params.emitVolume, 100); output.gain.gain.linearRampToValueAtTime(gainValue * emitVolume, audioCtx.currentTime + 0.1); if (output.panner) { const resolvedPan = this.audio.getOutputMode() === 'mono' ? 0 : Math.max(-1, Math.min(1, panValue)); diff --git a/client/src/audio/radioStationRuntime.ts b/client/src/audio/radioStationRuntime.ts index 102f346..34d2eb6 100644 --- a/client/src/audio/radioStationRuntime.ts +++ b/client/src/audio/radioStationRuntime.ts @@ -2,6 +2,7 @@ import { HEARING_RADIUS, type WorldItem } from '../state/gameState'; import { EFFECT_IDS, clampEffectLevel, connectEffectChain, disconnectEffectRuntime, type EffectId, type EffectRuntime } from './effects'; import { AudioEngine } from './audioEngine'; import { resolveSpatialMix } from './spatial'; +import { volumePercentToGain } from './volume'; export const RADIO_CHANNEL_OPTIONS = ['stereo', 'mono', 'left', 'right'] as const; export type RadioChannelMode = (typeof RADIO_CHANNEL_OPTIONS)[number]; @@ -265,8 +266,7 @@ export class RadioStationRuntime { } const streamUrl = String(item.params.streamUrl ?? '').trim(); const enabled = item.params.enabled !== false; - const mediaVolume = Number(item.params.mediaVolume ?? 50); - const normalizedVolume = Number.isFinite(mediaVolume) ? Math.max(0, Math.min(100, mediaVolume)) / 100 : 0.5; + const normalizedVolume = volumePercentToGain(item.params.mediaVolume, 50); const effect = normalizeRadioEffect(item.params.mediaEffect); const effectValue = normalizeRadioEffectValue(item.params.mediaEffectValue); this.applyEffect(output, audioCtx, effect, effectValue); diff --git a/client/src/audio/volume.ts b/client/src/audio/volume.ts new file mode 100644 index 0000000..8d695cd --- /dev/null +++ b/client/src/audio/volume.ts @@ -0,0 +1,8 @@ +/** Converts a 0-100 slider value into gain using a perceptual smoothstep curve. */ +export function volumePercentToGain(value: unknown, fallbackPercent: number): number { + const raw = Number(value); + const normalized = Number.isFinite(raw) ? Math.max(0, Math.min(100, raw)) / 100 : Math.max(0, Math.min(100, fallbackPercent)) / 100; + // Smoothstep keeps 0->0, 50->0.5, 100->1 while easing low/high ranges. + return normalized * normalized * (3 - 2 * normalized); +} +