Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/cuepool-core/src/cue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ pub struct CueTriggers {
pub wall_clock: Option<WallClockTrigger>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub timecode: Option<TimecodeTrigger>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub time_window: Option<TimeWindowTrigger>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -114,6 +116,18 @@ pub enum RepeatMode {
Once,
}

/// Daily on-air window. While the clock is inside `from..to` the cue fires
/// once (so a machine that boots late still starts it) and it stops at `to`.
/// `to` at or before `from` wraps past midnight. Times use the wall-clock
/// trigger's formats.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct TimeWindowTrigger {
pub from: String,
pub to: String,
#[serde(default)]
pub mode: ClockMode,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WallClockTrigger {
pub time: String,
Expand Down Expand Up @@ -944,6 +958,11 @@ mod tests {
timecode: Some(TimecodeTrigger {
time: Timespan::from_secs_f64(10.0),
}),
time_window: Some(TimeWindowTrigger {
from: "09:30:00".into(),
to: "17:00:00".into(),
mode: ClockMode::TwentyFourHour,
}),
};
let cue = Cue::Dummy {
base: CueBase {
Expand Down
2 changes: 1 addition & 1 deletion crates/cuepool-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use cue::{
};
pub use cue::{
ClockMode, CueTriggers, FadeType, HotkeyTrigger, LoopMode, MidiTrigger, MidiTriggerKind,
RepeatMode, StopMode, TimecodeTrigger, TriggerMode, WallClockTrigger,
RepeatMode, StopMode, TimeWindowTrigger, TimecodeTrigger, TriggerMode, WallClockTrigger,
};
pub use eq::{EQBand, EQBandShape, EQFilter, EQFilterOrder, EQSettings};
pub use lighting::{
Expand Down
1 change: 1 addition & 0 deletions crates/cuepool-gui/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3282,6 +3282,7 @@ impl CuePoolApp {
triggers.hotkey.is_some().then_some("hotkey"),
triggers.midi.is_some().then_some("MIDI"),
triggers.wall_clock.is_some().then_some("wall clock"),
triggers.time_window.is_some().then_some("time window"),
triggers.timecode.is_some().then_some("timecode"),
]
})
Expand Down
6 changes: 6 additions & 0 deletions crates/cuepool-gui/src/cue_list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,9 @@ fn trigger_badges(triggers: &cuepool_core::CueTriggers) -> Vec<&'static str> {
if triggers.wall_clock.is_some() {
badges.push("clk");
}
if triggers.time_window.is_some() {
badges.push("win");
}
if triggers.timecode.is_some() {
badges.push("tc");
}
Expand Down Expand Up @@ -921,6 +924,9 @@ fn describe_triggers(triggers: &cuepool_core::CueTriggers, tc_fps: f32) -> Strin
}
parts.push(s);
}
if let Some(window) = &triggers.time_window {
parts.push(format!("Time window {}–{}", window.from, window.to));
}
if let Some(tc) = &triggers.timecode {
parts.push(format!(
"Timecode ≥ {}",
Expand Down
31 changes: 31 additions & 0 deletions crates/cuepool-gui/src/inspector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,37 @@ fn triggers_editor(
}
}

// Time window
{
let mut enabled = triggers.time_window.is_some();
if ui
.checkbox(&mut enabled, "Time Window")
.on_hover_text(
"Daily on-air window. While the clock is inside it the cue fires once, \
even if CuePool starts late, and it stops at To. To at or before From \
wraps past midnight.",
)
.changed()
{
*changed = true;
triggers.time_window = enabled.then(|| cuepool_core::TimeWindowTrigger {
from: "09:00:00".into(),
to: "17:00:00".into(),
mode: cuepool_core::ClockMode::TwentyFourHour,
});
}
if let Some(window) = triggers.time_window.as_mut() {
ui.horizontal(|ui| {
ui.label("From:");
*changed |= ui.text_edit_singleline(&mut window.from).changed();
});
ui.horizontal(|ui| {
ui.label("To:");
*changed |= ui.text_edit_singleline(&mut window.to).changed();
});
}
}

// Timecode
{
let mut enabled = triggers.timecode.is_some();
Expand Down
61 changes: 61 additions & 0 deletions crates/cuepool/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub enum EngineCommand {
volume: f32,
pan: f32,
},
/// Stop one cue (a group with its members) using the cue's own fade-out,
/// as a Stop cue aimed at it with that fade would.
StopCue(Decimal),
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -333,6 +336,7 @@ impl ShowEngine {
EngineCommand::Preload => self.preload(),
EngineCommand::Seek { instance_id, secs } => self.seek(instance_id, secs),
EngineCommand::SetLevel { qid, volume, pan } => self.set_level(qid, volume, pan),
EngineCommand::StopCue(qid) => self.stop_cue(qid),
}
self.take_actions()
}
Expand Down Expand Up @@ -1004,6 +1008,35 @@ impl ShowEngine {
Some(instance_id)
}

/// Whether the cue is playing (or paused) here: audio, video or a still.
pub fn is_cue_active(&self, qid: Decimal) -> bool {
self.cue_is_active(qid)
}

fn stop_cue(&mut self, qid: Decimal) {
let (fade_out, fade_type) = self
.state
.lock_unpoisoned()
.show_file
.cues
.iter()
.find(|cue| cue.base().qid == qid)
.map_or((0.0, Default::default()), |cue| match cue {
Cue::Sound {
fade_out,
fade_type,
..
}
| Cue::Video {
fade_out,
fade_type,
..
} => (*fade_out, *fade_type),
_ => (0.0, Default::default()),
});
self.stop_target(qid, StopMode::Immediate, fade_out, fade_type);
}

fn cue_is_active(&self, qid: Decimal) -> bool {
self.is_video_playing(qid)
|| self.current_picture_qid == Some(qid)
Expand Down Expand Up @@ -3380,4 +3413,32 @@ mod tests {
assert!(engine.group_loops.is_empty());
assert!(engine.snapshot().videos.is_empty());
}

#[test]
fn stop_cue_uses_the_cues_own_fade_out() {
let app = cuepool_gui::CuePoolApp::new();
let mut engine = ShowEngine::new(app.state().clone(), None);
let (cue, input) = active_audio(1, Decimal::ONE);
engine.active_cues.push(cue);
engine.state.lock_unpoisoned().show_file.cues = vec![Cue::Sound {
base: cuepool_core::CueBase {
qid: Decimal::ONE,
..Default::default()
},
path: "tone.wav".into(),
start_time: Timespan::ZERO,
duration: Timespan::ZERO,
volume: 1.0,
pan: 0.0,
fade_in: 0.0,
fade_out: 2.0,
fade_type: Default::default(),
eq: None,
routing: Default::default(),
}];
assert!(engine.is_cue_active(Decimal::ONE));

engine.command(EngineCommand::StopCue(Decimal::ONE), Duration::ZERO);
assert!(input.is_fading(), "a cue with a fade-out fades, not cuts");
}
}
Loading
Loading