From ba935ab03589acd41dd68091711694fc16ad895b Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 4 Apr 2015 22:22:03 +0100 Subject: [PATCH] Check a voice is available before each CC trigger. If more than one sample is triggered by the same CC event, then it's possible to run out of voices during the loop. Move the check for an available voice into the loop to fix this. (Found while playing SalamanderGrandPianoV3, which triggers multiple samples from the sustain pedal.) --- sampler_channel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sampler_channel.c b/sampler_channel.c index 759f602..5b36c3d 100644 --- a/sampler_channel.c +++ b/sampler_channel.c @@ -72,7 +72,7 @@ void sampler_channel_process_cc(struct sampler_channel *c, int cc, int val) { struct sampler_module *m = c->module; // Handle CC triggering. - if (c->program && c->program->rll && c->program->rll->layers_oncc && m->voices_free) + if (c->program && c->program->rll && c->program->rll->layers_oncc) { struct sampler_rll *rll = c->program->rll; if (!(rll->cc_trigger_bitmask[cc >> 5] & (1 << (cc & 31)))) @@ -90,6 +90,8 @@ void sampler_channel_process_cc(struct sampler_channel *c, int cc, int val) !(old_value >= layer->runtime->on_locc && old_value <= layer->runtime->on_hicc)) { struct sampler_voice *v = m->voices_free; + if (!v) + break; int exgroups[MAX_RELEASED_GROUPS], exgroupcount = 0; sampler_voice_start(v, c, layer->runtime, layer->runtime->pitch_keycenter, 127, exgroups, &exgroupcount); sampler_channel_release_groups(c, -1, exgroups, exgroupcount); -- 2.11.4.GIT