forked from dliganov/Chaotic-DAW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Awful_events_triggers.h
203 lines (183 loc) · 6.17 KB
/
Awful_events_triggers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#ifndef EVENTS_TRIGGERS_H
#define EVENTS_TRIGGERS_H
#include "awful.h"
class Trigger
{
public:
Event* ev;
Element* el;
Pattern* patt;
bool activator; // Whether this trigger activates or deactivates an element
bool muted;
bool broken; // Interrupted by break or other symbol
int voicenum;
// Antialiasing helper variables
float auxbuff[1024];
bool aaIN;
bool aaOUT;
int aaFilledCount;
int aaCount;
int auCount;
float prev_value;
float aaBaseVal;
float cf1;
float cf2;
Trigger* tgact; // reference to the activator trigger if this one is a deactivator, otherwise NULL
bool outsync; // When this trigger is outsync'ed with playback (per lining for example)
bool tgworking;
bool toberemoved;
bool listed_globally;
Pattern* apatt_instance; // Autopattern instance for this trigga
Trk* trkdata;
double wt_pos; // Wavetable position integer
long frame_phase;
double sec_phase;
double sec_phase1;
double sec_phase2;
double sec_phase3;
float envVal1;
float envVal2;
float envVal3;
float envVal4;
float envVal5;
float lcount;
EnvPnt* ep1;
EnvPnt* ep2;
EnvPnt* ep3;
EnvPnt* ep4;
EnvPnt* ep5;
double env_phase1;
double env_phase2;
double env_phase3;
double env_phase4;
double env_phase5;
TgState tgstate;
float vol_val;
float pan_val;
float vol_base;
float pan_base;
int note_val;
double freq_incr_base;
double freq_incr_active;
int freq_incr_sgn;
float freq; // Constant part of the frequency
bool rev;
bool skip;
Mixcell* mcell;
MixChannel* mchan;
PreviewSlot* pslot;
Trigger* first_tgslide;
Trigger* tgsactive;
Trigger* tgsparent;
int tgsactnum;
//////////////////////////////////////
// Linked list pointers
//////////////////////////////////////
Trigger* act_prev; // Global active list
Trigger* act_next;
Trigger* loc_act_prev; // Local active list
Trigger* loc_act_next;
Trigger* ev_prev; // Event internal list
Trigger* ev_next;
Trigger* el_prev; // Element clones list
Trigger* el_next;
Trigger* pt_prev; // Pattern internal list
Trigger* pt_next;
Trigger* group_prev; // For group lists (envelopes, slidenotes, etc.)
Trigger* group_next;
Trigger();
void Initialize();
void Activate();
void Deactivate();
void Release();
void SoftFinish();
bool IsInstant();
bool IsSymbol();
bool IsOutOfPlayback();
bool CheckRemoval();
};
class Event
{
public:
long frame;
long framecount;
float vick;
Pattern* patt;
Event* next;
Event* prev;
Trigger* tg_first;
Trigger* tg_last;
bool queued;
bool to_be_deleted;
Event();
void AddTrigger(Trigger* c);
bool RemoveTrigger(Trigger* c);
};
class Playback
{
public:
Event* queued_ev;
Event* first_ev;
long ev_count_down;
bool looped;
long rng_start_frame;
long rng_end_frame;
Pattern* playPatt;
long currFrame;
double currFrame_tsync; // Time-synced value of current frame
bool tsync_block;
double currTick;
bool at_start;
bool dworking;
bool pactive;
Playback* prev;
Playback* next;
Playback();
Playback(Pattern* ppt);
void SetPlayPatt(Pattern* pPt);
void SetActive();
void SetInactive();
void UnqueueAll();
void UpdateQueuedEv();
void TickFrame(long nc, long dcount, long fpb);
void SetRanges(long start, long end);
void SetLooped(bool loop);
void SetCurrFrame(long frame);
void SetCurrTick(double tick);
void SetCurrFrameNOR(long frame);
void SetFrameToTick();
void AlignRangeToPattern();
bool IsAtStart();
void ResetLooped();
void ResetPos();
void GetSmallestCountDown(long* count);
long Requeue(bool change);
};
extern bool IsInstantTrigger(Trigger* tg);
extern bool IsSymbolTrigger(Trigger* tg);
extern bool IsTriggerOutOfPlayback(Trigger* tg);
extern void GlobalAddActiveTrigger(Trigger* tg);
extern void GlobalRemoveActiveTrigger(Trigger* tg);
extern void CleanupEvents(Pattern* pt);
extern void UpdateEventsFrames(Pattern* pt);
extern void RemoveTriggerFromEvent(Trigger* c);
extern void CreateElementTriggersPerPattern(Pattern* pt, Element* el, bool skipaddtoelement = false);
extern void Locate_Trigger(Trigger* tg);
extern void Del_Element_Triggers(Element* el);
extern void Del_Pattern_Internal_Triggers(Pattern* pt, bool skipelremove = false);
extern void MakeTriggersForElement(Element* el, Pattern* ptmain);
extern void RemoveTriggerFromEvent(Trigger* c);
extern void DeactivateTriggerCommon(Trigger* tg);
extern void ActivateCommandTrigger(Trigger* tg);
extern void DeactivateCommandTrigger(Trigger* tg);
extern void DeactivateSymbolTrigger(Trigger* efftg);
extern void ActivateSymbolTrigger(Trigger* efftg);
extern void DeactivatePlayback(Playback* pbk);
extern void ActivatePlayback(Playback* pbk);
extern void DisableAllPlaybacks();
extern void AddAutopatternInstance(Trigger* tg, NoteInstance* ii, bool add);
extern void SetMixcell4Trigger(Trigger* tg);
extern void SetMixChannel4Trigger(Trigger* tg);
extern void PreInitEnvelopes(tframe frame, Pattern* pt, Event* firstev, bool activate_env, bool paraminit = true);
extern void PreInitSamples(tframe frame, Pattern* pt, Event* firstev);
#endif //EVENTS_TRIGGERS_H