Stabilize emit speed vs tempo interaction

This commit is contained in:
Jage9
2026-02-21 23:23:14 -05:00
parent cecb4d97cd
commit ae75deb6bf
2 changed files with 12 additions and 4 deletions

View File

@@ -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 R132"; window.CHGRID_WEB_VERSION = "2026.02.22 R133";
// 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";

View File

@@ -49,9 +49,17 @@ function resolveEmitRates(item: WorldItem): { playbackRate: number; preservePitc
const globals = getItemTypeGlobalProperties(item.type); const globals = getItemTypeGlobalProperties(item.type);
const speed = resolveEmitPlaybackRate(item.params.emitSoundSpeed ?? globals.emitSoundSpeed ?? 50); const speed = resolveEmitPlaybackRate(item.params.emitSoundSpeed ?? globals.emitSoundSpeed ?? 50);
const tempo = resolveEmitPlaybackRate(item.params.emitSoundTempo ?? globals.emitSoundTempo ?? 50); const tempo = resolveEmitPlaybackRate(item.params.emitSoundTempo ?? globals.emitSoundTempo ?? 50);
const playbackRate = Math.max(0.25, Math.min(4, speed * tempo)); const speedOffset = Math.abs(speed - 1);
const preservePitch = Math.abs(speed - 1) < 0.001; if (speedOffset > 0.001) {
return { playbackRate, preservePitch }; return {
playbackRate: Math.max(0.25, Math.min(4, speed)),
preservePitch: false,
};
}
return {
playbackRate: Math.max(0.25, Math.min(4, tempo)),
preservePitch: true,
};
} }
export class ItemEmitRuntime { export class ItemEmitRuntime {