sva_samples/measure/
mod.rs1pub mod alias;
4pub mod bands;
5pub mod beating;
6pub mod crest;
7pub mod envelope;
8pub mod formants;
9pub mod harmony;
10pub mod ledger;
11pub mod loudness;
12pub mod loudness_pattern;
13pub mod modulation;
14pub mod partials;
15pub mod peaks;
16pub mod periodicity;
17pub mod pitch;
18pub mod score;
19pub mod self_similarity;
20pub mod sharpness;
21pub mod sliding;
22pub mod spectrum;
23pub mod stereo;
24pub(crate) mod stiff;
25
26pub(crate) fn scaled_pow2(samples_48k: f64, sr: f64) -> usize {
27 let n = (samples_48k * sr / 48_000.0).max(2.0);
28 let below = (n as usize).next_power_of_two() / 2;
29 match below >= 2 && n - below as f64 <= (2 * below) as f64 - n {
30 true => below,
31 false => (2 * below).max(2),
32 }
33}
34
35pub(crate) fn held(planes: &[&[f64]]) -> usize {
36 let len = planes
37 .first()
38 .expect("a reading reads at least one channel")
39 .len();
40 assert!(
41 planes.iter().all(|p| p.len() == len),
42 "a reading's channels are one length"
43 );
44 len
45}
46
47pub(crate) fn averaged(per_channel: Vec<Vec<f64>>) -> Vec<f64> {
49 let count = per_channel.len() as f64;
50 let mut each = per_channel.into_iter();
51 let mut out = each.next().unwrap_or_default();
52 for more in each {
53 for (sum, x) in out.iter_mut().zip(more) {
54 *sum += x;
55 }
56 }
57 out.iter_mut().for_each(|sum| *sum /= count);
58 out
59}
60
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
62pub enum Consumes {
63 ClosedForm,
64 Buffer,
65 Frames,
66}