1 /*
2 * binaural_drones.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_DRONES__
9 #define __BINAURAL_DRONES__
10 
11 #include <vector>
12 #include "binaural_drone.h"
13 #include "ui.h"
14 #include "instrument.h"
15 #include "curve_editor.h"
16 #include "help.h"
17 
18 struct fade_info {
19 	std::string name;
20 	int active;
21 	int after;
22 	solver sol;
23 	float xt, dxt;
24 	float xu, xui;
25 	float duration;
26 
27 	fade_info ();
28 	void start (const std::string& _name = "op");
29 	int eval (float* out);
30 	void set_duration (float t);
31 	void complete ();
32 	void abort ();
33 
34 };
35 
36 struct i_binaural_drones;
37 struct waveform_listener : curve_listener {
38 	i_binaural_drones* sb;
39 	void edited (curve_editor* ed, int i);
40 };
41 
42 struct i_binaural_drones : instrument {
43 
44 	std::vector<binaural_drone*> binaural_drones;
45 	int num_binaural_drones;
46 
47 	multi_curve wav; // waveform shared by all binaural drones
48 	curve_editor waved; // waveform editor
49 	waveform_listener wavlis; // waveform edit listener
50 
51 	// binaural drone fading
52 	multi_curve fdrcrv; // fading curve
53 	fade_info pitch_fader, vol_fader;
54 
55 	float master_volume; // split among all binaural drones
56 
57 	float modulation_amount;
58 
59 	float starting_pitch; // starting pitch from where binaural drones are made
60 	float separation; // in hz between l and r of a binaural drone
61 	int pairs; // number of binaural drones
62 	float spacing; // inter drone spacing
63 
64   enum {START_PITCH=0, FROM_SCALE};
65   int keynote;
66 	int close_octave; // close octave when making binaural drones on notes of scale?
67   int change_key_note (int dir);
68 	int resize_separation;
69 
70 	// justification
71   int just;
72 
73 	help hlp;
74 
75 	i_binaural_drones ();
76 	~i_binaural_drones ();
77 
78 	int add (float _lhz, float _rhz, float _vol, int just, float sep, float lx = 0, float rx = 0);
79 	void remove (int w);
80 	void sync (int n, const std::string& lst);
81 	void list ();
82 	void load ();
83 	void save ();
84 	void update_players (multi_curve& mx);
85 	int handle_input ();
86   int change_justification (int dir);
87 	int render_audio (float* L, float* R);
88 	void enter ();
89 
90 	int abort;
91 	int busy ();
92 	int aborted ();
93 
94 	std::string get_sel_vol ();
95 
96 };
97 
98 extern i_binaural_drones binaural_drones0;
99 
100 #endif
101