1#[macro_export]
78macro_rules! assert_audio_unit_snapshot {
79 ($unit:expr) => {{
81 let mut __unit = $unit;
83 let __unit_clone = __unit.clone();
84
85 let config = $crate::config::SnapshotConfigBuilder::default()
87 .build()
88 .unwrap();
89 let name = config.file_name(None);
90 let data_svg = $crate::snapshot::snapshot_audio_unit_with_options(__unit, config);
91
92 ::insta::with_settings!({ omit_expression => true}, {
93 ::insta::assert_binary_snapshot!(&name, data_svg.as_slice().to_vec());
94 });
95
96 let config = $crate::config::SnapshotConfigBuilder::default()
98 .output_mode($crate::config::WavOutput::Wav16)
99 .build()
100 .unwrap();
101 let name = config.file_name(None);
102 let data_wav = $crate::snapshot::snapshot_audio_unit_with_options(__unit_clone, config);
103
104 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
105 ::insta::assert_binary_snapshot!(&name, data_wav.as_slice().to_vec());
106 });
107 }};
108
109 ($name:literal, $unit:expr) => {{
111 let mut __unit = $unit;
112 let __unit_clone = __unit.clone();
113
114 let config = $crate::config::SnapshotConfigBuilder::default()
116 .chart_title($name)
117 .build()
118 .unwrap();
119 let name = config.file_name(Some($name));
120 let data_svg = $crate::snapshot::snapshot_audio_unit_with_options(__unit, config);
121
122 ::insta::with_settings!({ omit_expression => true}, {
123 ::insta::assert_binary_snapshot!(&name, data_svg.as_slice().to_vec());
124 });
125
126 let config = $crate::config::SnapshotConfigBuilder::default()
128 .output_mode($crate::config::WavOutput::Wav16)
129 .build()
130 .unwrap();
131 let name = config.file_name(Some($name));
132 let data_wav = $crate::snapshot::snapshot_audio_unit_with_options(__unit_clone, config);
133
134 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
135 ::insta::assert_binary_snapshot!(&name, data_wav.as_slice().to_vec());
136 });
137 }};
138
139 ($name:expr, $unit:expr, $input:expr) => {{
141 let __name: String = ::std::convert::Into::into($name);
142 let mut __unit = $unit;
143 let __unit_clone = __unit.clone();
144 let config = $crate::config::SnapshotConfigBuilder::default()
149 .chart_title(__name.as_str())
150 .build()
151 .unwrap();
152 let name = config.file_name(Some(__name.as_str()));
153 let data_svg =
154 $crate::snapshot::snapshot_audio_unit_with_input_and_options(__unit, $input, config);
155
156 ::insta::with_settings!({ omit_expression => true}, {
157 ::insta::assert_binary_snapshot!(&name, data_svg.as_slice().to_vec());
158 });
159
160 let config = $crate::config::SnapshotConfigBuilder::default()
162 .output_mode($crate::config::WavOutput::Wav16)
163 .build()
164 .unwrap();
165 let name = config.file_name(Some(__name.as_str()));
166 let data_wav =
167 $crate::snapshot::snapshot_audio_unit_with_input_and_options(__unit_clone, $input, config);
168
169 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
170 ::insta::assert_binary_snapshot!(&name, data_wav.as_slice().to_vec());
171 });
172 }};
173
174 ($name:expr, $unit:expr, $input:expr, $config:expr) => {{
176 let __name: String = ::std::convert::Into::into($name);
177 let mut config = $config;
178 config.maybe_title(__name.as_str());
179
180 let is_audio = matches!(
181 config.output_mode,
182 $crate::config::SnapshotOutputMode::Wav(_)
183 );
184
185 let name = config.file_name(Some(__name.as_str()));
186 let data = $crate::snapshot::snapshot_audio_unit_with_input_and_options($unit, $input, config);
187
188 if is_audio {
189 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
190 ::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
191 });
192 }
193 else {
194 ::insta::with_settings!({ omit_expression => true}, {
195 ::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
196 });
197 }
198 }};
199
200 ($unit:expr, $config:expr) => {{
204
205 let is_audio = matches!(
206 $config.output_mode,
207 $crate::config::SnapshotOutputMode::Wav(_)
208 );
209 let name = $config.file_name(None);
211 let data = $crate::snapshot::snapshot_audio_unit_with_options($unit, $config);
212
213 if is_audio {
214 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
215 ::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
216 });
217 }
218 else {
219 ::insta::with_settings!({ omit_expression => true }, {
220 ::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
221 });
222 }
223 }};
224}
225
226#[macro_export]
251macro_rules! assert_audio_unit_meta_data_snapshot {
252 ($unit:expr, $meta_builder:expr) => {{
253 let __config = $crate::config::SnapshotConfig::default();
254 let __data = $crate::snapshot::snapshot_audio_unit_data_with_input_and_options(
255 $unit,
256 $crate::input::InputSource::None,
257 __config.clone(),
258 );
259 let __meta = ($meta_builder)(&__data);
260 let __svg =
261 $crate::snapshot::snapshot_metadata_dashboard_with_snapshot_config(&__meta, &__config);
262
263 let __name = format!(
264 "meta_data_dashboard_{}_{}.svg",
265 module_path!().replace("::", "_"),
266 line!()
267 );
268
269 ::insta::with_settings!({ omit_expression => true }, {
270 ::insta::assert_binary_snapshot!(&__name, __svg);
271 });
272 }};
273
274 ($unit:expr, $input:expr => $meta_builder:expr) => {{
275 let __config = $crate::config::SnapshotConfig::default();
276 let __data =
277 $crate::snapshot::snapshot_audio_unit_data_with_input_and_options($unit, $input, __config.clone());
278 let __meta = ($meta_builder)(&__data);
279 let __svg =
280 $crate::snapshot::snapshot_metadata_dashboard_with_snapshot_config(&__meta, &__config);
281
282 let __name = format!(
283 "meta_data_dashboard_{}_{}.svg",
284 module_path!().replace("::", "_"),
285 line!()
286 );
287
288 ::insta::with_settings!({ omit_expression => true }, {
289 ::insta::assert_binary_snapshot!(&__name, __svg);
290 });
291 }};
292
293 ($unit:expr, $input:expr, $config:expr => $meta_builder:expr) => {{
294 let __config = $config;
295 let __data = $crate::snapshot::snapshot_audio_unit_data_with_input_and_options(
296 $unit,
297 $input,
298 __config.clone(),
299 );
300 let __meta = ($meta_builder)(&__data);
301 let __svg =
302 $crate::snapshot::snapshot_metadata_dashboard_with_snapshot_config(&__meta, &__config);
303
304 let __file_name = __config.file_name(None);
305 let __name = if __file_name == ".svg" || __file_name == ".wav" {
306 format!(
307 "meta_data_dashboard_{}_{}.svg",
308 module_path!().replace("::", "_"),
309 line!()
310 )
311 } else {
312 __file_name
313 };
314
315 ::insta::with_settings!({ omit_expression => true }, {
316 ::insta::assert_binary_snapshot!(&__name, __svg);
317 });
318 }};
319}
320
321#[macro_export]
332macro_rules! assert_dsp_net_snapshot {
333 ($name:expr, $net:expr) => {{
334 let __name: String = ::std::convert::Into::into($name);
335 let __snap_name = format!("{}.dot", __name);
337 let __bytes: ::std::vec::Vec<u8> = $crate::graph::snapshot_dsp_net_wiring($net);
338 ::insta::with_settings!({ omit_expression => true }, {
340 ::insta::assert_binary_snapshot!(&__snap_name, __bytes);
341 });
342 }};
343}