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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
ix!();

use crate::{
    WTOscillator,
};

impl OscillatorProcess for WTOscillator {

    fn process_block(&mut self, cfg: OscillatorProcessBlockCfg) { 

        let stereo = cfg.stereo;
        let drift  = cfg.drift;
        let depth  = cfg.fm_depth;
        let fm     = cfg.fm;
        let pitch0 = cfg.pitch;

        self.pitch_last = self.pitch_t;
        self.pitch_t = minf(148.0, pitch0);

        self.blitter.pitchmult_inv =
            maxd(1.0, 
                self.srunit.dsamplerate_os() * 
                (1.0 / 8.175798915) * 
                self.tuner.n2pinv::<f64,false>(self.pitch_t as f64)
            ) as f32;

        // This must be a real division, reciprocal-approximation is not
        self.blitter.pitchmult = 1.0 / self.blitter.pitchmult_inv; 

        // precise enough
        self.drift = drift;

        self.process_lag();

        self.update_tables();

        match fm {
            true  => self.process_block_fm(depth,stereo),
            false => self.process_block_nofm(stereo),
        }

        let mut hpfblock = WetBlock1::<BLOCK_SIZE_OS>::default();

        unsafe {
            self.li_hpf.store_block(hpfblock.buf.as_mut_ptr(), BLOCK_SIZE_OS_QUAD);
        }

        for k in (0..BLOCK_SIZE_OS).step_by(1) {
            self.do_block(k, stereo, &mut hpfblock);
        }

        unsafe {
            clear_block::<BLOCK_SIZE_OS_QUAD>(
                &mut self.blitter.oscbuffer_l[self.blitter.bufpos as usize]
            );

            if stereo {
                clear_block::<BLOCK_SIZE_OS_QUAD>(
                    &mut self.blitter.oscbuffer_r[self.blitter.bufpos as usize]
                );
            }
        }

        self.blitter.bufpos = 
            (self.blitter.bufpos + BLOCK_SIZE_OS as i32) & ((OB_LENGTH - 1) as i32);

        self.maybe_handle_overlap(stereo);
    }
}