Lengthen struck piano instrument held-note fade tails

This commit is contained in:
Jage9
2026-02-23 01:25:50 -05:00
parent c0a0ccd4a5
commit 01ec672693
2 changed files with 7 additions and 2 deletions

View File

@@ -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.23 R214";
window.CHGRID_WEB_VERSION = "2026.02.23 R215";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -41,6 +41,7 @@ type InstrumentPreset = {
gain: number;
sustainRatio?: number;
holdSustain?: boolean;
heldDecayScale?: number;
releaseScale?: number;
vibrato?: { rateHz: number; depthCents: number };
};
@@ -55,6 +56,7 @@ const PRESETS: Record<Exclude<PianoInstrumentId, 'drum_kit'>, InstrumentPreset>
gain: 0.32,
sustainRatio: 0.5,
holdSustain: false,
heldDecayScale: 2.0,
releaseScale: 0.9,
},
electric_piano: {
@@ -66,6 +68,7 @@ const PRESETS: Record<Exclude<PianoInstrumentId, 'drum_kit'>, InstrumentPreset>
gain: 0.3,
sustainRatio: 0.52,
holdSustain: false,
heldDecayScale: 2.0,
releaseScale: 0.8,
},
guitar: {
@@ -77,6 +80,7 @@ const PRESETS: Record<Exclude<PianoInstrumentId, 'drum_kit'>, InstrumentPreset>
gain: 0.24,
sustainRatio: 0.48,
holdSustain: false,
heldDecayScale: 2.0,
releaseScale: 0.7,
},
organ: {
@@ -308,7 +312,8 @@ export class PianoSynth {
voiceGain.gain.exponentialRampToValueAtTime(sustainGain, now + attackSeconds + decaySeconds * 0.6);
} else {
// Struck/plucked timbres naturally decay even if the key remains held.
voiceGain.gain.exponentialRampToValueAtTime(0.0001, now + attackSeconds + decaySeconds);
const heldDecaySeconds = Math.max(0.25, decaySeconds * (preset.heldDecayScale ?? 2.0));
voiceGain.gain.exponentialRampToValueAtTime(0.0001, now + attackSeconds + heldDecaySeconds);
}
let tailNode: AudioNode = voiceGain;