-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathbl_osc.h
50 lines (44 loc) · 1.17 KB
/
bl_osc.h
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
/*
bl_osc.h
aleph-dsp
a band-limited oscillator with variable waveshape (sine-saw),
pulse width modulation (saw-square-pulse)
and phase modulation.
*/
#include "fix.h"
#include "types.h"
#define WAVE_TAB_SIZE 2048
#define WAVE_TAB_SIZE_1 (WAVE_TAB_SIZE - 1)
#define WAVE_TAB_MAX16 (WAVE_TAB_SIZE * FIX16_ONE - 1)
typedef struct _blOsc {
// table of wavetables
fract32** wavtab;
// normalized waveshape
fract32 shape;
// current table size
u32 tabSize;
// normalized frequency
fract32 freq;
// phase as fractional index
fix16 idx;
// phase as fractional index, modulated
fix16 idxMod;
// index increment
fix16 inc;
// inversion amount
fract32 invAmp;
// inversion phase
fix16 invPhase;
} blOsc;
// set waveshape (table)
extern void blosc_set_shape(blOsc* osc, fract32 shape);
// set frequency
extern void blosc_set_freq(blOsc* osc, fract32 freq);
// set modulated phase
extern void blosc_set_pm(blOsc* osc, fract32 pm);
// set inversion amount
extern void blosc_set_inv(blOsc* osc, fract32 inv);
// set inversion phase
extern void blosc_set_inv_phase(blOsc* osc, fix16 phase);
// get next value
extern fract32 blosc_get_next(blOsc* osc);