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
39
40
41
42
43
44
45
46
47
48
49
ix!();

use crate::{
    AudioInputOscillator,
    AudioInputOscillatorParam,
};

impl OscillatorProcess for AudioInputOscillator {

    fn process_block(&mut self, cfg: OscillatorProcessBlockCfg) { 
        match cfg.stereo {
            true  => self.process_block_stereo(cfg),
            false => self.process_block_mono(cfg),
        };
    }
}

impl AudioInputOscillator {

    fn process_block_mono(&mut self, _cfg: OscillatorProcessBlockCfg) { 

        let g:   f32 = self.tables.db_to_linear(self.pvalf(AudioInputOscillatorParam::Gain));
        let inp: f32 = limit_range(self.pvalf(AudioInputOscillatorParam::Input), -1.0, 1.0);

        let a: f32 = g * (1.0 - inp);
        let b: f32 = g * (1.0 + inp);

        for k in 0..BLOCK_SIZE_OS {
            self.out.l[k] = 
                a * self.synth_in.audio_in0(k) +
                b * self.synth_in.audio_in1(k);
        }
    }

    fn process_block_stereo(&mut self, _cfg: OscillatorProcessBlockCfg) { 

        let g:   f32 = self.tables.db_to_linear(self.pvalf(AudioInputOscillatorParam::Gain));
        let inp: f32 = limit_range(self.pvalf(AudioInputOscillatorParam::Input), -1.0, 1.0);

        let a: f32 = g * (1.0 - inp);
        let b: f32 = g * (1.0 + inp);

        for k in 0..BLOCK_SIZE_OS
        {
            self.out.l[k] = a * self.synth_in.audio_in0(k);
            self.out.r[k] = b * self.synth_in.audio_in1(k);
        }
    }
}