summaryrefslogtreecommitdiff
path: root/src/synth/param.rs
blob: f679b566bdb7d041eaed1f4d31f05cfc6d4a818c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use super::*;

#[derive(Debug)]
pub struct Param {
    pub name: String,
    pub default: Sample,
    pub buf: SampleBuffer,
}

impl Generator for Param {
    fn eval<'a>(&'a mut self, params: &Parameters) -> &'a SampleBuffer {
        self.buf.set(*params.vars.get(&self.name).unwrap_or(&self.default));
        &self.buf
    }
    fn set_buffer(&mut self, buf: SampleBuffer) -> SampleBuffer {
        mem::replace(&mut self.buf, buf)
    }
}