From 13029f42779665cbfc3cd5d18bb7af8e8b6c252a Mon Sep 17 00:00:00 2001 From: AG Date: Sat, 20 Dec 2025 20:48:15 +0200 Subject: [PATCH] Bass line Note Trigger Sound fixed --- session_state.db | Bin 24576 -> 24576 bytes src/audio/Engine.ts | 1 + src/hooks/useDrumMachine.ts | 11 ++++++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/session_state.db b/session_state.db index 90ad56b238e3acbc32f38c544fb0c10ec1cd432b..313cf09380b60588cc87f4e1efee7efdad181bde 100644 GIT binary patch delta 732 zcmZ8dO-lk%6m|R{Qt25fh9v2@6`~o#vRdevE^MKjFfz#6hXwXQl&&HnFnRl0)Y_8y z1NIXle?b0&+P0~8@14;pc-;5iz31F>?rrv^W?#As*`;D>8Vr}-t zURjkrupS$-H&$aMJsMG&k2zw}`Ejzga(Z~8oK-z~b>T7Mb~uMN?_l!6IqV(1J7-!! zk1N)xs}>-?DMxr~I>6hSn}2Mt@opi&UqU|qvkC75{#=;i;n^_%^nY_-aJ?aCW2zjN zGZ4}c^7sC0X-uH6Yu_K)1`neq qpdvhC&MHh^AuVQt3+ZC{;!TG}Glznk7yYXf%PCb!DXKoG#2vo@JgS@k delta 484 zcmZoTz}Rqrae@>R! } = useStore(); const timerRef = useRef(null); + const wasPlayingRef = useRef(false); const lookahead = 25.0; const scheduleAheadTime = 0.1; const nextNoteTimeRef = useRef(0.0); @@ -161,8 +162,8 @@ export const useDrumMachine = (_lastMessage: any, sendMessage: (message: any) => const triggerBassNote = async (note: string) => { await audioEngine.init(); audioEngine.startBassNote(note, audioEngine.getCurrentTime()); - // Stop after 1s for preview - setTimeout(() => audioEngine.stopBassNote(note, audioEngine.getCurrentTime()), 1000); + // Stop after 500ms for preview + setTimeout(() => audioEngine.stopBassNote(note, audioEngine.getCurrentTime()), 500); }; const exportBeat = () => { @@ -199,9 +200,13 @@ export const useDrumMachine = (_lastMessage: any, sendMessage: (message: any) => scheduler(); } else { if (timerRef.current) clearTimeout(timerRef.current); - audioEngine.stopAllBassNotes(); + // Only stop all notes if we just switched from playing to stopped + if (wasPlayingRef.current) { + audioEngine.stopAllBassNotes(); + } setCurrentStep(null); } + wasPlayingRef.current = isPlaying; return () => { if (timerRef.current) clearTimeout(timerRef.current); };