89 |
Region::Region() |
Region::Region() |
90 |
{ |
{ |
91 |
pSample = NULL; |
pSample = NULL; |
92 |
|
seq_counter = 1; |
93 |
} |
} |
94 |
|
|
95 |
Region::~Region() |
Region::~Region() |
122 |
Region::OnKey(uint8_t chan, uint8_t key, uint8_t vel, |
Region::OnKey(uint8_t chan, uint8_t key, uint8_t vel, |
123 |
int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft, |
int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft, |
124 |
uint8_t prog, float rand, trigger_t trig, uint8_t* cc, |
uint8_t prog, float rand, trigger_t trig, uint8_t* cc, |
125 |
float timer, uint8_t seq, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key) |
float timer, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key) |
126 |
{ |
{ |
127 |
// chan (MIDI channel) |
// chan (MIDI channel) |
128 |
// key (MIDI note) |
// key (MIDI note) |
138 |
// cc (all 128 CC values) |
// cc (all 128 CC values) |
139 |
|
|
140 |
// timer (time since previous region in the group was triggered) |
// timer (time since previous region in the group was triggered) |
|
// seq (the state of the region sequence counter) |
|
141 |
// sw (the state of region key switches, 128 possible values) |
// sw (the state of region key switches, 128 possible values) |
142 |
// last_sw_key (the last key pressed in the key switch range) |
// last_sw_key (the last key pressed in the key switch range) |
143 |
// prev_sw_key (the previous note value) |
// prev_sw_key (the previous note value) |
147 |
key >= lokey && key <= hikey && |
key >= lokey && key <= hikey && |
148 |
vel >= lovel && vel <= hivel && |
vel >= lovel && vel <= hivel && |
149 |
bend >= lobend && bend <= hibend && |
bend >= lobend && bend <= hibend && |
150 |
bpm >= lobpm && bpm <= hibpm && |
bpm >= lobpm && bpm < hibpm && |
151 |
chanaft >= lochanaft && chanaft <= hichanaft && |
chanaft >= lochanaft && chanaft <= hichanaft && |
152 |
polyaft >= lopolyaft && polyaft <= hipolyaft && |
polyaft >= lopolyaft && polyaft <= hipolyaft && |
153 |
prog >= loprog && prog <= hiprog && |
prog >= loprog && prog <= hiprog && |
154 |
rand >= lorand && rand <= hirand && |
rand >= lorand && rand < hirand && |
155 |
timer >= lotimer && timer <= hitimer && |
timer >= lotimer && timer <= hitimer && |
|
seq == seq_position && |
|
156 |
|
|
157 |
( (sw_lokey == -1 || sw_hikey == -1 || sw_last == -1) || |
( (sw_lokey == -1 || sw_hikey == -1 || sw_last == -1) || |
158 |
((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : true) ) && |
((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : true) ) && |
176 |
return false; |
return false; |
177 |
} |
} |
178 |
|
|
179 |
return true; |
// seq_position has to be checked last, so we know that we |
180 |
|
// increment the right counter |
181 |
|
is_triggered = (seq_counter == seq_position); |
182 |
|
seq_counter = (seq_counter % seq_length) + 1; |
183 |
|
|
184 |
|
return is_triggered; |
185 |
} |
} |
186 |
|
|
187 |
bool |
bool |
188 |
Region::OnControl(uint8_t chan, uint8_t cont, uint8_t val, |
Region::OnControl(uint8_t chan, uint8_t cont, uint8_t val, |
189 |
int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft, |
int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft, |
190 |
uint8_t prog, float rand, trigger_t trig, uint8_t* cc, |
uint8_t prog, float rand, trigger_t trig, uint8_t* cc, |
191 |
float timer, uint8_t seq, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key) |
float timer, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key) |
192 |
{ |
{ |
193 |
// chan (MIDI channel) |
// chan (MIDI channel) |
194 |
// cont (MIDI controller) |
// cont (MIDI controller) |
204 |
// cc (all CC values) |
// cc (all CC values) |
205 |
|
|
206 |
// timer (time since previous region in the group was triggered) |
// timer (time since previous region in the group was triggered) |
|
// seq (the state of the region sequence counter) |
|
207 |
// sw (the state of region key switches, 128 possible values) |
// sw (the state of region key switches, 128 possible values) |
208 |
// last_sw_key (the last key pressed in the key switch range) |
// last_sw_key (the last key pressed in the key switch range) |
209 |
// prev_sw_key (the previous note value) |
// prev_sw_key (the previous note value) |
213 |
((val >= on_locc[cont] && val <= on_hicc[cont]) || |
((val >= on_locc[cont] && val <= on_hicc[cont]) || |
214 |
(val >= start_locc[cont] && val <= start_hicc[cont])) && |
(val >= start_locc[cont] && val <= start_hicc[cont])) && |
215 |
bend >= lobend && bend <= hibend && |
bend >= lobend && bend <= hibend && |
216 |
bpm >= lobpm && bpm <= hibpm && |
bpm >= lobpm && bpm < hibpm && |
217 |
chanaft >= lochanaft && chanaft <= hichanaft && |
chanaft >= lochanaft && chanaft <= hichanaft && |
218 |
polyaft >= lopolyaft && polyaft <= hipolyaft && |
polyaft >= lopolyaft && polyaft <= hipolyaft && |
219 |
prog >= loprog && prog <= hiprog && |
prog >= loprog && prog <= hiprog && |
220 |
rand >= lorand && rand <= hirand && |
rand >= lorand && rand < hirand && |
221 |
timer >= lotimer && timer <= hitimer && |
timer >= lotimer && timer <= hitimer && |
|
seq == seq_position && |
|
222 |
|
|
223 |
( (sw_lokey == -1 || sw_hikey == -1 || sw_last == -1) || |
( (sw_lokey == -1 || sw_hikey == -1 || sw_last == -1) || |
224 |
((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : true) ) && |
((sw_last >= sw_lokey && sw_last <= sw_hikey) ? (last_sw_key == sw_last) : true) ) && |
289 |
uint8_t chan, uint8_t key, uint8_t vel, |
uint8_t chan, uint8_t key, uint8_t vel, |
290 |
int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft, |
int bend, uint8_t bpm, uint8_t chanaft, uint8_t polyaft, |
291 |
uint8_t prog, float rand, trigger_t trig, uint8_t* cc, |
uint8_t prog, float rand, trigger_t trig, uint8_t* cc, |
292 |
float timer, uint8_t seq, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key |
float timer, bool* sw, uint8_t last_sw_key, uint8_t prev_sw_key |
293 |
) { |
) { |
294 |
std::vector<Region*> v; |
std::vector<Region*> v; |
295 |
for (int i = 0; i < regions.size(); i++) { |
for (int i = 0; i < regions.size(); i++) { |
296 |
if (regions[i]->OnKey ( |
if (regions[i]->OnKey ( |
297 |
chan, key, vel, bend, bpm, chanaft, polyaft, prog, |
chan, key, vel, bend, bpm, chanaft, polyaft, prog, |
298 |
rand, trig, cc, timer, seq, sw, last_sw_key, prev_sw_key) |
rand, trig, cc, timer, sw, last_sw_key, prev_sw_key) |
299 |
) { v.push_back(regions[i]); } |
) { v.push_back(regions[i]); } |
300 |
} |
} |
301 |
|
|
535 |
pitcheg_decay = 0; |
pitcheg_decay = 0; |
536 |
pitcheg_sustain = 100; // in percentage |
pitcheg_sustain = 100; // in percentage |
537 |
pitcheg_release = 0; |
pitcheg_release = 0; |
538 |
|
|
539 |
|
amplfo_delay = 0; |
540 |
|
amplfo_fade = 0; |
541 |
|
amplfo_freq = 0; |
542 |
|
amplfo_depth = 0; |
543 |
|
|
544 |
|
fillfo_delay = 0; |
545 |
|
fillfo_fade = 0; |
546 |
|
fillfo_freq = 0; |
547 |
|
fillfo_depth = 0; |
548 |
|
|
549 |
|
pitchlfo_delay = 0; |
550 |
|
pitchlfo_fade = 0; |
551 |
|
pitchlfo_freq = 0; |
552 |
|
pitchlfo_depth = 0; |
553 |
} |
} |
554 |
|
|
555 |
Region* |
Region* |
757 |
region->pitcheg_sustain = pitcheg_sustain; |
region->pitcheg_sustain = pitcheg_sustain; |
758 |
region->pitcheg_release = pitcheg_release; |
region->pitcheg_release = pitcheg_release; |
759 |
|
|
760 |
|
region->amplfo_delay = amplfo_delay; |
761 |
|
region->amplfo_fade = amplfo_fade; |
762 |
|
region->amplfo_freq = amplfo_freq; |
763 |
|
region->amplfo_depth = amplfo_depth; |
764 |
|
|
765 |
|
region->fillfo_delay = fillfo_delay; |
766 |
|
region->fillfo_fade = fillfo_fade; |
767 |
|
region->fillfo_freq = fillfo_freq; |
768 |
|
region->fillfo_depth = fillfo_depth; |
769 |
|
|
770 |
|
region->pitchlfo_delay = pitchlfo_delay; |
771 |
|
region->pitchlfo_fade = pitchlfo_fade; |
772 |
|
region->pitchlfo_freq = pitchlfo_freq; |
773 |
|
region->pitchlfo_depth = pitchlfo_depth; |
774 |
|
|
775 |
return region; |
return region; |
776 |
} |
} |
777 |
|
|
1277 |
else if ("pitcheg_decay" == key) pCurDef->pitcheg_decay = ToFloat(value); |
else if ("pitcheg_decay" == key) pCurDef->pitcheg_decay = ToFloat(value); |
1278 |
else if ("pitcheg_sustain" == key) pCurDef->pitcheg_sustain = ToFloat(value); |
else if ("pitcheg_sustain" == key) pCurDef->pitcheg_sustain = ToFloat(value); |
1279 |
else if ("pitcheg_release" == key) pCurDef->pitcheg_release = ToFloat(value); |
else if ("pitcheg_release" == key) pCurDef->pitcheg_release = ToFloat(value); |
1280 |
|
|
1281 |
|
// v1 LFO |
1282 |
|
else if ("amplfo_delay" == key) pCurDef->amplfo_delay = ToFloat(value); |
1283 |
|
else if ("amplfo_fade" == key) pCurDef->amplfo_fade = ToFloat(value); |
1284 |
|
else if ("amplfo_freq" == key) pCurDef->amplfo_freq = ToFloat(value); |
1285 |
|
else if ("amplfo_depth" == key) pCurDef->amplfo_depth = ToFloat(value); |
1286 |
|
else if ("fillfo_delay" == key) pCurDef->fillfo_delay = ToFloat(value); |
1287 |
|
else if ("fillfo_fade" == key) pCurDef->fillfo_fade = ToFloat(value); |
1288 |
|
else if ("fillfo_freq" == key) pCurDef->fillfo_freq = ToFloat(value); |
1289 |
|
else if ("fillfo_depth" == key) pCurDef->fillfo_depth = ToFloat(value); |
1290 |
|
else if ("pitchlfo_delay" == key) pCurDef->pitchlfo_delay = ToFloat(value); |
1291 |
|
else if ("pitchlfo_fade" == key) pCurDef->pitchlfo_fade = ToFloat(value); |
1292 |
|
else if ("pitchlfo_freq" == key) pCurDef->pitchlfo_freq = ToFloat(value); |
1293 |
|
else if ("pitchlfo_depth" == key) pCurDef->pitchlfo_depth = ToInt(value); |
1294 |
|
|
1295 |
else { |
else { |
1296 |
std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl; |
std::cerr << "The opcode '" << key << "' is unsupported by libsfz!" << std::endl; |
1297 |
} |
} |