diff --git a/src/samples/drums/tom-high.ts b/src/samples/drums/tom-high.ts index 91202ac..fb96689 100644 --- a/src/samples/drums/tom-high.ts +++ b/src/samples/drums/tom-high.ts @@ -2,8 +2,9 @@ import {triggerTom} from './tom-low.ts'; export function playTom2High(volume = 100) { triggerTom(volume, { - frequency: 250, - decayTime: 0.3, - pitchDecay: 0.15 + frequency: 250, // Higher frequency for high tom + decayTime: 0.3, // Shorter decay + pitchDecay: 0.3, // Fast pitch decay + frequencyDrop: 0.9 // Moderate frequency drop }); } diff --git a/src/samples/drums/tom-low.ts b/src/samples/drums/tom-low.ts index a855d04..5a2269c 100644 --- a/src/samples/drums/tom-low.ts +++ b/src/samples/drums/tom-low.ts @@ -4,7 +4,9 @@ const defaults = { frequency: 200, // Starting frequency decayTime: 0.4, // How long the sound lasts pitchDecay: 0.2, // How quickly the pitch drops + frequencyDrop: 0.5 // How much the frequency drops (1 = all the way) }; + export function triggerTom(volume = 50, settings = defaults) { const context = createAudioContext(); const time = context.currentTime; @@ -19,16 +21,23 @@ export function triggerTom(volume = 50, settings = defaults) { // Set initial frequency osc.frequency.setValueAtTime(settings.frequency, time); - // Frequency envelope - faster decay than kick + // Frequency envelope - less extreme drop than kick + const targetFreq = settings.frequency * (1 - settings.frequencyDrop); osc.frequency.exponentialRampToValueAtTime( - settings.frequency * 0.01, + Math.max(targetFreq, 0.01), // Ensure we don't go below 0.01 time + settings.pitchDecay ); // Amplitude envelope gain.gain.setValueAtTime(gainValue, time); - // Smoother decay for the tom sound + // More pronounced initial attack for tom character + gain.gain.linearRampToValueAtTime( + gainValue * 0.7, + time + 0.01 + ); + + // Then decay gain.gain.exponentialRampToValueAtTime( gainValue * 0.01, time + settings.decayTime - 0.02 @@ -48,9 +57,10 @@ export function triggerTom(volume = 50, settings = defaults) { } export function playTom1Low(volume = 100) { - triggerTom(volume, { - frequency: 140, - decayTime: 0.4, - pitchDecay: 0.25 + triggerTom(volume, { + frequency: 180, // Higher than kick but lower than high tom + decayTime: 0.35, // Medium decay + pitchDecay: 0.15, // Medium pitch decay + frequencyDrop: 0.4 // More pronounced drop than high tom }); }