bad char
[vg.git] / vg_audio_dsp.h
1 #pragma once
2
3 //#define VG_ECHO_LPF_BUTTERWORTH
4
5 #include "vg_platform.h"
6 #include "dep/glad/glad.h"
7 #include "vg_m.h"
8
9 struct vg_dsp
10 {
11 float *buffer;
12 u32 allocations;
13
14 u8 *view_texture_buffer;
15 GLuint view_texture;
16
17 float echo_distances[14],
18 echo_tunings[8],
19 reverb_wet_mix,
20 reverb_dry_mix;
21
22 vg_rand rand;
23 }
24 extern vg_dsp;
25
26 struct dsp_delay
27 {
28 u32 length, cur;
29 float *buffer;
30 };
31
32 struct dsp_lpf
33 {
34 float exponent;
35 float *buffer;
36 };
37
38 struct dsp_schroeder
39 {
40 struct dsp_delay M;
41 float gain;
42 };
43
44 struct dsp_biquad
45 {
46 f32 a0, a1, a2, b1, b2, c0, d0,
47 xnz1, xnz2, ynz1, ynz2, offset;
48 };
49
50 void vg_dsp_init( void );
51 void vg_dsp_free( void );
52 void dsp_update_tunings(void);
53 void vg_dsp_process( float *stereo_in, float *stereo_out );
54 void vg_dsp_update_texture( void );
55
56 f32 dsp_biquad_process( struct dsp_biquad *bq, f32 xn );
57 void dsp_init_biquad_butterworth_lpf( struct dsp_biquad *bq, f32 fc );
58 void dsp_read_delay( struct dsp_delay *delay, float *s, u32 t );
59 void dsp_write_delay( struct dsp_delay *delay, float *s );
60 void dsp_init_delay( struct dsp_delay *delay, float length );
61 void dsp_update_lpf( struct dsp_lpf *lpf, float freq );
62 void dsp_init_lpf( struct dsp_lpf *lpf, float freq );
63 void dsp_write_lpf( struct dsp_lpf *lpf, float *s );
64 void dsp_read_lpf( struct dsp_lpf *lpf, float *s );
65 void dsp_init_schroeder( struct dsp_schroeder *sch, float length, float gain );
66 void dsp_process_schroeder( struct dsp_schroeder *sch,
67 float *input, float *output );