Rev 2302 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1726 | jag | 1 | /* |
2 | * eval.cc |
||
2302 | jag | 3 | * DIN Is Noise is copyright (c) 2006-2025 Jagannathan Sampath |
1726 | jag | 4 | * DIN Is Noise is released under GNU Public License 2.0 |
5 | * For more information, please visit https://dinisnoise.org/ |
||
6 | */ |
||
1786 | jag | 7 | |
1719 | jag | 8 | #include "state_button.h" |
9 | #include "capturer.h" |
||
10 | #include "binaural_drones.h" |
||
11 | #include "console.h" |
||
12 | #include "din.h" |
||
13 | #include "ui_list.h" |
||
14 | #include "fractaliser.h" |
||
15 | #include "keyboard_keyboard.h" |
||
16 | #include "main.h" |
||
17 | #include "mondrian.h" |
||
18 | #include "oscilloscope.h" |
||
1723 | jag | 19 | #include "recorder.h" |
20 | #include "tcl_interp.h" |
||
1724 | jag | 21 | #include "authors_note.h" |
1719 | jag | 22 | |
23 | state_button* capturer_t::add () { |
||
24 | #ifdef __EVALUATION__ |
||
25 | if (ncaps == 1) { |
||
26 | cons << RED << "Can add more mouse captures in the Licensed Version of DIN Is Noise" << eol; |
||
27 | return 0; |
||
28 | } |
||
29 | #endif |
||
30 | state_button* sb = new state_button; |
||
31 | sb->set_pos (sbx, sby); |
||
32 | sbx += state_button::SIZE2; |
||
33 | title.add_child (sb); |
||
34 | caps.push_back (sb); |
||
35 | ++ncaps; |
||
36 | return sb; |
||
37 | } |
||
38 | |||
2067 | jag | 39 | i_binaural_drones::i_binaural_drones () : |
40 | wav ("binaural-drones-waveform.crv"), |
||
41 | waved ("binaural-drones-waveform.ed"), |
||
42 | fdrcrv ("fader.crv"), |
||
43 | hlp ("binaural-drones.hlp") |
||
44 | { |
||
1719 | jag | 45 | |
46 | #ifdef __EVALUATION__ |
||
47 | name = "binaural-drones [Evaluation Version]"; |
||
48 | #else |
||
49 | name = "binaural-drones"; |
||
50 | #endif |
||
51 | wavlis.sb = this; |
||
52 | waved.add (&wav, &wavlis); |
||
53 | extern curve_library wav_lib; |
||
54 | waved.attach_library (&wav_lib); |
||
55 | prev_mousex = prev_mousey = 0; |
||
56 | vol_fader.sol (&fdrcrv); |
||
57 | pitch_fader.sol (&fdrcrv); |
||
58 | abort = 0; |
||
59 | inst = 1; |
||
60 | } |
||
61 | |||
62 | |||
63 | din::din (cmdlist& cl) : |
||
64 | wave ("microtonal-keyboard-waveform.crv"), |
||
65 | waved ("microtonal-keyboard-waveform.ed"), |
||
66 | wavlis (wave_listener::MICROTONAL_KEYBOARD), |
||
67 | win (0, 0, view.xmax, view.ymax), |
||
68 | drone_wave ("drone.crv"), |
||
69 | droneed ("drone.ed"), |
||
70 | dronelis (wave_listener::DRONE), |
||
71 | fm ("fm", "fm.crv"), |
||
72 | am ("am", "am.crv"), |
||
73 | moded ("modulation.ed"), |
||
2264 | jag | 74 | swing ("swing.crv"), |
2265 | jag | 75 | accent ("accent.crv"), |
1719 | jag | 76 | gatr ("gr", "gater.crv"), |
77 | gated ("gater.ed"), |
||
78 | gatlib ("gater-patterns.lib"), |
||
79 | helptext ("din.hlp") |
||
80 | { |
||
2024 | jag | 81 | |
1719 | jag | 82 | #ifdef __EVALUATION__ |
83 | name = "microtonal-keyboard [Evaluation Version]"; |
||
84 | #else |
||
85 | name = "microtonal-keyboard"; |
||
86 | #endif |
||
87 | |||
88 | prev_mousex = prev_mousey = delta_mousex = delta_mousey = 0; |
||
89 | win_mousex = win_mousey = prev_win_mousex = prev_win_mousey = 0; |
||
90 | tonex = toney = 0; |
||
91 | |||
92 | current_range = 0; |
||
93 | |||
94 | adding = 0; |
||
95 | |||
96 | wanding = 0; |
||
97 | |||
98 | moving_drones = 0; |
||
99 | |||
100 | rising = falling = 0; |
||
101 | |||
102 | n_dvap = 0; |
||
103 | dvap = 0; |
||
1804 | jag | 104 | dcol = 0; |
1719 | jag | 105 | |
106 | dap = 0; |
||
107 | n_dap = 0; |
||
108 | |||
109 | num_drones = 0; |
||
110 | |||
111 | create_drone_pend = 0; |
||
112 | |||
113 | static const int cap = 1024; |
||
114 | selected_drones.reserve (cap); |
||
115 | |||
116 | scaleinfo.scl = this; |
||
117 | |||
118 | fdr_gater_prev_amount = 0; |
||
119 | |||
120 | rvec.reserve (cap); |
||
121 | svec.reserve (cap); |
||
122 | xforming = NONE; |
||
123 | |||
124 | num_selected_drones = num_browsed_drones = 0; |
||
125 | |||
126 | ptr_scaleinfo = &all_notes; |
||
127 | |||
128 | nstepz = 0; |
||
129 | con_pts = 0; |
||
130 | con_clr = 0; |
||
131 | con_size = 0; |
||
132 | totcon = 0; |
||
133 | _2totcon = 0; |
||
134 | ec = 0; |
||
135 | |||
136 | inst = 1; |
||
137 | |||
138 | dinfo.cen.lis = this; |
||
139 | |||
140 | } |
||
141 | |||
142 | void din::chuck () { |
||
143 | if (num_selected_drones > 1) { |
||
144 | #ifdef __EVALUATION__ |
||
145 | if (num_selected_drones > 3) { |
||
146 | cons << RED << "Chuck with more than 3 drones possible in the Licensed Version of DIN Is Noise" << eol; |
||
147 | return; |
||
148 | } |
||
149 | #endif |
||
150 | int yes = 1; |
||
151 | drone* sun = selected_drones[0]; |
||
152 | sun->chuck.set (yes, 0); |
||
1746 | jag | 153 | drone* planet = 0; |
1764 | jag | 154 | for (int i = 1; i < num_selected_drones; ++i) { |
155 | sun->trail.set (0); |
||
1746 | jag | 156 | planet = selected_drones[i]; |
1719 | jag | 157 | planet->chuck.set (yes, sun); |
158 | sun->chuck.sat = planet; |
||
159 | planet->chuck.sat = 0; |
||
160 | planet->chuck.calc (planet); |
||
161 | sun = planet; |
||
162 | } |
||
1747 | jag | 163 | planet->trail.set (10000); |
1719 | jag | 164 | cons << GREEN << "Chucked " << num_selected_drones << " drones" << eol; |
165 | } else { |
||
166 | cons << RED_A2D << eol; |
||
167 | } |
||
168 | } |
||
169 | |||
170 | void din::create_drone_pendulum () { |
||
171 | |||
172 | #ifdef __EVALUATION__ |
||
173 | cons << RED << "Can create drone pendulums only in the Licensed Version of DIN Is Noise" << eol; |
||
174 | return; |
||
175 | #endif |
||
176 | |||
1838 | jag | 177 | int o = dinfo.drone_pend.orient; |
178 | int no = !o; |
||
179 | double along[] = {rgn.width, rgn.height}; |
||
180 | int num_drones = dinfo.drone_pend.n; |
||
181 | |||
1719 | jag | 182 | CLEAR_SELECTED_DRONES |
183 | |||
184 | double xl [] = {double(rgn.left), double(rgn.midx)}; |
||
185 | double yl [] = {double((rgn.bottom + rgn.top) / 2.0), double(rgn.bottom)}; |
||
186 | double x = xl [o], y = yl [o]; |
||
187 | double* xy [] = {&x, &y}; |
||
188 | double& xyo = *xy[o]; |
||
189 | double depths [] = {double(rgn.top - rgn.midy), double(rgn.right - rgn.midx)}; |
||
190 | double depth = depths[o]; |
||
191 | |||
192 | int nd1 = num_drones - 1; |
||
193 | double spacing = along[o] * 1.0 / nd1; |
||
194 | double _1bylast = 1.0 / nd1; |
||
195 | double a = 0.0f, da = _1bylast; |
||
1838 | jag | 196 | float obpm = 0.0f; |
1764 | jag | 197 | for (int i = 0; i < num_drones; ++i) { |
1719 | jag | 198 | get_color::data.p = i * _1bylast; |
199 | drone* pd = add_drone (x, y); |
||
200 | drone& d = *pd; |
||
1814 | jag | 201 | if (!dinfo.seloncre) { |
202 | d.sel = 1; |
||
203 | selected_drones.push_back (pd); |
||
204 | } |
||
1719 | jag | 205 | d.mod.active = 1; |
206 | mod_params* mods [] = {&d.mod.am, &d.mod.fm}; |
||
207 | mod_params& mod = *mods[o]; |
||
208 | mod.depth = warp_depth (a) * depth; |
||
1838 | jag | 209 | obpm = warp_bpm (a) * dinfo.drone_pend.bpm; |
210 | mod.bv.set_bpm (obpm); |
||
211 | mods[no]->bv.set_bpm (obpm); |
||
1719 | jag | 212 | a += da; |
213 | xyo += spacing; |
||
214 | } |
||
215 | |||
1814 | jag | 216 | if (!dinfo.seloncre) print_selected_drones (); |
1719 | jag | 217 | |
218 | drone_pendulum_group* grp = new drone_pendulum_group (o, depth, selected_drones, num_selected_drones); |
||
219 | drone_pendulums.push_back (grp); |
||
220 | |||
221 | uis.dpeu.bpm.set_value (dinfo.drone_pend.bpm); |
||
222 | uis.dpeu.depth.set_value (depth); |
||
223 | |||
224 | cons << GREEN << "Created a drone pendulum of " << num_drones << " drones." << eol; |
||
225 | |||
226 | } |
||
227 | |||
228 | void din::create_drone_mesh () { |
||
229 | mkb_selector.mesh = 0; |
||
230 | #ifdef __EVALUATION__ |
||
231 | if (mkb_selector.rowcol > 4) { |
||
232 | cons << RED << "Can only create a 2 x 2 drone mesh with the Evaluation Version oF DIN Is Noise" << eol; |
||
233 | return; |
||
234 | } |
||
235 | #endif |
||
236 | mkb_selector.orderer = mkb_selector.orderers [dinfo.mesh_vars.order]; |
||
237 | mkb_selector.order_order (); |
||
238 | amd.triggert = dinfo.mesh_vars.duration * 1.0f / mkb_selector.rowcol; |
||
239 | amd.i = 0; |
||
240 | amd.j = mkb_selector.cols; |
||
1814 | jag | 241 | |
1719 | jag | 242 | CLEAR_SELECTED_DRONES |
243 | amd.start (); |
||
1814 | jag | 244 | |
1719 | jag | 245 | } |
246 | |||
247 | void din::change_range_note (int i, int d) { |
||
248 | #ifdef __EVALUATION__ |
||
249 | cons << RED << "Change Left/Right Note/Octave is available in the Licensed Version of DIN Is Noise" << eol; |
||
250 | return; |
||
251 | #endif |
||
252 | int cn = dinfo.change_note; |
||
253 | scale_info& si = *ptr_scaleinfo; |
||
254 | |||
255 | range& sr = ranges [dinfo.sel_range]; |
||
256 | if (cn) |
||
257 | sr.change_note (i, d, si); |
||
258 | else |
||
259 | sr.change_octave (i, d, si); |
||
260 | |||
261 | int ri, rj; |
||
262 | ri = rj = dinfo.sel_range; |
||
263 | if (i) { |
||
264 | int srr = dinfo.sel_range + 1; |
||
265 | if (srr < num_ranges) { |
||
266 | range& rsrr = ranges [srr]; |
||
267 | if (cn) |
||
268 | rsrr.change_note (0, d, si); |
||
269 | else |
||
270 | rsrr.change_octave (0, d, si); |
||
271 | ri = dinfo.sel_range; rj = srr; |
||
272 | } |
||
273 | } else { |
||
274 | int srl = dinfo.sel_range - 1; |
||
275 | if (srl > -1) { |
||
276 | range& rsrl = ranges [srl]; |
||
277 | if (cn) |
||
278 | rsrl.change_note (1, d, si); |
||
279 | else |
||
280 | rsrl.change_octave (1, d, si); |
||
281 | ri = srl; rj = dinfo.sel_range; |
||
282 | } |
||
283 | } |
||
284 | |||
285 | if (ri == rj) |
||
286 | refresh_drones (ri); |
||
287 | else |
||
288 | refresh_drones (ri, rj); |
||
289 | |||
290 | note& L = sr.notes[0]; |
||
291 | note& R = sr.notes[1]; |
||
292 | sprintf (BUFFER, "Left Note = %s @ %0.3f Hz, Right Note = %s @ %0.3f Hz, Hz/pixel = %0.3f", L.name.c_str(), L.hz, R.name.c_str(), R.hz, sr.hz_per_pix ()); |
||
293 | cons << YELLOW << BUFFER << eol; |
||
294 | |||
295 | } |
||
296 | |||
297 | int din::connect_drones () { |
||
298 | |||
299 | if (num_selected_drones < 2) { |
||
300 | cons << RED_A2D << eol; |
||
301 | return 0; |
||
302 | } |
||
303 | |||
304 | #ifdef __EVALUATION__ |
||
305 | #define MAX_CONN 4 |
||
306 | if (num_selected_drones > MAX_CONN) { |
||
307 | cons << RED << "Can only connect upto " << MAX_CONN << " drones in the Evaluation Version of DIN Is Noise" << eol; |
||
308 | return 0; |
||
309 | } |
||
310 | #endif |
||
311 | |||
312 | if (nstepz == 0) { |
||
313 | cons << RED << "Bad Steps value, please check Menu > Drone Tools > Steps" << eol; |
||
314 | return 0; |
||
315 | } |
||
316 | |||
317 | for (int s = 0; s < nstepz; ++s) { |
||
318 | int ds = stepz[s]; |
||
319 | for (int i = 0, j = 0; i < num_selected_drones; ++i) { |
||
320 | j = i + ds; |
||
321 | if (MENU.cb_conn_wrap.state) j %= num_selected_drones; |
||
322 | if (j < num_selected_drones) { |
||
323 | drone* pdi = selected_drones[i]; |
||
324 | drone& di = *pdi; |
||
325 | drone* pdj = selected_drones[j]; |
||
326 | drone& dj = *pdj; |
||
327 | if (can_connect (pdi, pdj)) { |
||
328 | double m = magnitude (pdi->cx, pdi->cy, pdj->cx, pdj->cy); |
||
329 | di.connections.push_back (pdj); |
||
330 | dj.connections.push_back (pdi); |
||
331 | di.mags.push_back (m); |
||
332 | dj.mags.push_back (m); |
||
333 | ++di.nconn; |
||
334 | ++dj.nconn; |
||
335 | totcon += 2; |
||
336 | } |
||
337 | } |
||
338 | } |
||
339 | } |
||
340 | |||
341 | _2totcon = 2 * totcon; |
||
342 | alloc_conns (); |
||
343 | |||
1797 | jag | 344 | if (MENU.trackcon.state) { |
345 | int last = num_selected_drones - 1; |
||
346 | drone* pld = selected_drones [last]; |
||
347 | drone *pdi = 0, *pdj = 0; |
||
348 | for (int i = 0, j = 1; i < last; ++i, ++j) { |
||
349 | pdi = selected_drones [i]; |
||
350 | pdj = selected_drones [j]; |
||
351 | push_back (trackers, pdi); |
||
352 | pdi->tracking = drone::POINT; |
||
353 | pdi->tracked_drone = pdj; |
||
354 | } |
||
355 | pld->tracking = drone::USE; |
||
356 | pld->tracked_drone = pdi; |
||
357 | push_back (trackers, pld); |
||
1719 | jag | 358 | } |
359 | |||
360 | return 1; |
||
361 | |||
362 | } |
||
363 | |||
1948 | jag | 364 | int plugin::apply (multi_curve& crv) { |
365 | |||
1719 | jag | 366 | #ifdef __EVALUATION__ |
367 | cons << RED << "Can apply plugins only in the Licensed Version of DIN Is Noise" << eol; |
||
368 | return 0; |
||
369 | #endif |
||
1948 | jag | 370 | |
371 | int n = points.size (); |
||
372 | if (n == 0) return 0; |
||
373 | |||
374 | crv.clear (0); |
||
375 | |||
376 | for (int i = 0; i < n; ++i) { |
||
377 | point<float>& p = points[i]; |
||
378 | crv.add_vertex (p.x, p.y); |
||
379 | crv.add_left_tangent (p.x, p.y); |
||
380 | crv.add_right_tangent (p.x, p.y); |
||
381 | } |
||
382 | |||
383 | if (shapeform) |
||
384 | crv.set_shapeform (1); |
||
385 | else |
||
386 | crv.evaluate (); |
||
387 | |||
388 | CRVED->set_curve_style (&crv); |
||
389 | |||
390 | return 1; |
||
391 | |||
392 | } |
||
393 | |||
394 | int fractaliser::apply (multi_curve& crv) { // needed bcos of tangents |
||
395 | #ifdef __EVALUATION__ |
||
396 | cons << RED << "Can apply plugins only in the Licensed Version of DIN Is Noise" << eol; |
||
397 | return 0; |
||
398 | #endif |
||
1719 | jag | 399 | render (); |
400 | int npts = points.size (); |
||
401 | if (npts == 0) return 0; |
||
402 | crv.clear (0); |
||
1952 | jag | 403 | // if (change_curve_name) crv.set_name (ss.str()); |
1719 | jag | 404 | |
405 | typedef std::list< point<float> >::iterator points_list_iterator; |
||
406 | points_list_iterator lti = left_tangents.begin (), rti = right_tangents.begin (); |
||
407 | for (int i = 0; i < npts; ++i) { |
||
408 | point<float>& p = points[i]; |
||
409 | point<float>& lt = *lti++; |
||
410 | point<float>& rt = *rti++; |
||
411 | crv.add_vertex (p.x, p.y); |
||
412 | crv.add_left_tangent (lt.x, lt.y); |
||
413 | crv.add_right_tangent (rt.x, rt.y); |
||
414 | } |
||
1947 | jag | 415 | crv.set_shapeform (shapeform); |
1719 | jag | 416 | crv.evaluate (); |
417 | return 1; |
||
418 | } |
||
419 | |||
420 | keyboard_keyboard::keyboard_keyboard () : |
||
2067 | jag | 421 | wave ("keyboard-keyboard-waveform.crv"), |
422 | waved ("keyboard-keyboard-waveform.ed"), |
||
423 | wavlis (wave_listener::KEYBOARD_KEYBOARD), |
||
424 | attackcrv ("attack.crv"), decaycrv ("decay.crv"), |
||
425 | attacked ("attack.ed"), decayed ("decay.ed"), |
||
426 | helptext ("keyboard-keyboard.hlp"), velcrv ("velocity.crv"), |
||
427 | veled ("velocity.ed"), vellib ("velocity.lib") |
||
1719 | jag | 428 | { |
2067 | jag | 429 | |
1719 | jag | 430 | #ifdef __EVALUATION__ |
431 | name = "keyboard-keyboard [Evaluation Version]"; |
||
432 | #else |
||
433 | name = "keyboard-keyboard"; |
||
434 | #endif |
||
435 | last_mousex = last_mousey = -1; |
||
436 | num_triggered_notes = 0; |
||
437 | scaleinfo.scl = this; |
||
438 | show_nearby_notes = 0; |
||
439 | |||
440 | fname = "keyboard-keyboard.settings"; |
||
441 | ifstream file ((user_data_dir + fname).c_str (), ios::in); |
||
442 | if (!file) { |
||
443 | dlog << "!!! couldnt load: " << fname << endl; |
||
444 | } else { |
||
445 | string ignore; |
||
446 | file >> ignore >> show_nearby_notes; |
||
447 | file >> ignore >> ATTACK_TIME; |
||
448 | file >> ignore >> DECAY_TIME; |
||
449 | file >> ignore >> NOTE_VOLUME; |
||
450 | file >> ignore >> PITCH_BEND; |
||
451 | file >> ignore >> trig_what; |
||
452 | PITCH_BEND_PER_PIXEL = 0.01f * PITCH_BEND; |
||
453 | } |
||
454 | |||
455 | inst = 1; |
||
456 | |||
457 | } |
||
458 | |||
459 | |||
460 | extern const char* INSTRUMENTS []; |
||
461 | extern const char* INSTRUMENTS_SHORT []; |
||
462 | extern const int NUM_INSTRUMENTS, LAST_INSTRUMENT; |
||
463 | extern int CURRENT_INSTRUMENT; |
||
464 | extern string INSTRUMENT; |
||
465 | extern instrument* INSTRUMENT_PTR []; |
||
466 | extern checkbutton* LAST_TABS []; |
||
467 | extern oscilloscope scope; |
||
468 | |||
469 | void load_instrument (instrument* inst) { |
||
470 | |||
471 | if (inst == 0) inst = get_current_instrument (); |
||
472 | |||
473 | MENU.b_microtonal_keyboard.turn_off (DONT_CALL_LISTENER); |
||
474 | MENU.b_keyboard_keyboard.turn_off (DONT_CALL_LISTENER); |
||
475 | MENU.b_mondrian.turn_off (DONT_CALL_LISTENER); |
||
476 | MENU.b_binaural_drones.turn_off (DONT_CALL_LISTENER); |
||
477 | |||
478 | if (inst == &keybd2) { |
||
479 | MENU.b_keyboard_keyboard.turn_on (); |
||
480 | MENU.next_tab = MENUP.cb_instrument; |
||
481 | CURRENT_INSTRUMENT = 0; |
||
482 | } else if (inst == &din0) { |
||
483 | CURRENT_INSTRUMENT = 1; |
||
484 | MENU.b_microtonal_keyboard.turn_on (); |
||
485 | checkbutton* pcb = LAST_TABS [CURRENT_INSTRUMENT]; |
||
486 | if (pcb) { |
||
487 | MENU.next_tab = pcb; |
||
488 | } else { |
||
489 | if (din0.num_selected_drones) |
||
490 | MENU.next_tab = MENUP.cb_mkb_drone_params; |
||
491 | else |
||
492 | MENU.next_tab = MENUP.cb_mkb_voice; |
||
493 | } |
||
494 | } else if (inst == &mondrian0) { |
||
495 | CURRENT_INSTRUMENT = 2; |
||
496 | MENU.b_mondrian.turn_on (); |
||
497 | MENU.cb_instrument.turn_on (); |
||
498 | checkbutton* pcb = LAST_TABS [CURRENT_INSTRUMENT]; |
||
499 | if (pcb) MENU.next_tab = pcb; else MENU.next_tab = MENUP.cb_mon_tools; |
||
500 | } else /*if (inst == &binaural_drones0)*/ { |
||
501 | CURRENT_INSTRUMENT = 3; |
||
502 | MENU.b_binaural_drones.turn_on (); |
||
503 | MENU.cb_instrument.turn_on (); |
||
504 | checkbutton* pcb = LAST_TABS [CURRENT_INSTRUMENT]; |
||
505 | if (pcb) MENU.next_tab = pcb; else MENU.next_tab = MENUP.cb_binaural_drones_tools; |
||
506 | } |
||
507 | |||
508 | scope.load_current_instrument (); |
||
509 | MENU.scol.setup (); |
||
510 | |||
511 | MENU.next_tab_instr = inst; |
||
512 | uis.set_current (inst); |
||
2250 | jag | 513 | |
1719 | jag | 514 | MENU.hide_editors (); |
515 | MENU.show_editors (inst); |
||
516 | |||
517 | #ifdef __EVALUATION__ |
||
518 | if (dynamic_cast<ui*>(inst) != &anote) |
||
519 | #endif |
||
520 | |||
521 | MENU.setup_tabs (inst); |
||
522 | |||
523 | setup_plugin_labels (); |
||
524 | cons ("setup-editors"); |
||
525 | uis.update_bottom_line (); |
||
526 | |||
527 | } |
||
528 | |||
529 | extern string VERSION_NUMBER; |
||
530 | extern string APP_NAME; |
||
531 | |||
532 | void make_app_name () { |
||
533 | #ifdef __EVALUATION__ |
||
534 | APP_NAME = "DIN Is Noise " + VERSION_NUMBER + " | EVALUATION VERSION"; |
||
535 | #elif defined __LICENSED__ |
||
536 | APP_NAME = "DIN Is Noise " + VERSION_NUMBER + " | LICENSED VERSION"; |
||
537 | #endif |
||
538 | } |
||
1723 | jag | 539 | |
540 | void range_mod_lis::clicked (button& b) { |
||
541 | if (&b == MENUP.b_rm_start_all) { |
||
542 | #ifdef __EVALUATION__ |
||
543 | cons << RED << "Range modulation available only on the Licensed Version of DIN Is Noise" << eol; |
||
544 | return; |
||
545 | #endif |
||
546 | din0.set_ran_mod (1); |
||
547 | } else if (&b == MENUP.b_rm_stop_all) { |
||
548 | din0.set_ran_mod (0); |
||
549 | } else if (&b == MENUP.b_rm_toggle) { |
||
550 | #ifdef __EVALUATION__ |
||
551 | cons << RED << "Range modulation available only on the Licensed Version of DIN Is Noise" << eol; |
||
552 | return; |
||
553 | #endif |
||
554 | din0.toggle_ran_mod (); |
||
555 | } else if (&b == MENUP.b_rm_pause_resume) { |
||
556 | #ifdef __EVALUATION__ |
||
557 | cons << RED << "Range modulation available only on the Licensed Version of DIN Is Noise" << eol; |
||
558 | return; |
||
559 | #endif |
||
560 | din0.pause_resume_ran_mod (); |
||
561 | } else { |
||
562 | din0.dinfo.sel_range = din0.current_range; |
||
563 | MENU.load_range (din0.dinfo.sel_range); |
||
564 | } |
||
565 | } |
||
566 | |||
567 | void range_mod_lis::changed (checkbutton& cb) { |
||
568 | |||
569 | if (&cb == MENUP.cb_mod_ran) { |
||
570 | #ifdef __EVALUATION__ |
||
571 | cons << RED << "Range modulation available only on the Licensed Version of DIN Is Noise" << eol; |
||
572 | cb.set_state (!cb.state, 0); |
||
573 | return; |
||
574 | #endif |
||
575 | modulator& srm = din0.ranges[din0.dinfo.sel_range].mod; |
||
576 | int& a = srm.active; |
||
577 | if (a) a *= cb.state; else a = cb.state; |
||
578 | } else |
||
579 | din0.dinfo.mark_sel_range = cb.state; |
||
580 | } |
||
581 | |||
582 | void recording_listener::clicked (button& b) { |
||
583 | if (&b == MENUP.b_clear_record) { |
||
584 | recorder0.clear (); |
||
585 | uis.cb_record.set_text ("Record"); |
||
586 | MENU.cb_record.set_text ("Record"); |
||
587 | if (MENU.show) MENU.toggle (); |
||
588 | } else { |
||
589 | #ifdef __EVALUATION__ |
||
590 | cons << RED << "Can save recordings only in the Licensed Version of DIN Is Noise" << eol; |
||
591 | return; |
||
592 | #endif |
||
593 | recorder0.start_saving (); |
||
594 | } |
||
595 | } |
||
596 | |||
597 | |||
598 | void binaural_drones_listener::clicked (button& b) { |
||
599 | |||
600 | if (&b == MENUP.bbd_select_all) { |
||
601 | MENU.il_binaural_drones.select (1); // 1 == all |
||
602 | } else if (&b == MENUP.bbd_select_none) { |
||
603 | MENU.il_binaural_drones.select (0); // 0 == none |
||
2010 | jag | 604 | //MENU.il_binaural_drones.last = 0; |
1723 | jag | 605 | } else if (&b == MENUP.bbd_invert_select) { |
606 | MENU.il_binaural_drones.invert_select (); |
||
2010 | jag | 607 | //if (MENU.il_binaural_drones.num_selected() == 0) MENU.il_binaural_drones.last = 0; |
1723 | jag | 608 | } else if (&b == MENUP.bbd_select2) { |
609 | if (select_rule == ID) { |
||
610 | tokenizer tv (MENU.bdf_value.text); |
||
611 | int s, e, i; tv >> s >> e >> i; |
||
612 | --s; --e; // bcos starts at 1 on ui :( |
||
613 | clamp (0, s, MENU.il_binaural_drones.n); |
||
614 | clamp (0, e, MENU.il_binaural_drones.n); |
||
615 | clamp (1, i, MENU.il_binaural_drones.n); |
||
616 | sprintf (BUFFER, "wrap-get-nums %d %d %d", s, e, i); |
||
617 | } else { |
||
618 | const char* get [] = {"left", "right", "separation", "volume"}; |
||
619 | const char* op [] = {"==", ">=", "<=", "<>"}; |
||
620 | sprintf (BUFFER, "filter-binaurals %s %s %s", get[select_what], op[select_rule], MENU.bdf_value.text.c_str()); |
||
621 | } |
||
622 | interpreter (BUFFER); |
||
623 | tokenizer tz (interpreter.result); |
||
624 | if (!MENU.il_binaural_drones.select_these (tz)) cons << RED << "No matching binaural drone pairs found!" << eol; |
||
625 | } |
||
626 | |||
627 | if (binaural_drones0.busy ()) { |
||
628 | cons << RED << "Still executing your command, please wait or ESC to abort" << YELLOW << eol; |
||
629 | return; |
||
630 | } |
||
631 | |||
2107 | jag | 632 | binaural_drones0.separation = MENU.sp_bd_separation.value; |
2110 | jag | 633 | binaural_drones0.master_volume = (float) MENU.lf_master_volume.fld / 100.0f; |
2107 | jag | 634 | binaural_drones0.pairs = MENU.sp_bd_pairs.value; |
1723 | jag | 635 | binaural_drones0.close_octave = MENU.cb_close_octave.state; |
636 | binaural_drones0.resize_separation = MENU.cb_resize_separation.state; |
||
637 | |||
638 | const char* selerr = "Please select some binaural drone pairs"; |
||
639 | if (&b == MENUP.b_create_binaurals_on_notes) { |
||
640 | |||
641 | #ifdef __EVALUATION__ |
||
642 | cons << RED << "Available only in the Licensed Version of DIN Is Noise" << eol; |
||
643 | return; |
||
644 | #endif |
||
645 | |||
646 | cons << YELLOW << "Creating binaural drones [fading in], please wait" << eol; |
||
647 | float tonic; |
||
648 | if (binaural_drones0.keynote == i_binaural_drones::START_PITCH) |
||
649 | tonic = binaural_drones0.starting_pitch; |
||
650 | else |
||
651 | tonic = get_tonic (&binaural_drones0); |
||
652 | string intervals; |
||
653 | vector<string>& notes = binaural_drones0.scaleinfo.notes; |
||
654 | int j = notes.size (); if (binaural_drones0.close_octave == 0) --j; |
||
655 | for (int i = 0; i < j; ++i) intervals = intervals + notes[i] + " "; |
||
656 | stringstream cmd; |
||
657 | cmd << "create-binaurals-on-notes " << tonic << ' ' << binaural_drones0.separation << " {" << intervals << "}" << ' ' << binaural_drones0.resize_separation; |
||
658 | interpreter (cmd.str()); |
||
659 | MENU.changed (MENU.cb_binaural_drones_edit); |
||
660 | } else if (&b == MENUP.b_create_binaurals_from_pitch) { |
||
661 | |||
662 | #ifdef __EVALUATION__ |
||
663 | if (binaural_drones0.num_binaural_drones || binaural_drones0.pairs > 1) { |
||
664 | cons << RED << "Can create > 1 binaural drone pair in the Licensed Version of DIN Is Noise" << eol; |
||
665 | return; |
||
666 | } |
||
667 | #endif |
||
668 | |||
669 | cons << YELLOW << "Creating binaural drones [fading in], please wait" << eol; |
||
670 | string start_pitch = MENU.lf_bd_start_pitch.fld.text; |
||
671 | string spacing = MENU.lf_bd_spacing.fld.text; |
||
672 | sprintf (BUFFER, "create-binaurals-from-pitch %f %f %d %f", binaural_drones0.starting_pitch, binaural_drones0.separation, binaural_drones0.pairs, binaural_drones0.spacing); |
||
673 | interpreter (BUFFER); |
||
674 | MENU.changed (MENU.cb_binaural_drones_edit); |
||
675 | } else if (&b == MENUP.bbd_sync) { |
||
676 | if (MENU.il_binaural_drones.num_selected ()) { |
||
677 | cons << YELLOW << "Syncing (fade-out + sync + fade-in) : please wait or ESC to abort" << eol; |
||
678 | interpreter ("sync-selected-binaurals"); |
||
679 | } else { |
||
680 | cons << RED << selerr << eol; |
||
681 | } |
||
682 | } else if (&b == MENUP.bbd_delete) { |
||
683 | if (MENU.il_binaural_drones.num_selected ()) { |
||
684 | cons << YELLOW << "Deleting (after fade-out) : please wait or ESC to abort" << eol; |
||
685 | interpreter ("delete-selected-binaurals"); |
||
686 | } else { |
||
687 | cons << RED << selerr << eol; |
||
688 | } |
||
689 | } else if (&b == MENUP.bd_modulate_up) { |
||
690 | if (MENU.il_binaural_drones.num_selected ()) { |
||
691 | cons << YELLOW << "Modulating up: please wait or ESC to abort" << eol; |
||
692 | sprintf (BUFFER, "modulate-selected-binaurals %f", binaural_drones0.modulation_amount); |
||
693 | interpreter (BUFFER); |
||
694 | } else { |
||
695 | cons << RED << selerr << eol; |
||
696 | } |
||
697 | } else if (&b == MENUP.bd_modulate_down) { |
||
698 | if (MENU.il_binaural_drones.num_selected ()) { |
||
699 | cons << YELLOW << "Modulating down: please wait or ESC to abort" << eol; |
||
700 | sprintf (BUFFER, "modulate-selected-binaurals %f", 1.0f / binaural_drones0.modulation_amount); |
||
701 | interpreter (BUFFER); |
||
702 | } else { |
||
703 | cons << RED << selerr << eol; |
||
704 | } |
||
705 | } else if (&b == MENUP.bbd_flip) { |
||
706 | if (MENU.il_binaural_drones.num_selected ()) { |
||
707 | for (int i = 0; i < MENU.il_binaural_drones.n; ++i) { |
||
708 | if (MENU.il_binaural_drones.items[i].sel) { |
||
709 | binaural_drone* bi = binaural_drones0.binaural_drones[i]; |
||
710 | float r_hz = bi->l_hz, l_hz = bi->r_hz; |
||
711 | bi->set_hz (binaural_drone::LEFT, l_hz); |
||
712 | bi->set_hz (binaural_drone::RIGHT, r_hz); |
||
713 | } |
||
714 | } |
||
715 | binaural_drones0.pitch_fader.start ("Pitch flip"); |
||
716 | cons << YELLOW << "Flipping Hz: please wait or ESC to abort" << eol; |
||
717 | interpreter ("flip-selected-binaurals"); |
||
718 | } else { |
||
719 | cons << RED << selerr << eol; |
||
720 | } |
||
721 | } |
||
722 | } |
||
723 | |||
724 | |||
725 | void mondrian::load_settings (ifstream& file) { |
||
726 | |||
727 | std::string ignore; |
||
728 | |||
729 | #ifdef __EVALUATION__ |
||
730 | name = "Mondrian [Evaluation Version]"; |
||
731 | #else |
||
732 | name = "Mondrian"; |
||
733 | #endif |
||
734 | |||
735 | float l, b, r, t; |
||
736 | file >> ignore >> l >> b >> r >> t; |
||
737 | win.set (l, b, r, t); |
||
738 | |||
739 | file >> ignore >> win_chunk.x >> win_chunk.y; |
||
740 | file >> ignore >> obj_chunk.x >> obj_chunk.y; |
||
741 | |||
742 | win_per_obj (win_chunk.x / obj_chunk.x, win_chunk.y / obj_chunk.y); |
||
743 | obj_per_win (obj_chunk.x / win_chunk.x , obj_chunk.y / win_chunk.y); |
||
744 | |||
745 | file >> ignore >> win_resolution; |
||
746 | |||
1902 | jag | 747 | /*float dummy1 = 0, dummy2 = 0; |
748 | win2obj (win_resolution, dummy1, obj_resolution, dummy2);*/ |
||
749 | |||
1723 | jag | 750 | file >> ignore >> label_hz_vol; |
751 | file >> ignore >> min_voices; |
||
752 | file >> ignore >> auto_del_rect.active; |
||
753 | file >> ignore >> auto_del_rect.triggert; |
||
754 | file >> ignore >> auto_split_rect.active; |
||
755 | file >> ignore >> auto_split_rect.triggert; |
||
756 | file >> ignore >> auto_split_orient; |
||
757 | file >> ignore >> auto_split_at; |
||
758 | file >> ignore >> split_leaf; |
||
759 | file >> ignore >> delete_leaf; |
||
760 | file >> ignore >> mondrian::min_split_size; |
||
761 | file >> ignore >> draw__boxes; |
||
762 | file >> ignore >> draw_ball.position; |
||
763 | file >> ignore >> draw_ball.heading; |
||
764 | file >> ignore >> draw__notes; |
||
765 | file >> ignore >> label_notes; |
||
766 | file >> ignore >> fill_boxes; |
||
767 | file >> ignore >> num_boxes; |
||
768 | file >> ignore >> added_ball_type; |
||
769 | file >> ignore >> cursor; |
||
770 | file >> ignore >> auto_adjust_voices; |
||
771 | file >> ignore >> slit::HALF_SIZE; |
||
772 | file >> ignore >> MENU.cb_turn_sync.state; |
||
773 | file >> ignore >> MENU.cb_speed_sync.state; |
||
2052 | jag | 774 | file >> ignore >> MENU.texture.state; |
1723 | jag | 775 | MENU.cb_turn_sync.set_state (MENU.cb_turn_sync.state); |
776 | MENU.cb_speed_sync.set_state (MENU.cb_speed_sync.state); |
||
2053 | jag | 777 | MENU.texture.set_state (MENU.texture.state); |
1723 | jag | 778 | |
779 | } |
||
780 | |||
781 | |||
782 | extern float MIN_TIME; |
||
783 | extern int can_wheel (); |
||
784 | extern int IPS; |
||
785 | |||
786 | int mondrian::handle_input () { |
||
787 | |||
788 | if (moving_balls) move_balls (win.mousex - win.mousex_prev, win.mousey - win.mousey_prev); |
||
789 | if (editing_slit) slit_lip.edit (); else |
||
790 | if (editing_edge) set_edge (hit, edge, win.mousex, win.mousey); |
||
791 | |||
792 | if (lmb) { |
||
793 | if (lmb_clicked == 0) { |
||
794 | if (stop_moving_balls ()); |
||
795 | else if (stop_editing_slit ()); |
||
796 | else if (stop_editing_edge ()); |
||
797 | else if (try_slitting ()); |
||
798 | else { |
||
799 | finding f; find (root, win.mousex, win.mousey, f); |
||
800 | hit = f.found; |
||
801 | if (hit) { // box hit |
||
802 | box<float>& bf = hit->extents; |
||
803 | edge = bf.get_edge_hit (win.mousex, win.mousey, gutter2); |
||
804 | if (edge != edge::NONE) { // edge hit |
||
805 | // slit hit? |
||
806 | slit_lip.slitt = 0; |
||
807 | float* curs [rect::nedges] = {&win.mousex, &win.mousey, &win.mousex, &win.mousey}; |
||
808 | slit_lip.cur = curs[edge]; |
||
809 | if (get_slit_lip (slit_lip, hit, edge, *slit_lip.cur)) { // slit hit! |
||
810 | float* prevs [rect::nedges] = {&win.mousex_prev, &win.mousey_prev, &win.mousex_prev, &win.mousey_prev}; |
||
811 | slit_lip.prev = prevs[edge]; |
||
812 | toggle_flag (editing_slit, "Just move mouse to edit slit. ESC to stop."); // edit this slit |
||
813 | } else toggle_flag (editing_edge, "Just move mouse to move edge. ESC or click to stop."); // edit this edge |
||
814 | mon_selector.abort (); |
||
815 | } |
||
816 | } |
||
817 | } |
||
818 | } |
||
819 | |||
820 | if (adding_balls) { // user is adding balls |
||
821 | if (started_making_ball == 0) { |
||
822 | started_making_ball = 1; |
||
823 | new_ball = new ball (added_ball_type); |
||
824 | new_ball->set_velocity (1.0f, 1.0f); |
||
825 | mon_selector.abort (); |
||
826 | } else { |
||
827 | float dx, dy; |
||
828 | win.diff_mouse (dx, dy); |
||
829 | if (dx == 0 && dy == 0); else new_ball->set_velocity (dx, dy); |
||
830 | new_ball->x = win.mousex; |
||
831 | new_ball->y = win.mousey; |
||
832 | } |
||
833 | } |
||
834 | |||
835 | lmb_clicked = 1; |
||
836 | |||
837 | } else { |
||
838 | lmb_clicked = 0; |
||
839 | if (new_ball) { |
||
840 | new_ball->frozen = 0; |
||
841 | finding f; find (root, new_ball->x, new_ball->y, f); |
||
842 | #ifdef __EVALUATION__ |
||
843 | if (num_balls) { |
||
844 | cons << RED << "Can create more balls in the Licensed Version of DIN Is Noise" << eol; |
||
845 | f.found = 0; |
||
846 | } |
||
847 | #endif |
||
848 | if (f.found) { |
||
849 | new_ball->R = f.found; |
||
850 | f.found->balls.push_back (new_ball); |
||
851 | balls.push_back (new_ball); |
||
852 | browse.clear (); |
||
853 | clear_selected<ball> (selected_balls, num_selected_balls); |
||
854 | new_ball->select = 1; |
||
855 | selected_balls.push_back (new_ball); |
||
856 | ++num_selected_balls; |
||
857 | ++num_balls; |
||
858 | after_selection (); |
||
859 | } else |
||
860 | delete new_ball; |
||
861 | |||
862 | started_making_ball = 0; |
||
863 | new_ball = 0; |
||
864 | } |
||
865 | } |
||
866 | |||
867 | static const double reptf = 1./7, repts = 1./48.; |
||
868 | double repts1 = 1./IPS; |
||
869 | |||
870 | // octave shift |
||
871 | if (keypressed (SDLK_z)) {if (!modulate_balls (-1)) modulate_down ();} |
||
872 | else if (keypressed (SDLK_x)) {if (!modulate_balls (1)) modulate_up ();} |
||
873 | |||
874 | // split box |
||
875 | if (keypressed (SDLK_r)) { // vertically |
||
876 | if (recting ()) ; else { |
||
877 | if (SHIFT) |
||
878 | multi_split_rect (split::VERTICAL); // vertically at notes |
||
879 | else if (CTRL) |
||
880 | multi_split_rect (num_boxes, split::VERTICAL); // vertically make num_boxes |
||
881 | else |
||
882 | split_rect (split::VERTICAL, win.mousex); // into 2 new boxes |
||
883 | } |
||
884 | } |
||
885 | else if (keypressed (SDLK_f)) { // horizontally |
||
886 | if (recting ()) ; else { |
||
887 | if (SHIFT) |
||
888 | multi_split_rect (split::HORIZONTAL); // horizontally at notes |
||
889 | else if (CTRL) |
||
890 | multi_split_rect (num_boxes, split::HORIZONTAL); // horizontally make num_boxes |
||
891 | else |
||
892 | split_rect (split::HORIZONTAL, win.mousey); // into 2 new boxes |
||
893 | } |
||
894 | } |
||
895 | else if (keypressed (SDLK_t)) { |
||
896 | if (recting ()) ; else { |
||
897 | if (SHIFT || CTRL) |
||
898 | make_nxn_grid (); // make grid of num_boxes x num_boxes |
||
899 | else |
||
900 | make_note_grid (); // make note grid |
||
901 | } |
||
902 | } |
||
903 | |||
904 | if (keypressed(SDLK_RETURN)) toggle_triggered_sound (); |
||
905 | |||
906 | // change ball speed |
||
907 | static const float delta_speed = 0.25; |
||
908 | if (keypressedd (SDLK_LEFTBRACKET)) change_speed (MENU.sp_mondrian_change_speed, -delta_speed); |
||
909 | else if (keypressedd (SDLK_RIGHTBRACKET)) change_speed (MENU.sp_mondrian_change_speed, delta_speed); |
||
910 | |||
911 | // change ball attack & decay time |
||
912 | if (keypressedd (SDLK_SEMICOLON, reptf, repts)) { |
||
913 | if (SHIFT) { |
||
914 | delta_attack_time -= MIN_TIME; |
||
915 | if (delta_attack_time < MIN_TIME) delta_attack_time = MIN_TIME; |
||
916 | sprintf (BUFFER, "delta attack time = %0.3f secs", delta_attack_time); |
||
917 | cons << BUFFER << eol; |
||
918 | } else |
||
919 | --MENU.sp_mondrian_change_attack_time; |
||
920 | } |
||
921 | else if (keypressedd (SDLK_QUOTE, reptf, repts)) { |
||
922 | if (SHIFT) { |
||
923 | delta_attack_time += MIN_TIME; |
||
924 | sprintf (BUFFER, "delta attack time = %0.3f secs", delta_attack_time); |
||
925 | cons << BUFFER << eol; |
||
926 | } else |
||
927 | ++MENU.sp_mondrian_change_attack_time; |
||
928 | } |
||
929 | else if (keypressedd (SDLK_COMMA, reptf, repts)) { |
||
930 | if (SHIFT) { |
||
931 | delta_decay_time -= MIN_TIME; |
||
932 | if (delta_decay_time < MIN_TIME) delta_decay_time = MIN_TIME; |
||
933 | sprintf (BUFFER, "delta decay time = %0.3f secs", delta_decay_time); |
||
934 | cons << BUFFER << eol; |
||
935 | } else |
||
936 | --MENU.sp_mondrian_change_decay_time; |
||
937 | } |
||
938 | else if (keypressedd (SDLK_PERIOD, reptf, repts)) { |
||
939 | if (SHIFT) { |
||
940 | delta_decay_time += MIN_TIME; |
||
941 | sprintf (BUFFER, "delta decay time = %0.3f secs", delta_decay_time); |
||
942 | cons << BUFFER << eol; |
||
943 | } else |
||
944 | ++MENU.sp_mondrian_change_decay_time; |
||
945 | } |
||
946 | |||
947 | // change ball course |
||
948 | if (keypressedd (SDLK_o, reptf, repts1)) { |
||
949 | if (CTRL) |
||
950 | toggle_auto_rotate (1); // always change anti-clockwise |
||
951 | else if (SHIFT) { |
||
952 | change_ball_dtheta (-1); |
||
953 | } |
||
954 | else |
||
955 | rotate_velocity (+1); |
||
956 | } else if (keypressedd (SDLK_p, reptf, repts1)) { |
||
957 | if (CTRL) |
||
958 | toggle_auto_rotate (-1); // always change clockwise |
||
959 | else if (SHIFT) { |
||
960 | change_ball_dtheta (+1); |
||
961 | } |
||
962 | else |
||
963 | rotate_velocity (-1); // rotate velocity vector clockwise |
||
964 | } |
||
965 | |||
966 | // ball / slit selection |
||
967 | if (keypressed (SDLK_l)) { |
||
968 | select_all_targets (); |
||
969 | } else if (keypressed (SDLK_i)) { |
||
970 | if (SHIFT) |
||
971 | MENU.cb_label_hz_vol.toggle (); // label pitch/volume of triggered notes |
||
972 | else |
||
973 | invert_selected_targets (); |
||
974 | } else if (keypressed (SDLK_k)) { // box |
||
975 | select_box_targets (); |
||
976 | } else if (keypressed (SDLK_n)) { |
||
977 | clear_selected_targets (); |
||
978 | } |
||
979 | |||
980 | // ball browsing |
||
981 | if (keypressedd (SDLK_LEFT)) browse_ball (-1); // MENU.bolis.picked (MENU.ol_browse_balls.option, -1); |
||
982 | else if (keypressedd (SDLK_RIGHT)) browse_ball (+1); // MENU.bolis.picked (MENU.ol_browse_balls.option, +1); |
||
983 | |||
984 | // freeze/thaw balls |
||
985 | if (keypressed (SDLK_SPACE)) { |
||
986 | list<ball*>& balls = get_balls (); |
||
987 | if (SHIFT) freeze_balls (balls); |
||
988 | else if (CTRL) thaw_balls (balls); |
||
989 | else freeze_thaw_balls (balls); |
||
990 | } |
||
991 | |||
992 | if (keypressed (SDLK_j)) flip_velocity (); // flip ball velocity ie flips ball direction |
||
993 | |||
994 | if (keypressedd (SDLK_KP_PLUS, reptf, repts)) ++MENU.sp_mondrian_change_slit_size; |
||
995 | else if (keypressedd (SDLK_KP_MINUS, reptf, repts)) --MENU.sp_mondrian_change_slit_size; |
||
996 | |||
997 | if (keypressedd (SDLK_MINUS, reptf, repts)) --MENU.sp_mondrian_change_trail_size; |
||
998 | else if (keypressedd (SDLK_EQUALS, reptf, repts)) ++MENU.sp_mondrian_change_trail_size; |
||
999 | |||
1000 | if (keypressed (SDLK_b)) { |
||
1001 | if (SHIFT) do_add_balls (ball::WRECKER); |
||
1002 | else if (CTRL) do_add_balls (ball::HEALER); |
||
1003 | else do_add_balls (); // add bouncers |
||
1004 | } |
||
1005 | |||
1006 | if (keypressed (SDLK_m)) do_move_balls (); // move balls |
||
1007 | if (keypressed (SDLK_c)) delete_selected_targets (); |
||
1008 | |||
1009 | if (keypressedd (SDLK_y)) change_min_voices (-1); |
||
1010 | else if (keypressedd (SDLK_u)) change_min_voices (+1); |
||
1011 | |||
1012 | if (keypressed (SDLK_F9)) remove_slits_on_current_edge (); |
||
1013 | else if (keypressed (SDLK_F10)) remove_slits_on_current_box (); |
||
1014 | else if (keypressed (SDLK_F11)) remove_slits_on_boxes_with_balls (); |
||
1015 | else if (keypressed (SDLK_F12)) remove_all_slits (); |
||
1016 | |||
1017 | if (keypressed (SDLK_F3)) toggle_balls_type (ball::WRECKER); |
||
1018 | else if (keypressed (SDLK_F4)) toggle_balls_type (ball::HEALER); |
||
1019 | else if (keypressed (SDLK_F5)) toggle_balls_type (ball::BOUNCER); |
||
1020 | else if (keypressed (SDLK_F6)) switch_balls_type (); |
||
1021 | else if (keypressed (SDLK_F7)) select_type (ball::WRECKER); |
||
1022 | else if (keypressed (SDLK_F8)) select_type (ball::HEALER); |
||
1023 | |||
1024 | if (keypressed (SDLK_v)) { |
||
1025 | if (recting()) ; else { |
||
1026 | if (SHIFT) delete_all_rects = !delete_all_rects; |
||
1027 | else |
||
1028 | delete_current_rect (); |
||
1029 | } |
||
1030 | } |
||
1031 | |||
1032 | if (keypressed (SDLK_g)) { |
||
1033 | MENU.monl.picked (MENU.ol_selection_targets.option, +1); |
||
1034 | if (sel_tar == SELECT_BALLS) |
||
1035 | cons << GREEN << "Selection target: balls" << eol; |
||
1036 | else |
||
1037 | cons << GREEN << "Selection target: slits" << eol; |
||
1038 | } |
||
1039 | |||
1040 | if (keypressed (SDLK_h)) toggle_slit_anim (); |
||
1041 | |||
1042 | if (!mouse_slider0.active) { |
||
1043 | if (keypressedd (SDLK_9)) { |
||
1044 | if (SHIFT) --MENU.sp_mondrian_change_note_poly_radius; else --MENU.sp_mondrian_change_note_poly_points; |
||
1045 | } else if (keypressedd (SDLK_0)) { |
||
1046 | if (SHIFT) ++MENU.sp_mondrian_change_note_poly_radius; else ++MENU.sp_mondrian_change_note_poly_points; |
||
1047 | } |
||
1048 | } |
||
1049 | |||
1050 | if (keypressed (SDLK_SLASH)) {if (!mouse_slider0.active) start_slitting ();} |
||
1051 | else if (keypressedd (SDLK_INSERT)) ++MENU.sp_mondrian_change_slit_anim_time; |
||
1052 | else if (keypressedd (SDLK_DELETE)) --MENU.sp_mondrian_change_slit_anim_time; |
||
1053 | |||
1054 | if (keypressed (SDLK_F1)) _help (); |
||
1055 | |||
1056 | // movement |
||
1057 | if (can_wheel ()) do_zoom (-wheel * zoom); |
||
1058 | double pan_rept = window::PAN_REPEAT, zoom_rept = window::ZOOM_REPEAT; |
||
1059 | if (keypressedd (SDLK_a, pan_rept, pan_rept)) do_panx (-pan); |
||
1060 | else if (keypressedd (SDLK_d, pan_rept, pan_rept)) do_panx (+pan); |
||
1061 | else if (keypressedd (SDLK_w, pan_rept, pan_rept)) do_pany (+pan); |
||
1062 | else if (keypressedd (SDLK_s, pan_rept, pan_rept)) do_pany (-pan); |
||
1063 | |||
1064 | if (!mouse_slider0.active) { |
||
1065 | if (keypressedd (SDLK_q, zoom_rept, zoom_rept)) do_zoom (+zoom); // zoom out |
||
1066 | else if (keypressedd (SDLK_e, zoom_rept, zoom_rept)) do_zoom (-zoom); // zoom in |
||
1067 | } |
||
1068 | |||
1069 | return 1; |
||
1070 | } |
||
1071 | |||
1072 | void mondrian::clone_ball (ball* b) { |
||
1073 | #ifdef __EVALUATION__ |
||
1074 | if (num_balls) cons << RED << "Can clone balls in the Licensed Version of DIN Is Noise" << eol; |
||
1075 | return; |
||
1076 | #endif |
||
1077 | ball* cb = new ball; |
||
1078 | b->clone_this (cb); |
||
1079 | locate_ball (cb); |
||
1080 | balls.push_back (cb); |
||
1081 | ++num_balls; |
||
1082 | } |
||
1083 | |||
1084 | |||
1085 | state_button* point_modulator::add (hit_t& h) { |
||
1086 | #ifdef __EVALUATION__ |
||
1087 | if (nlst == 1) { |
||
1088 | cons << RED << "Can add more point modulators in the Licensed Version of DIN Is Noise" << eol; |
||
1089 | return 0; |
||
1090 | } |
||
1091 | #endif |
||
1092 | on_lst (_desel); |
||
1093 | state_button* sb = new state_button; |
||
1094 | sb->set_pos (sbx, sby); |
||
1095 | sbx += state_button::SIZE2; |
||
1096 | title.add_child (sb); |
||
1097 | const float bpm = 5.0f; |
||
1098 | mod_dat md (h, sb, bpm); |
||
1099 | lst.push_back (md); |
||
1100 | ++nlst; |
||
1101 | sb->set_listener (this); |
||
1102 | sb->set_state (1); |
||
1103 | |||
1104 | set_title (); |
||
1105 | return sb; |
||
1106 | } |
||
1107 | |||
1108 | |||
1109 | int ui_list::handle_input () { |
||
1110 | |||
1111 | // handle quit |
||
1112 | // |
||
1113 | #ifdef __MACOSX_CORE__ |
||
1114 | if (keydown (SDLK_LMETA) && keypressed (SDLK_q)) { // command key + q on mac os x |
||
1115 | quit = IMMEDIATE; |
||
1116 | return 1; |
||
1117 | } |
||
1118 | #else |
||
1119 | if (ALT && keypressed (SDLK_F4)) { // alt + f4 on windows & linux |
||
1120 | quit = IMMEDIATE; |
||
1121 | return 1; |
||
1122 | } |
||
1123 | #endif |
||
1124 | |||
1125 | // handle widgets |
||
1126 | // |
||
2176 | jag | 1127 | |
2310 | jag | 1128 | basic_editor::hide_cursor = mouse_slider0.active; |
1129 | //basic_editor::hide_cursor = 0; |
||
2177 | jag | 1130 | |
1723 | jag | 1131 | if (widget::focus) { // handle input of widget with focus |
1132 | widget::focus->handle_input (); |
||
1133 | return 1; |
||
1134 | } else { |
||
1135 | vector<widget*> widgets = widgets_of [current]; |
||
1136 | for (vector<widget*>::size_type i = 0, j = widgets.size (); i < j; ++i) { |
||
1137 | widget* wi = widgets[i]; |
||
1138 | if (wi->visible && wi->enabled) { |
||
1139 | wi->handle_input (); |
||
1140 | if (widget::focus) return 1; |
||
1141 | } |
||
1142 | } |
||
1143 | } |
||
1144 | |||
1145 | // toggle menu |
||
1146 | // |
||
1147 | #ifdef __EVALUATION__ |
||
1148 | if (current != &anote) { // no menu on author's note |
||
1149 | #endif |
||
1150 | if (rmb) { |
||
1151 | if (!rmb_clicked) { |
||
1152 | rmb_clicked = 1; |
||
1153 | if (escape_from_things ()); |
||
1154 | else main_menu.toggle (); |
||
1155 | } |
||
1156 | } else rmb_clicked = 0; |
||
1157 | #ifdef __EVALUATION__ |
||
1158 | } |
||
1159 | #endif |
||
1160 | |||
1161 | // handle current screen |
||
1162 | current->handle_input (); |
||
1163 | |||
1164 | if (keypressed (SDLK_BACKQUOTE)) { // flip to last screen |
||
2029 | jag | 1165 | if (prev && !mouse_slider0.active) { |
1723 | jag | 1166 | if (prev->ed) load_editor (prev); |
1167 | else if (prev->inst) load_instrument (dynamic_cast<instrument*>(prev)); |
||
1168 | else set_current (prev); // settings screen for now |
||
1169 | } |
||
1170 | } |
||
1171 | |||
1172 | if (mouse_slider0.active == 0) { |
||
1173 | if (keypressed (SDLK_1)) { // switch instrument |
||
1174 | if (current->inst) goto_next_instrument (); // else back to current instrument |
||
1175 | load_instrument (); |
||
1176 | } else { // load editors attached to keys 2 - 8 |
||
1177 | for (int i = 0; i < MAX_EDITORS; ++i) { |
||
1178 | if (keypressed (key[i])) { |
||
1179 | ui* edi = ed[i]; |
||
1180 | if (edi) load_editor (edi); |
||
1181 | } |
||
1182 | } |
||
1183 | } |
||
1184 | } |
||
1185 | |||
1186 | /*if (keypressed(SDLK_RETURN)) { |
||
1187 | if (alt_down ()) { // clear recording |
||
1188 | main_menu.recl.clicked (main_menu.b_clear_record); |
||
1189 | } else if (CTRL) { // start recording |
||
1190 | if (cb_record.state == 0) cb_record.turn_on (); else cb_record.turn_off (); |
||
1191 | } |
||
1192 | }*/ |
||
1193 | |||
1194 | if (keypressed (SDLK_F2)) { |
||
1195 | if (UI_OFF) turn_on_ui (); else turn_off_ui (); |
||
1196 | } |
||
1197 | |||
1198 | if (keypressed (SDLK_PAUSE)) { |
||
1199 | scope.visible = !scope.visible; |
||
1200 | main_menu.cb_scope.set_state (scope.visible, 0); |
||
1201 | } |
||
1202 | |||
1203 | if (keypressed (SDLK_MENU)) main_menu.mbl.clicked (main_menu.b_menu); |
||
1204 | |||
1205 | if (keypressed (SDLK_ESCAPE)) { |
||
1206 | if (UI_OFF) turn_on_ui (); |
||
1207 | else if ( escape_from_things() ) ; |
||
1208 | else { // ask to press esc again to really quit |
||
1209 | esc: |
||
1210 | if (esct == -1) { |
||
1211 | cons << console::red << "Press ESC again to quit" << eol; |
||
1212 | esct = ui_clk(); |
||
1213 | } else { |
||
1214 | double dt = ui_clk() - esct; |
||
1215 | if (dt > 1.0) { // 1 sec timeout |
||
2297 | jag | 1216 | esct = -1; // cancel |
1723 | jag | 1217 | goto esc; |
2297 | jag | 1218 | } else if (quit != SOON) try_quit (); |
1723 | jag | 1219 | } |
1220 | } |
||
1221 | } |
||
1222 | |||
1223 | return 1; |
||
1224 | |||
1225 | } |
||
1226 | |||
1227 | extern ui* SCREENS []; |
||
1228 | void ui_list::setup () { |
||
1229 | |||
1230 | // all screens |
||
1883 | jag | 1231 | int nscreens = 41; |
1723 | jag | 1232 | uis.resize (nscreens); |
1233 | uis[0] = 0; |
||
1234 | ui** si = SCREENS; |
||
1235 | for (int i = 1; i < nscreens; ++i, ++si) uis[i] = *si; |
||
1236 | |||
1237 | // bottom line |
||
1238 | int dirs [] = {arrow_button::left, arrow_button::right, arrow_button::up, arrow_button::down}; |
||
1239 | arrow_button* scrl [] = {&ab_scroll_left, &ab_scroll_right, &ab_scroll_up, &ab_scroll_down}; |
||
1240 | for (int i = 0; i < 4; ++i) { |
||
1241 | arrow_button* si = scrl[i]; |
||
1242 | si->set_dir (dirs[i]); |
||
1243 | si->set_size (12); |
||
1244 | si->set_listener (&sal); |
||
1245 | si->click_repeat = 1; |
||
1246 | si->first_repeat_time = 0.005; |
||
1247 | si->subsequent_repeat_time = 0.015; |
||
1248 | } |
||
1249 | |||
1250 | cb_voice.set_listener (&vlis); |
||
1251 | cb_voice.colorize (0); |
||
1252 | |||
1253 | cb_gater.set_listener (&glis); |
||
1254 | cb_gater.colorize (0); |
||
1255 | |||
1256 | cb_delay.set_listener (&dlis); |
||
1257 | cb_delay.colorize (0); |
||
1258 | |||
1259 | cb_compress.set_listener (&clis); |
||
1260 | |||
1261 | b_settings.set_listener (&slis); |
||
1262 | |||
1263 | cb_record.set_listener (&main_menu.recl); |
||
1264 | |||
1265 | sp_voices.set ("Voices", 1, 1, MILLION, &vov, 0); |
||
1266 | sp_attack_time.set ("Attack time", 0.1f, 0.0f, MILLION, &atv, 0); |
||
1267 | sp_decay_time.set ("Decay time", 0.1f, 0.0f, MILLION, &dkv, 0); |
||
1268 | sp_pitch_bend.set ("Hz/Pixel", 0.01f, 0.0f, MILLION, &pbl, 0); |
||
1269 | sp_octave_shift_bpm.set ("BPM", 1, 0.0f, MILLION, &osl, 0); |
||
1270 | |||
1271 | cb_show_nearby_notes.set_listener (&pbl); |
||
1272 | cb_show_nearby_notes.turn_off (); |
||
1273 | |||
1274 | // waveform display |
||
1275 | // |
||
1276 | l_waveform_display.set_text ("Waveform"); |
||
1277 | |||
1278 | ab_prev_wav.set_dir (arrow_button::left); |
||
1279 | ab_prev_wav.set_listener (&wdl); |
||
1280 | ab_next_wav.set_dir (arrow_button::right); |
||
1281 | ab_next_wav.set_listener (&wdl); |
||
1282 | |||
1283 | ab_prev_wav.click_repeat = ab_next_wav.click_repeat = 1; |
||
1284 | ab_prev_wav.first_repeat_time = ab_next_wav.first_repeat_time = 0.33; |
||
1285 | ab_prev_wav.subsequent_repeat_time = ab_next_wav.subsequent_repeat_time = 1/20.; |
||
1286 | |||
1287 | cd_waveform_display.set_size (96, 96); |
||
1288 | cd_waveform_display.crv = &keybd2.wave; // keyboard-keyboard's waveform |
||
1943 | jag | 1289 | cd_waveform_display.setbbox (keybd2.wave.shapeform); |
1723 | jag | 1290 | |
1291 | // octave shift |
||
1292 | l_octave_shift.set_text ("Octave Shift"); |
||
1293 | ab_octave_down.set_dir (arrow_button::left); |
||
1294 | ab_octave_down.set_listener (&osl); |
||
1295 | ab_octave_up.set_dir (arrow_button::right); |
||
1296 | ab_octave_up.set_listener (&osl); |
||
1297 | int arrow_size = 24; |
||
1298 | ab_octave_up.set_size (arrow_size); |
||
1299 | ab_octave_down.set_size (arrow_size); |
||
1300 | b_abort_octave_shift.set_text ("Abort"); |
||
1301 | b_abort_octave_shift.set_listener (&main_menu.aosl); |
||
1302 | |||
1303 | // keys trigger? notes or noise |
||
1304 | ol_trig_what.set_listener (&twl); |
||
1305 | |||
1306 | DEFINE_PARAMETERS |
||
1307 | widget_load ("d_parameters", pw, npars); |
||
1308 | for (int i = 1; i < npars; ++i) { |
||
1309 | d_parameters.add_child (pw[i]); |
||
1310 | //pw[i]->set_moveable(1); |
||
1311 | } |
||
1312 | |||
1313 | d_parameters.set_name ("Parameters"); |
||
1314 | d_parameters.set_moveable (1); |
||
1315 | |||
1316 | ab_parameters.set_listener (&pal); |
||
1317 | |||
1318 | cb_voice.set_state (din0.dinfo.voice); |
||
1319 | cb_gater.set_state (din0.dinfo.gater); |
||
1320 | cb_delay.set_state (din0.dinfo.delay); |
||
1321 | cb_compress.set_state (din0.dinfo.compress); |
||
1322 | |||
1323 | cb_show_pitch_volume_board.set_listener (&spvl); |
||
1324 | cb_show_pitch_volume_drones.set_listener (&spvl); |
||
1325 | |||
1326 | #ifdef __EVALUATION__ |
||
1327 | anote.setup (); |
||
1328 | #endif |
||
1329 | |||
1330 | plugin__browser.setup (); |
||
1331 | settings_scr.setup (); |
||
1332 | main_menu.setup (); |
||
1333 | |||
1334 | } |
||
1725 | jag | 1335 | |
1336 | void nagscr () { |
||
1337 | #ifdef __EVALUATION__ |
||
1338 | cons.clear (); |
||
1339 | uis.set_current (&anote); // nag screen :( |
||
1340 | #elif defined __LICENSED__ |
||
1341 | load_instrument (); // open with last used instrument |
||
1342 | #endif |
||
1343 | } |
||
1764 | jag | 1344 | |
1811 | jag | 1345 | void drone_commands_listener::startwanding () { |
1346 | int* flags [] = {&din0.adding, &din0.wanding}; |
||
1347 | static const char* mesg [] = {"Click to add drones, ESC or Right Click to stop", "Just move mouse to add drones, ESC or Right Click to stop"}; |
||
1348 | din0.adding = din0.wanding = 0; |
||
1349 | *flags[din0.dinfo.wand] = 1; |
||
1350 | #ifdef __EVALUATION__ |
||
1351 | if (din0.wanding) { |
||
1352 | din0.wanding = 0; |
||
1353 | cons << RED << "Wand only available in the Licensed Version of DIN Is Noise" << eol; |
||
1354 | return; |
||
1355 | } |
||
1356 | #endif |
||
1357 | cons << GREEN << mesg[din0.dinfo.wand] << eol; |
||
1358 | } |
||
1359 | |||
1764 | jag | 1360 | void drone_commands_listener::clicked (button& b) { |
1361 | int toggle = 1; |
||
1811 | jag | 1362 | if (&b == MENUP.ol_add_wand.option) startwanding (); else |
1764 | jag | 1363 | if (&b == MENUP.b_delete_drones) din0.delete_selected_drones (); else |
1364 | if (&b == MENUP.b_select_all_drones) {toggle = 0; din0.select_all_drones ();} else |
||
1365 | if (&b == MENUP.b_launch_drones) din0.make_launchers (); else |
||
1366 | if (&b == MENUP.b_orbit_selected_drones) din0.orbit_selected_drones (); else |
||
1367 | if (&b == MENUP.b_freeze_drones) din0.freeze_drones (); else |
||
1368 | if (&b == MENUP.b_thaw_drones) din0.thaw_drones (); else |
||
1369 | if (&b == MENUP.b_select_launchers) {toggle = 0; din0.select_launchers (); } else |
||
1370 | if (&b == MENUP.b_set_targets) din0.set_targets (); else |
||
1371 | if (&b == MENUP.b_select_attractors) {toggle = 0; din0.select_attractors (); } else |
||
1372 | if (&b == MENUP.b_select_attractees) {toggle = 0; din0.select_attractees (); } else |
||
1373 | if (&b == MENUP.b_stop_launching_drones) din0.destroy_launchers (); else |
||
1374 | if (&b == MENUP.b_invert_drone_selection) {toggle = 0; din0.invert_selected_drones();} else |
||
1375 | if (&b == MENUP.b_track_drones) din0.make_trackers (); else |
||
1376 | if (&b == MENUP.b_select_tracked_drones) {toggle = 0; din0.select_tracked_drones (); } else |
||
1377 | if (&b == MENUP.ol_create_this.option) din0.toggle_create_this (); else |
||
1378 | if (&b == MENUP.b_clear_targets) din0.clear_targets(); else |
||
1379 | if (&b == MENUP.b_flip_rows_cols) { |
||
2107 | jag | 1380 | int r = MENU.sp_mesh_rows.value, c = MENU.sp_mesh_cols.value; |
1764 | jag | 1381 | MENU.sp_mesh_rows.set_value (c); |
1382 | MENU.sp_mesh_cols.set_value (r); |
||
1383 | din0.dinfo.rows = c; |
||
1384 | din0.dinfo.cols = r; |
||
1385 | mkb_selector.set_mesh (din0.meshh.create, din0.dinfo.rows, din0.dinfo.cols); |
||
1386 | MENU.picked (MENU.ol_mesh_point.option, 0); |
||
1387 | toggle = 0; |
||
2029 | jag | 1388 | } |
1389 | |||
1764 | jag | 1390 | if (toggle) MENU.toggle (); |
1391 | } |
||
1843 | jag | 1392 | |
1393 | |||
1869 | jag | 1394 | VALUE_CHANGED(menu,genslis) { |
1395 | int& gens = din0.dinfo.gens; |
||
2107 | jag | 1396 | gens = MENU.gens.value; |
1869 | jag | 1397 | #ifdef __EVALUATION__ |
1398 | if (gens > 1) { |
||
1399 | cons << RED << "Generations > 1 only in the licensed version of DIN Is Noise" << eol; |
||
1400 | gens = 1; |
||
1874 | jag | 1401 | MENU.gens.set_value (1); |
1869 | jag | 1402 | return; |
1403 | } |
||
1404 | #endif |
||
1405 | cons << GREEN << "Default Generations = " << gens << eol; |
||
1406 | } |