build system revision
[vg.git] / vg_audio_synth_bird.h
1 #pragma once
2
3 #ifndef BIRD_SAMPLE_RATE
4 #define BIRD_SAMPLE_RATE 44100
5 #endif
6
7 struct synth_bird_signature
8 {
9 float length, pause, /* timings in seconds */
10 x0,x1,x2,x3, /* polynomial coefficients for the fundemental */
11 v0,v1,v2,v3; /* volume of each oscillator */
12
13 int lfo_hz; /* LFO frequency (30-60hz) */
14 float fm; /* LFO modulation depth (+/- hz) */
15 };
16
17 struct synth_bird
18 {
19 struct{
20 int osc_main[4],
21 osc_lfo;
22 float volume[4];
23
24 float fundamental;
25 int x, length, /* position/length of signature in samples */
26 gate, adsr, /* adsr ranges 0->44100 */
27 frame; /* current frame of the pattern */
28
29 int lfo_hz;
30 float fm_depth;
31
32 int adsr_rise,
33 adsr_fall;
34 }
35 rt;
36
37 struct synth_bird_settings{
38 int tones[4][2]; /* fraction of the fundemental tone
39 for each oscillator */
40 float adsr_rise, /* rise/fall in seconds */
41 adsr_fall;
42
43 enum bird_lfo_wave{
44 k_bird_lfo_sine_approx,
45 k_bird_lfo_bipolar_poly
46 }
47 type;
48
49 int pattern_length;
50 struct synth_bird_signature pattern[];
51 }
52 settings;
53 };
54
55 void synth_bird_reset( struct synth_bird *bird );
56 u32 synth_bird_get_length_in_samples( struct synth_bird *bird );
57 void synth_bird_generate_samples( struct synth_bird *bird,
58 float *stereo_buffer, int samples );