summaryrefslogtreecommitdiff
path: root/src/monitor.rs
blob: ffe688a9f6cba37115af3fe559c82ad8a3d72b0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use super::*;
use synth::SampleBuffer;
use std::collections::HashMap;

pub struct VoiceDatum {
    pitch: Pitch,
    ampl: f32,
}

pub enum Datum {
    Voices(Vec<VoiceDatum>),
    Samples(SampleBuffer),
    Playtime(f32, f32),
}

pub enum DatumKind {
    Voices,
    Samples,
    Playtime,
}

impl<'a> From<&'a Datum> for DatumKind {
    fn from(d: &'a Datum) -> DatumKind {
        match *d {
            Datum::Voices(_) => DatumKind::Voices,
            Datum::Samples(_) => DatumKind::Samples,
            Datum::Playtime(_, _) => DatumKind::Playtime,
        }
    }
}

pub type Data = HashMap<DatumKind, Datum>;

pub trait Monitor {
    fn process(&mut self, data: &Data);
}

pub type MonBox = Box<Monitor>;