Skip to main content

rill_patchbay/sequencer/
snapshot.rs

1use rill_core::NodeId;
2
3/// A single parameter target within a snapshot or step.
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5#[derive(Debug, Clone, PartialEq)]
6pub struct ParameterTarget {
7    /// Graph node ID.
8    pub node_id: NodeId,
9    /// Parameter name on the target node.
10    pub param_name: String,
11    /// Stored value for this parameter.
12    pub value: f32,
13}
14
15impl ParameterTarget {
16    /// Create a new parameter target.
17    pub fn new(node_id: NodeId, param_name: impl Into<String>, value: f32) -> Self {
18        Self {
19            node_id,
20            param_name: param_name.into(),
21            value,
22        }
23    }
24}
25
26/// A named collection of parameter values — a complete preset "scene".
27///
28/// Snapshots are a convenience for storing/recalling complete parameter sets.
29/// A [`SequenceStep`](super::SequenceStep) expands its referenced snapshot's
30/// parameters into the step's own lock list on step advance.
31#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
32#[derive(Debug, Clone)]
33pub struct Snapshot {
34    /// Unique snapshot identifier.
35    pub id: String,
36    /// Parameter targets stored in this snapshot.
37    pub parameters: Vec<ParameterTarget>,
38}
39
40impl Snapshot {
41    /// Create a new snapshot with the given ID and parameters.
42    pub fn new(id: impl Into<String>, parameters: Vec<ParameterTarget>) -> Self {
43        Self {
44            id: id.into(),
45            parameters,
46        }
47    }
48}