1 /*
2  * Author: Harry van Haaren 2013
3  *         harryhaaren@gmail.com
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef LUPPP_EVENT_H
20 #define LUPPP_EVENT_H
21 
22 #include <iostream>
23 #include <stdint.h>
24 
25 /*
26     event.hxx
27 
28   This file provides declarations for each type of event that the engine uses.
29 */
30 
31 #include "looper.hxx"
32 #include "gridlogic.hxx"
33 #include "transport.hxx"
34 
35 #pragma GCC diagnostic ignored "-Wunused-parameter"
36 
37 using namespace std;
38 
39 namespace Event
40 {
41 enum SEND_TYPE {
42 	SEND_POSTFADER = 0,
43 	SEND_KEY,
44 	SEND_XSIDE,
45 };
46 enum RETURN_TYPE {
47 	RETURN_INVALID = 0,
48 	RETURN_MAIN,
49 };
50 enum INPUT_TO {
51 	INPUT_TO_SEND = 0,
52 	INPUT_TO_MIX,
53 	INPUT_TO_XSIDE,
54 	INPUT_TO_SIDE_KEY,
55 };
56 
57 enum EVENT_TYPE {
58 	// default event type
59 	EVENT_NULL = 0,
60 
61 	MASTER_VOL,
62 	MASTER_INPUT_VOL,
63 	MASTER_INPUT_TO,
64 	MASTER_INPUT_TO_ACTIVE,
65 	MASTER_RETURN,
66 	RECORD,
67 
68 	STATE_SAVE,       // save action
69 	STATE_RESET, // reset all state
70 	STATE_SAVE_FINISH,// save action finished, flush metadata to disk
71 	STATE_SAVE_BUFFER,// save an individual AudioBuffer* to disk
72 
73 	REQUEST_SAVE_BUFFER, // gets an audioBuffer of a certain size
74 
75 	/// Grid
76 	GRID_EVENT, // press / release events
77 	GRID_STATE, // state of one block
78 	GRID_LAUNCH_SCENE, // launches a scene
79 	GRID_SELECT_CLIP_ENABLE, // enable selecting a clip from the grid
80 	GRID_SELECT_CLIP_EVENT, // a press / release on the selected clip
81 	GRID_SELECT_NEW_CHOSEN, // a different clip is now "special"
82 
83 	/// Track
84 	TRACK_JACKSEND,
85 	TRACK_JACKSEND_ACTIVATE,
86 	TRACK_SEND,
87 	TRACK_SEND_ACTIVE,
88 	TRACK_SIGNAL_LEVEL,
89 	TRACK_VOLUME,
90 	TRACK_PAN,
91 	TRACK_RECORD_ARM,
92 
93 	FX_REVERB,
94 
95 	LOOPER_LOAD,
96 	LOOPER_STATE,
97 	LOOPER_PROGRESS,
98 	LOOPER_LOOP_LENGTH,
99 	LOOPER_LOOP_USE_AS_TEMPO,
100 
101 	/// Transport etc
102 	METRONOME_ACTIVE,
103 	METRONOME_VOLUME,
104 	TRANSPORT,                /// rolling or stopped
105 
106 	TIME_BPM,
107 	TIME_BAR_BEAT,
108 	TIME_TEMPO_TAP,
109 
110 	GUI_PRINT,
111 
112 	LOOPER_REQUEST_BUFFER,
113 	DEALLOCATE_BUFFER,
114 
115 	SAMPLERATE,
116 
117 	// Controller
118 	CONTROLLER_INSTANCE,
119 	CONTROLLER_INSTANCE_REMOVE,
120 	CONTROLLER_INSTANCE_GET_TO_WRITE,
121 	CONTROLLER_BINDING_ENABLE,
122 	CONTROLLER_BINDING_TARGET,
123 	CONTROLLER_BINDING_MADE,
124 	CONTROLLER_BINDING_REMOVE,
125 
126 	QUIT,
127 
128 	// for keeping loop index's inside the enum
129 	EVENT_TYPE_FINAL,
130 };
131 
132 /// returns the pretty name of an event
133 const char* getPrettyName( int type );
134 
135 /// returns an EVENT_TYPE from a pretty name
136 EVENT_TYPE getTypeFromName(const char* name);
137 };
138 
139 using namespace Event;
140 
141 class AudioBuffer;
142 
143 class EventBase
144 {
145 public:
~EventBase()146 	virtual ~EventBase() {}
147 
148 	virtual int type() = 0;
149 	virtual uint32_t size() = 0;
150 
151 	/// returns const char* to static char buffer: is the pretty name for event
152 	/// optional override: if function isn't overriden, no target update sent
name()153 	virtual const char* name()
154 	{
155 		return 0;
156 	}
157 };
158 
159 class EventTransportState : public EventBase
160 {
161 public:
type()162 	int type()
163 	{
164 		return int(TRANSPORT);
165 	}
size()166 	uint32_t size()
167 	{
168 		return sizeof(EventTransportState);
169 	}
170 	TRANSPORT_STATE ts;
EventTransportState()171 	EventTransportState(): ts( TRANSPORT_STOPPED ) {}
EventTransportState(TRANSPORT_STATE t)172 	EventTransportState( TRANSPORT_STATE t): ts(t) {}
173 };
174 
175 class EventControllerBindingMade : public EventBase
176 {
177 public:
type()178 	int type()
179 	{
180 		return int(CONTROLLER_BINDING_MADE);
181 	}
size()182 	uint32_t size()
183 	{
184 		return sizeof(EventControllerBindingMade);
185 	}
186 	int controllerID;
187 	void* binding;
EventControllerBindingMade(int id=0,void * b=0)188 	EventControllerBindingMade(int id = 0, void* b=0): controllerID(id), binding(b) {}
189 };
190 
191 class EventControllerBindingRemove : public EventBase
192 {
193 public:
type()194 	int type()
195 	{
196 		return int(CONTROLLER_BINDING_REMOVE);
197 	}
size()198 	uint32_t size()
199 	{
200 		return sizeof(EventControllerBindingRemove);
201 	}
202 	int controllerID;
203 	int bindingID;
204 	void* binding;
EventControllerBindingRemove(int ctlrID=0,int bindID=0,void * b=0)205 	EventControllerBindingRemove(int ctlrID = 0, int bindID=0, void* b=0): controllerID(ctlrID), bindingID(bindID), binding(b) {}
206 };
207 
208 class EventControllerBindingEnable : public EventBase
209 {
210 public:
type()211 	int type()
212 	{
213 		return int(CONTROLLER_BINDING_ENABLE);
214 	}
size()215 	uint32_t size()
216 	{
217 		return sizeof(EventControllerBindingEnable);
218 	}
219 	int controllerID;
220 	bool enable;
EventControllerBindingEnable(int id=0,bool e=false)221 	EventControllerBindingEnable(int id = 0, bool e=false):controllerID(id),enable(e) {}
222 };
223 
224 class EventGridSelectClipEvent : public EventBase
225 {
226 public:
type()227 	int type()
228 	{
229 		return int(GRID_SELECT_CLIP_EVENT);
230 	}
size()231 	uint32_t size()
232 	{
233 		return sizeof(EventGridSelectClipEvent);
234 	}
235 	bool pressed;
EventGridSelectClipEvent(bool p=false)236 	EventGridSelectClipEvent(bool p=false):pressed(p) {}
237 };
238 
239 class EventGridSelectClipEnable : public EventBase
240 {
241 public:
type()242 	int type()
243 	{
244 		return int(GRID_SELECT_CLIP_ENABLE);
245 	}
size()246 	uint32_t size()
247 	{
248 		return sizeof(EventGridSelectClipEnable);
249 	}
250 	bool enable;
EventGridSelectClipEnable(bool e=false)251 	EventGridSelectClipEnable(bool e=false):enable(e) {}
252 };
253 
254 class EventGridSelectNewChosen : public EventBase
255 {
256 public:
type()257 	int type()
258 	{
259 		return int(GRID_SELECT_NEW_CHOSEN);
260 	}
size()261 	uint32_t size()
262 	{
263 		return sizeof(EventGridSelectNewChosen);
264 	}
265 	int track;
266 	int scene;
EventGridSelectNewChosen(int t=-1,int s=-1)267 	EventGridSelectNewChosen(int t = -1, int s = -1):track(t),scene(s) {}
268 };
269 
270 class EventQuit : public EventBase
271 {
272 public:
type()273 	int type()
274 	{
275 		return int(QUIT);
276 	}
size()277 	uint32_t size()
278 	{
279 		return sizeof(EventQuit);
280 	}
EventQuit()281 	EventQuit() {}
282 };
283 
284 class EventSamplerate : public EventBase
285 {
286 public:
type()287 	int type()
288 	{
289 		return int(SAMPLERATE);
290 	}
size()291 	uint32_t size()
292 	{
293 		return sizeof(EventSamplerate);
294 	}
295 	int samplerate;
EventSamplerate(int sr=0)296 	EventSamplerate(int sr = 0): samplerate(sr) {}
297 };
298 
299 class EventControllerInstance : public EventBase
300 {
301 public:
type()302 	int type()
303 	{
304 		return int(CONTROLLER_INSTANCE);
305 	}
size()306 	uint32_t size()
307 	{
308 		return sizeof(EventControllerInstance);
309 	}
310 	void* controller;
EventControllerInstance(void * c=0)311 	EventControllerInstance(void* c = 0) : controller(c) {}
312 };
313 
314 class EventControllerInstanceRemove : public EventBase
315 {
316 public:
type()317 	int type()
318 	{
319 		return int(CONTROLLER_INSTANCE_REMOVE);
320 	}
size()321 	uint32_t size()
322 	{
323 		return sizeof(EventControllerInstanceRemove);
324 	}
325 	int ID;
EventControllerInstanceRemove(int i=-1)326 	EventControllerInstanceRemove(int i = -1) : ID(i) {}
327 };
328 
329 /// writes the GenericMIDI controller instance to a .ctlr file
330 class EventControllerInstanceGetToWrite : public EventBase
331 {
332 public:
type()333 	int type()
334 	{
335 		return int(CONTROLLER_INSTANCE_GET_TO_WRITE);
336 	}
size()337 	uint32_t size()
338 	{
339 		return sizeof(EventControllerInstanceGetToWrite);
340 	}
341 	int ID;
342 	void* controller;
EventControllerInstanceGetToWrite(int id=0,void * c=0)343 	EventControllerInstanceGetToWrite(int id = 0, void* c = 0) : ID(id), controller(c) {}
344 };
345 
346 class EventMasterInputTo : public EventBase
347 {
348 public:
type()349 	int type()
350 	{
351 		return int(MASTER_INPUT_TO);
352 	}
size()353 	uint32_t size()
354 	{
355 		return sizeof(EventMasterInputTo);
356 	}
357 	static const char* prettyName;
name()358 	const char* name()
359 	{
360 		return prettyName;
361 	}
362 
363 	int place;
364 	float value;
EventMasterInputTo(int p=-1,float v=0)365 	EventMasterInputTo(int p=-1, float v=0) : place(p), value(v) {}
366 };
367 
368 class EventMasterInputToActive : public EventBase
369 {
370 public:
type()371 	int type()
372 	{
373 		return int(MASTER_INPUT_TO_ACTIVE);
374 	}
size()375 	uint32_t size()
376 	{
377 		return sizeof(EventMasterInputToActive);
378 	}
379 	static const char* prettyName;
name()380 	const char* name()
381 	{
382 		return prettyName;
383 	}
384 
385 	int place;
386 	bool active;
EventMasterInputToActive(int p=-1,bool a=false)387 	EventMasterInputToActive(int p=-1, bool a=false) : place(p), active(a) {}
388 };
389 
390 class EventMasterVol : public EventBase
391 {
392 public:
393 	static const char* prettyName;
name()394 	const char* name()
395 	{
396 		return prettyName;
397 	}
type()398 	int type()
399 	{
400 		return int(MASTER_VOL);
401 	}
size()402 	uint32_t size()
403 	{
404 		return sizeof(EventMasterVol);
405 	}
406 
407 	float vol;
EventMasterVol(float v=0)408 	EventMasterVol(float v = 0) : vol(v) {}
409 };
410 
411 class EventMasterInputVol : public EventBase
412 {
413 public:
414 	static const char* prettyName;
name()415 	const char* name()
416 	{
417 		return prettyName;
418 	}
type()419 	int type()
420 	{
421 		return int(MASTER_INPUT_VOL);
422 	}
size()423 	uint32_t size()
424 	{
425 		return sizeof(EventMasterInputVol);
426 	}
427 	float vol;
EventMasterInputVol(float v=0)428 	EventMasterInputVol(float v = 0) : vol(v) {}
429 };
430 
431 class EventMasterReturn : public EventBase
432 {
433 public:
type()434 	int type()
435 	{
436 		return int(MASTER_RETURN);
437 	}
size()438 	uint32_t size()
439 	{
440 		return sizeof(EventMasterReturn);
441 	}
442 	static const char* prettyName;
name()443 	const char* name()
444 	{
445 		return prettyName;
446 	}
447 
448 	RETURN_TYPE ret;
449 	float vol;
EventMasterReturn(RETURN_TYPE s=RETURN_INVALID,float v=0)450 	EventMasterReturn(RETURN_TYPE s=RETURN_INVALID, float v=0): ret(s), vol(v) {}
451 };
452 
453 class EventTrackVol : public EventBase
454 {
455 public:
type()456 	int type()
457 	{
458 		return int(TRACK_VOLUME);
459 	}
size()460 	uint32_t size()
461 	{
462 		return sizeof(EventTrackVol);
463 	}
464 	static const char* prettyName;
name()465 	const char* name()
466 	{
467 		return prettyName;
468 	}
469 
470 	int track;
471 	float vol;
472 
EventTrackVol()473 	EventTrackVol() {};
EventTrackVol(int t,float v)474 	EventTrackVol(int t, float v)
475 	{
476 		track = t;
477 		vol = v;
478 	}
479 };
480 
481 class EventTrackPan : public EventBase
482 {
483 public:
type()484 	int type()
485 	{
486 		return int(TRACK_PAN);
487 	}
size()488 	uint32_t size()
489 	{
490 		return sizeof(EventTrackPan);
491 	}
492 	static const char* prettyName;
name()493 	const char* name()
494 	{
495 		return prettyName;
496 	}
497 
498 	int track;
499 	float pan;
500 
EventTrackPan()501 	EventTrackPan() {};
EventTrackPan(int t,float p)502 	EventTrackPan(int t, float p)
503 	{
504 		track = t;
505 		pan = p;
506 	}
507 };
508 
509 
510 class EventTrackRecordArm : public EventBase
511 {
512 public:
type()513 	int type()
514 	{
515 		return int(TRACK_RECORD_ARM);
516 	}
size()517 	uint32_t size()
518 	{
519 		return sizeof(EventTrackRecordArm);
520 	}
521 	static const char* prettyName;
name()522 	const char* name()
523 	{
524 		return prettyName;
525 	}
526 
527 	int track;
528 	float recordArm;
529 
EventTrackRecordArm()530 	EventTrackRecordArm() {};
EventTrackRecordArm(int t,bool r)531 	EventTrackRecordArm(int t, bool r)
532 	{
533 		track = t;
534 		recordArm = r;
535 	}
536 };
537 
538 class EventStateSave : public EventBase
539 {
540 public:
type()541 	int type()
542 	{
543 		return int(STATE_SAVE);
544 	}
size()545 	uint32_t size()
546 	{
547 		return sizeof(EventStateSave);
548 	}
549 
EventStateSave()550 	EventStateSave() {}
551 };
552 
553 class EventStateReset : public EventBase
554 {
555 public:
type()556 	int type()
557 	{
558 		return int(STATE_RESET);
559 	}
size()560 	uint32_t size()
561 	{
562 		return sizeof(EventStateReset);
563 	}
564 
EventStateReset()565 	EventStateReset() {}
566 };
567 
568 class EventStateSaveFinish : public EventBase
569 {
570 public:
type()571 	int type()
572 	{
573 		return int(STATE_SAVE_FINISH);
574 	}
size()575 	uint32_t size()
576 	{
577 		return sizeof(EventStateSaveFinish);
578 	}
579 
EventStateSaveFinish()580 	EventStateSaveFinish() {};
581 };
582 
583 class EventGridEvent : public EventBase
584 {
585 public:
type()586 	int type()
587 	{
588 		return int(GRID_EVENT);
589 	}
size()590 	uint32_t size()
591 	{
592 		return sizeof(EventGridEvent);
593 	}
594 	static const char* prettyName;
name()595 	const char* name()
596 	{
597 		return prettyName;
598 	}
599 
600 	int track;
601 	int scene;
602 	bool pressed;
603 
EventGridEvent()604 	EventGridEvent() {};
EventGridEvent(int t,int s,bool p)605 	EventGridEvent(int t, int s, bool p): track(t), scene(s), pressed(p) {}
606 };
607 
608 class EventGridState : public EventBase
609 {
610 public:
type()611 	int type()
612 	{
613 		return int(GRID_STATE);
614 	}
size()615 	uint32_t size()
616 	{
617 		return sizeof(EventGridState);
618 	}
619 
620 	int track;
621 	int scene;
622 	GridLogic::State state;
623 
EventGridState()624 	EventGridState() {};
EventGridState(int t,int s,GridLogic::State st)625 	EventGridState(int t, int s, GridLogic::State st): track(t), scene(s), state(st) {}
626 };
627 
628 class EventGridLaunchScene : public EventBase
629 {
630 public:
type()631 	int type()
632 	{
633 		return int(GRID_LAUNCH_SCENE);
634 	}
size()635 	uint32_t size()
636 	{
637 		return sizeof(EventGridLaunchScene);
638 	}
639 	static const char* prettyName;
name()640 	const char* name()
641 	{
642 		return prettyName;
643 	}
644 
645 	int scene;
646 
EventGridLaunchScene()647 	EventGridLaunchScene() {};
EventGridLaunchScene(int s)648 	EventGridLaunchScene(int s): scene(s) {}
649 };
650 
651 class EventFxReverb : public EventBase
652 {
653 public:
type()654 	int type()
655 	{
656 		return int(FX_REVERB);
657 	}
size()658 	uint32_t size()
659 	{
660 		return sizeof(EventFxReverb);
661 	}
662 
663 	bool enable;
664 
665 	float rtSize;
666 	float wet;
667 	float damping;
668 
EventFxReverb()669 	EventFxReverb() {};
EventFxReverb(bool e,float s,float w,float d)670 	EventFxReverb(bool e, float s, float w, float d): enable(e), rtSize(s), wet(w), damping(d) {}
671 };
672 
673 class EventTrackSend : public EventBase
674 {
675 public:
type()676 	int type()
677 	{
678 		return int(TRACK_SEND);
679 	}
size()680 	uint32_t size()
681 	{
682 		return sizeof(EventTrackSend);
683 	}
684 	static const char* prettyName;
name()685 	const char* name()
686 	{
687 		return prettyName;
688 	}
689 
690 	int track;
691 	SEND_TYPE send;
692 	float value;
693 
EventTrackSend()694 	EventTrackSend() {};
EventTrackSend(int t,SEND_TYPE s,float v)695 	EventTrackSend(int t, SEND_TYPE s, float v): track(t), send(s), value(v) {}
696 };
697 
698 class EventTrackJackSend : public EventBase
699 {
700 public:
type()701 	int type()
702 	{
703 		return int(TRACK_JACKSEND);
704 	}
size()705 	uint32_t size()
706 	{
707 		return sizeof(EventTrackJackSend);
708 	}
709 	static const char* prettyName;
name()710 	const char* name()
711 	{
712 		return prettyName;
713 	}
714 
715 	int track;
716 
717 	float value;
718 
EventTrackJackSend()719 	EventTrackJackSend() {};
EventTrackJackSend(int t,float v)720 	EventTrackJackSend(int t, float v): track(t), value(v) {}
721 };
722 
723 class EventTrackSendActive : public EventBase
724 {
725 public:
type()726 	int type()
727 	{
728 		return int(TRACK_SEND_ACTIVE);
729 	}
size()730 	uint32_t size()
731 	{
732 		return sizeof(EventTrackSendActive);
733 	}
734 	static const char* prettyName;
name()735 	const char* name()
736 	{
737 		return prettyName;
738 	}
739 
740 	int track;
741 	SEND_TYPE send;
742 	bool active;
743 
EventTrackSendActive()744 	EventTrackSendActive() {};
EventTrackSendActive(int t,SEND_TYPE s,bool a)745 	EventTrackSendActive(int t, SEND_TYPE s, bool a): track(t), send(s), active(a) {}
746 };
747 
748 class EventTrackJackSendActivate : public EventBase
749 {
750 public:
type()751 	int type()
752 	{
753 		return int(TRACK_JACKSEND_ACTIVATE);
754 	}
size()755 	uint32_t size()
756 	{
757 		return sizeof(EventTrackJackSendActivate);
758 	}
759 	static const char* prettyName;
name()760 	const char* name()
761 	{
762 		return prettyName;
763 	}
764 
765 	int track;
766 	bool active;
767 
EventTrackJackSendActivate()768 	EventTrackJackSendActivate() {};
EventTrackJackSendActivate(int t,bool a)769 	EventTrackJackSendActivate(int t, bool a): track(t), active(a) {}
770 };
771 class EventLooperState : public EventBase
772 {
773 public:
type()774 	int type()
775 	{
776 		return int(LOOPER_STATE);
777 	}
size()778 	uint32_t size()
779 	{
780 		return sizeof(EventLooperState);
781 	}
782 
783 	int track;
784 	int scene;
785 	//Looper::State state;
786 
EventLooperState()787 	EventLooperState() {}
788 	//EventLooperState(int t, int sc, Looper::State s) : track(t), scene(sc), state(s){}
789 };
790 
791 class EventLooperProgress : public EventBase
792 {
793 public:
type()794 	int type()
795 	{
796 		return int(LOOPER_PROGRESS);
797 	}
size()798 	uint32_t size()
799 	{
800 		return sizeof(EventLooperProgress);
801 	}
802 
803 	int track;
804 	float progress;
EventLooperProgress()805 	EventLooperProgress() {}
EventLooperProgress(int t,float p)806 	EventLooperProgress(int t, float p) : track(t), progress(p) {}
807 };
808 
809 class EventLooperLoopLength : public EventBase
810 {
811 public:
type()812 	int type()
813 	{
814 		return int(LOOPER_LOOP_LENGTH);
815 	}
size()816 	uint32_t size()
817 	{
818 		return sizeof(EventLooperLoopLength);
819 	}
820 
821 	int track;
822 	int scene;
823 	int beats;
EventLooperLoopLength()824 	EventLooperLoopLength() {}
EventLooperLoopLength(int t,int s,int b)825 	EventLooperLoopLength(int t, int s, int b) : track(t), scene(s), beats(b) {}
826 };
827 
828 class EventLooperUseAsTempo : public EventBase
829 {
830 public:
type()831 	int type()
832 	{
833 		return int(LOOPER_LOOP_USE_AS_TEMPO);
834 	}
size()835 	uint32_t size()
836 	{
837 		return sizeof(EventLooperUseAsTempo);
838 	}
839 
840 	int track;
841 	int scene;
842 	int beats;
EventLooperUseAsTempo()843 	EventLooperUseAsTempo() {}
EventLooperUseAsTempo(int t,int s)844 	EventLooperUseAsTempo(int t, int s) : track(t), scene(s) {}
845 };
846 
847 class EventLooperLoad : public EventBase
848 {
849 public:
type()850 	int type()
851 	{
852 		return int(LOOPER_LOAD);
853 	}
size()854 	uint32_t size()
855 	{
856 		return sizeof(EventLooperLoad);
857 	}
858 
859 	int track;
860 	int clip;
861 	void* audioBuffer;
862 
EventLooperLoad()863 	EventLooperLoad() {}
EventLooperLoad(int t,int c,void * ab)864 	EventLooperLoad(int t, int c, void* ab) : track(t), clip(c), audioBuffer(ab)
865 	{
866 	}
867 };
868 
869 class EventMetronomeActive : public EventBase
870 {
871 public:
type()872 	int type()
873 	{
874 		return int(METRONOME_ACTIVE);
875 	}
size()876 	uint32_t size()
877 	{
878 		return sizeof(EventMetronomeActive);
879 	}
880 	static const char* prettyName;
name()881 	const char* name()
882 	{
883 		return prettyName;
884 	}
885 
886 	bool active;
EventMetronomeActive(bool a=false)887 	EventMetronomeActive(bool a = false) : active(a) {}
888 };
889 
890 class EventMetronomeVolume : public EventBase
891 {
892 public:
type()893 	int type()
894 	{
895 		return int(METRONOME_VOLUME);
896 	}
size()897 	uint32_t size()
898 	{
899 		return sizeof(EventMetronomeVolume);
900 	}
901 	static const char* prettyName;
name()902 	const char* name()
903 	{
904 		return prettyName;
905 	}
906 
907 	float vol;
EventMetronomeVolume(float v=0.f)908 	EventMetronomeVolume(float v = 0.f) : vol(v) {}
909 };
910 
911 class EventTimeBPM : public EventBase
912 {
913 public:
type()914 	int type()
915 	{
916 		return int(TIME_BPM);
917 	}
size()918 	uint32_t size()
919 	{
920 		return sizeof(EventTimeBPM);
921 	}
922 	static const char* prettyName;
name()923 	const char* name()
924 	{
925 		return prettyName;
926 	}
927 
928 	float bpm;
929 
EventTimeBPM()930 	EventTimeBPM() {}
EventTimeBPM(float b)931 	EventTimeBPM(float b) : bpm(b) {}
932 };
933 
934 class EventTrackSignalLevel : public EventBase
935 {
936 public:
type()937 	int type()
938 	{
939 		return int(TRACK_SIGNAL_LEVEL);
940 	}
size()941 	uint32_t size()
942 	{
943 		return sizeof(EventTrackSignalLevel);
944 	}
945 
946 	int track;
947 	float left;
948 	float right;
949 
EventTrackSignalLevel()950 	EventTrackSignalLevel() {}
EventTrackSignalLevel(int t,float l,float r)951 	EventTrackSignalLevel(int t, float l,float r) : track(t), left(l), right(r) {}
952 };
953 
954 class EventTimeTempoTap : public EventBase
955 {
956 public:
type()957 	int type()
958 	{
959 		return int(TIME_TEMPO_TAP);
960 	}
size()961 	uint32_t size()
962 	{
963 		return sizeof(EventTimeTempoTap);
964 	}
965 	static const char* prettyName;
name()966 	const char* name()
967 	{
968 		return prettyName;
969 	}
970 
971 	bool pressed; // only used to turn on / off the button in GUI
EventTimeTempoTap()972 	EventTimeTempoTap():pressed(false) {}
EventTimeTempoTap(bool p)973 	EventTimeTempoTap(bool p): pressed(p) {}
974 };
975 
976 class EventTimeBarBeat : public EventBase
977 {
978 public:
type()979 	int type()
980 	{
981 		return int(TIME_BAR_BEAT);
982 	}
size()983 	uint32_t size()
984 	{
985 		return sizeof(EventTimeBarBeat);
986 	}
987 
988 	int bar;
989 	int beat;
EventTimeBarBeat()990 	EventTimeBarBeat(): bar(0), beat(0) {}
EventTimeBarBeat(int ba,int be)991 	EventTimeBarBeat(int ba, int be): bar(ba), beat(be) {}
992 };
993 
994 class EventLooperClipRequestBuffer : public EventBase
995 {
996 public:
type()997 	int type()
998 	{
999 		return int(LOOPER_REQUEST_BUFFER);
1000 	}
size()1001 	uint32_t size()
1002 	{
1003 		return sizeof(EventLooperClipRequestBuffer);
1004 	}
1005 
1006 	int track;
1007 	int scene;
1008 
1009 	// number of floats to contain
1010 	unsigned long numElements;
1011 
1012 	// pointer to the new AudioBuffer being passed back
1013 	AudioBuffer* ab;
1014 
EventLooperClipRequestBuffer()1015 	EventLooperClipRequestBuffer(): track(0), scene(0), numElements(0), ab(0) {}
EventLooperClipRequestBuffer(int t,int s,int siz)1016 	EventLooperClipRequestBuffer(int t, int s, int siz): track(t), scene(s), numElements(siz), ab(0) {}
EventLooperClipRequestBuffer(int t,int s,AudioBuffer * a)1017 	EventLooperClipRequestBuffer(int t, int s, AudioBuffer* a): track(t), scene(s), numElements(0), ab(a) {}
1018 };
1019 
1020 
1021 class EventStateSaveBuffer : public EventBase
1022 {
1023 public:
type()1024 	int type()
1025 	{
1026 		return int(STATE_SAVE_BUFFER);
1027 	}
size()1028 	uint32_t size()
1029 	{
1030 		return sizeof(EventStateSaveBuffer);
1031 	}
1032 
1033 	int track;
1034 	int scene;
1035 	// pointer to the AudioBuffer to be saved
1036 	AudioBuffer* ab;
1037 	bool no_dealloc;
1038 
EventStateSaveBuffer()1039 	EventStateSaveBuffer(): track(0), scene(0), ab(0), no_dealloc(0) {}
EventStateSaveBuffer(int t,int s,AudioBuffer * a)1040 	EventStateSaveBuffer(int t, int s, AudioBuffer* a): track(t), scene(s), ab(a) {}
1041 };
1042 
1043 class EventRequestSaveBuffer : public EventBase
1044 {
1045 public:
type()1046 	int type()
1047 	{
1048 		return int(REQUEST_SAVE_BUFFER);
1049 	}
size()1050 	uint32_t size()
1051 	{
1052 		return sizeof(EventRequestSaveBuffer);
1053 	}
1054 
1055 	int track;
1056 	int scene;
1057 
1058 	size_t bufferSize;
1059 
1060 	// pointer to the AudioBuffer to be saved
1061 	AudioBuffer* ab;
1062 
EventRequestSaveBuffer()1063 	EventRequestSaveBuffer(): track(0), scene(0), ab(0) {}
EventRequestSaveBuffer(int t,int s,size_t si)1064 	EventRequestSaveBuffer(int t, int s, size_t si): track(t), scene(s), bufferSize(si), ab(0) {}
EventRequestSaveBuffer(int t,int s,AudioBuffer * a)1065 	EventRequestSaveBuffer(int t, int s, AudioBuffer* a): track(t), scene(s), ab(a) {}
1066 };
1067 
1068 class EventDeallocateBuffer : public EventBase
1069 {
1070 public:
type()1071 	int type()
1072 	{
1073 		return int(DEALLOCATE_BUFFER);
1074 	}
size()1075 	uint32_t size()
1076 	{
1077 		return sizeof(EventDeallocateBuffer);
1078 	}
1079 
1080 	AudioBuffer* ab;
1081 
EventDeallocateBuffer()1082 	EventDeallocateBuffer(): ab(0) {}
EventDeallocateBuffer(AudioBuffer * a)1083 	EventDeallocateBuffer(AudioBuffer* a): ab(a) {}
1084 };
1085 
1086 
1087 // prints the string S in the GUI console
1088 class EventGuiPrint : public EventBase
1089 {
1090 public:
type()1091 	int type()
1092 	{
1093 		return int(GUI_PRINT);
1094 	}
size()1095 	uint32_t size()
1096 	{
1097 		return sizeof(EventGuiPrint);
1098 	}
1099 
1100 	char stringArray[50];
1101 
EventGuiPrint()1102 	EventGuiPrint() {}
EventGuiPrint(const char * s)1103 	EventGuiPrint(const char* s)
1104 	{
1105 		if ( strlen( s ) > 49 ) {
1106 			// this will be called from an RT context, and should be removed from
1107 			// production code. It is here for the programmer to notice when they
1108 			// are using code which causes too long a message.
1109 			cout << "EventGuiPrint() error! Size of string too long!" << endl;
1110 		} else {
1111 			// move the sting into this event
1112 			strcpy( &stringArray[0], s );
1113 		}
1114 	}
getMessage()1115 	char* getMessage()
1116 	{
1117 		return &stringArray[0];
1118 	}
1119 };
1120 
1121 
1122 class EventControllerBindingTarget : public EventBase
1123 {
1124 public:
type()1125 	int type()
1126 	{
1127 		return int(CONTROLLER_BINDING_TARGET);
1128 	}
size()1129 	uint32_t size()
1130 	{
1131 		return sizeof(EventControllerBindingTarget);
1132 	}
1133 	char target[50];
1134 
EventControllerBindingTarget()1135 	EventControllerBindingTarget() {}
EventControllerBindingTarget(const char * s)1136 	EventControllerBindingTarget(const char* s)
1137 	{
1138 		if ( strlen( s ) > 49 ) {
1139 			// this will be called from an RT context, and should be removed from
1140 			// production code. It is here for the programmer to notice when they
1141 			// are using code which causes too long a message.
1142 			cout << "EventControllerBindingTarget() error! Size of string too long!" << endl;
1143 		} else {
1144 			// move the sting into this event
1145 			strcpy( &target[0], s );
1146 		}
1147 	}
getMessage()1148 	char* getMessage()
1149 	{
1150 		return &target[0];
1151 	}
1152 };
1153 
1154 
1155 #endif // LUPPP_EVENT_H
1156 
1157