Keep empty instruments in sample list, to match up with hydrogen layout. NB: this will break existing patterns created against older versions of DrMr that used kits with empty instruments. Sorry about that.

This commit is contained in:
Nick Lanham 2012-02-21 13:16:37 +01:00
parent b3dd5bb1b2
commit 6bb66abca2
2 changed files with 13 additions and 7 deletions

7
drmr.c
View File

@ -210,10 +210,11 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
// changed after the check that the midi-note is valid
pthread_mutex_lock(&drmr->load_mutex);
if (nn >= 0 && nn < drmr->num_samples) {
if (drmr->samples[nn].layer_count > 0)
if (drmr->samples[nn].layer_count > 0) {
layer_to_sample(drmr->samples+nn,*(drmr->gains[nn]));
if (drmr->samples[nn].limit == 0)
fprintf(stderr,"Failed to find layer at: %i for %f\n",nn,*drmr->gains[nn]);
if (drmr->samples[nn].limit == 0)
fprintf(stderr,"Failed to find layer at: %i for %f\n",nn,*drmr->gains[nn]);
}
drmr->samples[nn].active = 1;
drmr->samples[nn].offset = 0;
}

View File

@ -175,9 +175,7 @@ endElement(void *userData, const char *name)
}
if (info->in_instrument &&
(info->cur_instrument && (info->cur_instrument->filename || info->cur_instrument->layers)) &&
!strcmp(name,"instrument")) {
if (info->in_instrument && info->cur_instrument && !strcmp(name,"instrument")) {
struct instrument_info * cur_i = info->kit_info->instruments;
if (cur_i) {
while(cur_i->next) cur_i = cur_i->next;
@ -530,7 +528,7 @@ drmr_sample* load_hydrogen_kit(char *path, double rate, int *num_samples) {
samples[i].limit = layer->limit;
samples[i].data = layer->data;
free(layer);
} else {
} else if (cur_i->layers) {
int layer_count = 0;
int j;
struct instrument_layer *cur_l = cur_i->layers;
@ -556,6 +554,13 @@ drmr_sample* load_hydrogen_kit(char *path, double rate, int *num_samples) {
j++;
cur_l = cur_l->next;
}
} else { // no layer or file, empty inst
samples[i].layer_count = 0;
samples[i].layers = NULL;
samples[i].offset = 0;
samples[i].info = NULL;
samples[i].limit = 0;
samples[i].data = NULL;
}
samples[i].active = 0;
i_to_free = cur_i;