From bea24c8a12c862460e7c9e15765f9254c908477a Mon Sep 17 00:00:00 2001 From: Robin Fernandes Date: Tue, 10 Oct 2023 17:01:48 +1100 Subject: [PATCH] #217 Allow users to offset detected (and manual) audio events by a configurable offset --- src/components/AudioWaveform.tsx | 47 +++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/src/components/AudioWaveform.tsx b/src/components/AudioWaveform.tsx index 40c0573..2ca7e07 100644 --- a/src/components/AudioWaveform.tsx +++ b/src/components/AudioWaveform.tsx @@ -69,6 +69,7 @@ export function AudioWaveform(props: AudioWaveformProps) { const [onsetMethod, setOnsetMethod] = useState("default"); const [onsetThreshold, setOnsetThreshold] = useState("1.1"); const [onsetSilence, setOnsetSilence] = useState("-70"); + const [eventOffset, setEventOffset] = useState("-50"); const onsetRef = useRef(null); const onsetProgressRef = useRef(null); @@ -654,6 +655,12 @@ export function AudioWaveform(props: AudioWaveformProps) { } } + function offsetEvents(): void { + const offset = Number.parseFloat(eventOffset)/1000; + setDetectedEvents(detectedEvents.map(e => e + offset)); + setManualEvents(manualEvents.map(e => e + offset)); + } + function generateKeyframes(): void { const frames = manualEvents.concat(detectedEvents).map(s => Math.round(s * props.fps)); props.onAddKeyframes(frames, infoLabel); @@ -775,7 +782,7 @@ export function AudioWaveform(props: AudioWaveformProps) { Parseq uses Aubio.js to estimate your reference audio's BPM. The result is not always accurate, but can guide you towards a good overall BPM value for your Parseq document (which you set above the grid). Parseq does not yet support variable BPMs. - + } + + + + <> + setEventOffset(e.target.value)} + disabled={isAnalysing} + /> + + + + + + - - - Parseq uses Aubio.js to detect events in your reference audio. You can move events by dragging them, add events by double-clicking, and delete events by shift-clicking. You can generate Parseq keyframes from audio events in the "Keyframe generation" tab. @@ -837,15 +858,15 @@ export function AudioWaveform(props: AudioWaveformProps) { - - setInfoLabel(e.target.value)} - InputProps={{ style: { fontSize: "0.75em", fontFamily: "monospace", width: "18em" } }} - disabled={isAnalysing} - /> + + setInfoLabel(e.target.value)} + InputProps={{ style: { fontSize: "0.75em", fontFamily: "monospace", width: "18em" } }} + disabled={isAnalysing} + />