1 /*
2 * din_info.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 #include "random.h"
9 
10 struct pointgotlis {
11   virtual void gotpoint () = 0;
12 };
13 
14 struct din_info {
15 
16 // applies to microtonal-keyboard only
17 // din used to be just the microtonal-keyboard
18 //
19   struct scroll_t {
20     double rept; // key repeat time
21     int rate; // scrolls per second
22     int dx, dy; // x & y amount per scroll
scroll_tdin_info::scroll_t23     scroll_t () : rate (80), dx(15), dy(1) {}
calc_repeat_timedin_info::scroll_t24     void calc_repeat_time () {if (rate) rept = 1./ rate;}
25   };
26   scroll_t scroll;
27 
28   int height; // din board height
29   int gater; // gater?
30   int delay; // delay?
31   int compress; // compressor?
32   int voice; // lead voice?
33   int anchor; // draw drone anchor?
34 	int vel; // draw velocity vectors of drones?
35 	int accel; // draw acceleration vectors of drones?
36   gravity_t gravity; // gravity vector
37 
38 	// drone bounce
39 	struct bouncet {
40 		enum {AHEAD, BACK, RANDOM};
41 		int style;
42 		int n;
43 		int speed;
bouncetdin_info::bouncet44 		bouncet () : style (AHEAD), n(1), speed (100) {}
45 	} bounce;
46 
47 	enum {DRONE_MESH, DRONE_PENDULUM};
48 	int create_this;
49 
50   // drone mesh
51   int rows, cols;
52 	struct mesh_vars_t {
53 		int order;
54 		int point;
55 		float duration;
56 		int sync;
57 		int use_drone_pend;
58 		int dpp;
59 		struct _apply_to{
60 			int active;
61 			int am;
62 			int fm;
setdin_info::mesh_vars_t::_apply_to63 			void set (int* what, int val) {
64 				*what = val;
65 				calc_active ();
66 			}
calc_activedin_info::mesh_vars_t::_apply_to67 			void calc_active () {
68 				active = am || fm;
69 			}
_apply_todin_info::mesh_vars_t::_apply_to70 			_apply_to () {
71 				active = am = fm = 0;
72 			}
73 		} apply_to;
74 
75 	} mesh_vars;
76 
77 	// drone pendulum
78 	struct drone_pend_t {
79 		int orient; // 0 - vertical, 1 - horizontal
80 		int n; // number of drones
81 		float depth; // am or fm depth depending on orientation
82 		float bpm; // start bpm of drones
83 	} drone_pend;
84 
85 	// show pitch & volume
86 	struct s_show_pitch_volume {
87 		int board;
88 		int drones;
s_show_pitch_volumedin_info::s_show_pitch_volume89 		s_show_pitch_volume () { board = drones = 0;}
90 	} show_pitch_volume;
91 
92 	// for drone rise, fall times
93   float drone_rise_time, drone_fall_time;
94 
95 	// drone snapping
96 	struct snap_t {
97 		enum {FREE=0, SLIDE, LOCK, MIRROR};
98 		int style;
99 		float left, right;
100 	} snap;
101 
102 	int set_unset_toggle; // for drone.mod_afx_vel and drone.snap
103 
104 	// ranges
105 	int sel_range;
106 	int mark_sel_range;
107 	int change_note;
108 	static const char* cnno [];
109 	static const char* cnn_opts[];
110 	int change_note_style;
111 
112 	// pitch/volume distribution
113 	struct dist_t {
114 		int vol;
115 		int pitch;
116 		int pix;
117 		static const int PIX_PER_LEVEL = 5;
dist_tdin_info::dist_t118 		dist_t () : vol(0), pitch(0), pix (PIX_PER_LEVEL) {}
119 	} dist;
120 
121 	int phrasor_right; // phrase position slider's right
122 
123 	int seloncre;
124 
125 	int voice_is_voice; // 0 => noise
126 
127   // scale/rotate center
128   struct cent {
129 
130     float x, y;
131     void draw ();
132 
133     enum {NONE, SET, FINISH};
134     int op;
135     int lmbclk;
136 
137     point<float> h;
138     void set (float hx, float hy);
139     int handle_input ();
140     pointgotlis* lis;
141 
centdin_info::cent142     cent () {
143       x = y = 0;
144       op = NONE;
145       lmbclk = 0;
146       lis = 0;
147     }
148 
149   } cen;
150 
151   int wand; // drone wanding?
152 
153   struct {
154     struct {
155       int which;
156     } dva;
157   } menu;
158 
159   din_info ();
160   void save ();
161 
162 };
163 
164