1use derive_builder::Builder;
2use fundsp::DEFAULT_SR;
3
4const DEFAULT_HEIGHT: usize = 500;
5
6#[derive(Debug, Clone, Builder)]
7pub struct SnapshotConfig {
9 #[builder(default = "1024")]
13 pub num_samples: usize,
14 #[builder(default = "fundsp::DEFAULT_SR")]
18 pub sample_rate: f64,
19 #[builder(default, setter(strip_option))]
23 pub svg_width: Option<usize>,
24 #[builder(default = "DEFAULT_HEIGHT")]
28 pub svg_height_per_channel: usize,
29 #[builder(default = "Processing::default()")]
33 pub processing_mode: Processing,
34 #[builder(default)]
38 pub with_inputs: bool,
39 #[builder(default, setter(into, strip_option))]
43 pub chart_title: Option<String>,
44 #[builder(default, setter(into, each(into, name = "output_title")))]
48 pub output_titles: Vec<String>,
49 #[builder(default, setter(into, each(into, name = "input_title")))]
53 pub input_titles: Vec<String>,
54 #[builder(default)]
58 pub show_grid: bool,
59 #[builder(default = "true")]
63 pub show_labels: bool,
64 #[builder(default, setter(into, strip_option, each(into, name = "output_color")))]
68 pub output_colors: Option<Vec<String>>,
69 #[builder(default, setter(into, strip_option, each(into, name = "input_color")))]
73 pub input_colors: Option<Vec<String>>,
74 #[builder(default = "\"#000000\".to_string()", setter(into))]
78 pub background_color: String,
79 #[builder(default = "2.0")]
83 pub line_width: f32,
84}
85
86#[derive(Debug, Clone, Copy, Default)]
88pub enum Processing {
89 #[default]
90 Tick,
92 Batch(u8),
96}
97
98impl Default for SnapshotConfig {
99 fn default() -> Self {
100 Self {
101 num_samples: 1024,
102 sample_rate: DEFAULT_SR,
103 svg_width: None,
104 svg_height_per_channel: DEFAULT_HEIGHT,
105 processing_mode: Processing::default(),
106 with_inputs: false,
107 chart_title: None,
108 output_titles: Vec::new(),
109 input_titles: Vec::new(),
110 show_grid: false,
111 show_labels: true,
112 output_colors: None,
113 input_colors: None,
114 background_color: "#000000".to_string(),
115 line_width: 2.0,
116 }
117 }
118}
119
120#[cfg(test)]
121mod tests {
122 use super::*;
123
124 #[test]
125 fn test_default_builder() {
126 SnapshotConfigBuilder::default()
127 .build()
128 .expect("defaul config builds");
129 }
130}