1 /*
2 * binaural_drone.h
3 * DIN Is Noise is copyright (c) 2006-2021 Jagannathan Sampath
4 * DIN Is Noise is released under GNU Public License 2.0
5 * For more information, please visit https://dinisnoise.org/
6 */
7 
8 #ifndef __BINAURAL_DRONE__
9 #define __BINAURAL_DRONE__
10 
11 #include "multi_curve.h"
12 #include "play.h"
13 #include <string>
14 
15 struct binaural_drone {
16 
17   std::string name;
18 	void make_name ();
19 	void make_name (float stepl, float stepr); // for fading in/out step > hz > name
20 	void make_name (float v); // for fading in/out vol > name
21 
22 	// L and R hz
23 	float l_hz, r_hz;
24 	float l_step, r_step;
25 	float l_step_prev, r_step_prev;
26 
27 	enum {SEPARATION = 2};
28 	float sep;
29 	void set_sep (float s);
30 
31 	// hz justification
32 	enum {LEFT=0, RIGHT, CENTER};
33 	int just;
34 	void set_just (int j);
35 
36 	// volume
37 	enum {VOLUME = 3};
38 	float vol;
39 	float vol_prev;
40 
41 	solver soll, solr;
42 	play playl, playr;
43 
44 	enum {INVALID = -1};
45 	binaural_drone (multi_curve* wav, float lhz, float rhz, float vol, int just, float sep, float lx = INVALID, float rx = INVALID);
46 
47 	void set_hz (int i, float _hz);
48 	void set_hz (float _lhz, float _rhz);
49 	void fill_hz ();
50 
51 	void render (float* L, float* R, float* vfdr, float* pfdr, int uv, int uh, int abort);
52 
53 	void set_vol (float vol);
54 
55 	struct fade_flags {
56 
57 		int vol;
58 		float vol_cur;
59 
60 		enum {NONE = 0, L, R, BOTH};
61 		int hz;
62 		float l_step_cur, r_step_cur;
63 
fade_flagsbinaural_drone::fade_flags64 		fade_flags () {vol = hz = NONE;}
65 
66 	} fading;
67 
68 	void calc_fader (float* out, float* alpha, int n, float v1, float v2, float* cur);
69 	void sync ();
70 
71 	int sel;
72 
73 };
74 
75 #endif
76