M13.34: audio scrubbing (Ctrl/Cmd-drag the current time)
- audio::AudioScrub: an open output that plays a faded snippet (one frame, 30–100 ms) of the
comp's mix at each new frame, replacing what is still queued; holding still repeats nothing.
The mixing is shared with the preview feeder (mix_block); AudioFeed::clear.
- The Timeline ruler: Ctrl/Cmd-drag scrubs audio (EffectcraftApp::scrub_audio opens the output
through the audio device hook on first use). The Audio panel meters follow the snippets; an
idle second closes the output.
- playback.scrubAudio {time?} for agents.
- Tests: ui_audio_scrub (snippet length, fades, same-frame no-op, replace not pile up, silent
comps, Cmd-drag in the ruler, idle close) with a fake device. Docs: parity.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9607be471b
commit
5afc25d0d8
@@ -211,6 +211,8 @@ pub struct EffectcraftApp {
|
||||
pub integrated_titlebar: bool,
|
||||
/// Audio preview while playing (audio clock drives playback).
|
||||
pub audio: Option<audio::AudioPlayback>,
|
||||
/// Audio scrubbing's open output (Ctrl/Cmd-drag the current time, `playback.scrubAudio`).
|
||||
pub scrub: Option<audio::AudioScrub>,
|
||||
/// Audio panel VU meters.
|
||||
pub meter: audio::Meter,
|
||||
/// Waveform peak summaries per footage item (see `panels::waveform`).
|
||||
@@ -276,6 +278,7 @@ impl EffectcraftApp {
|
||||
dialog_state: Default::default(),
|
||||
integrated_titlebar: false,
|
||||
audio: None,
|
||||
scrub: None,
|
||||
meter: Default::default(),
|
||||
waveforms: Default::default(),
|
||||
last_reveal: None,
|
||||
@@ -677,6 +680,30 @@ impl EffectcraftApp {
|
||||
}
|
||||
}
|
||||
|
||||
/// Audio scrubbing: play the frame of `comp` at `t` (see [`audio::AudioScrub`]), opening the
|
||||
/// output on first use. Silent comps and missing devices do nothing.
|
||||
pub fn scrub_audio(&mut self, comp: ItemId, t: Tick, now: f64) {
|
||||
if self.playback.playing || !effectcraft_engine::render::audio::comp_has_audio(&self.session.project, comp) {
|
||||
return;
|
||||
}
|
||||
if self.scrub.is_none() {
|
||||
let out = audio::AudioOutput::from_prefs(&self.session.prefs);
|
||||
let Some(dev) = self.hooks.audio_device.as_ref().and_then(|f| f(&out)) else { return };
|
||||
match audio::AudioScrub::open(dev, now) {
|
||||
Ok(s) => self.scrub = Some(s),
|
||||
Err(e) => {
|
||||
log::warn!("audio scrubbing: {e}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
let src = self.render_source();
|
||||
let mix = self.session.prefs.audio.preview_sample_rate;
|
||||
if let Some(s) = &mut self.scrub {
|
||||
s.play(&src, comp, t, mix, now);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stop(&mut self) {
|
||||
let was = std::mem::replace(&mut self.playback.playing, false);
|
||||
self.audio = None;
|
||||
@@ -845,6 +872,14 @@ impl EffectcraftApp {
|
||||
if let Some(a) = &mut self.audio {
|
||||
a.pump();
|
||||
self.meter.update(a.feed.take_peaks(), now);
|
||||
} else if let Some(s) = &mut self.scrub {
|
||||
// Scrubbing: the meters follow the snippets; an idle second closes the output.
|
||||
s.pump();
|
||||
self.meter.update(s.feed.take_peaks(), now);
|
||||
if now - s.last_used > 1.0 {
|
||||
self.scrub = None;
|
||||
}
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(50));
|
||||
} else if self.meter.active() {
|
||||
self.meter.update([0.0; 2], now);
|
||||
ctx.request_repaint();
|
||||
|
||||
Reference in New Issue
Block a user