diff options
author | cbdev <cb@cbcdn.com> | 2019-07-24 21:38:45 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2019-07-24 21:38:45 +0200 |
commit | 8d7fb5b7cb2f1deb6600f8cebfff27dba70193b1 (patch) | |
tree | 7cb3509f6039e5c467516c87943f83256816751e | |
parent | 27eba094a067a0879250a3cf73c83df0da5c63a1 (diff) | |
download | midimonster-8d7fb5b7cb2f1deb6600f8cebfff27dba70193b1.tar.gz midimonster-8d7fb5b7cb2f1deb6600f8cebfff27dba70193b1.tar.bz2 midimonster-8d7fb5b7cb2f1deb6600f8cebfff27dba70193b1.zip |
Allow n:1 multi-channel mapping
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | config.c | 8 |
2 files changed, 6 insertions, 5 deletions
@@ -98,7 +98,8 @@ delimiting a range of channels. Multiple such expressions may be used in one ch specification, with the rightmost expression being incremented (or decremented) first for evaluation. -Both sides of a multi-channel assignment need to have the same number of channels. +Both sides of a multi-channel assignment need to have the same number of channels, or one +side must have exactly one channel. Example multi-channel mapping: @@ -220,7 +220,7 @@ static int config_map(char* to_raw, char* from_raw){ goto done; } - if(spec_to.channels != spec_from.channels + if((spec_to.channels != spec_from.channels && spec_from.channels != 1 && spec_to.channels != 1) || spec_to.channels == 0 || spec_from.channels == 0){ fprintf(stderr, "Multi-channel specification size mismatch: %s.%s (%lu channels) - %s.%s (%lu channels)\n", @@ -235,9 +235,9 @@ static int config_map(char* to_raw, char* from_raw){ //iterate, resolve globs and map rv = 0; - for(n = 0; !rv && n < spec_from.channels; n++){ - channel_from = config_glob_resolve(instance_from, &spec_from, n); - channel_to = config_glob_resolve(instance_to, &spec_to, n); + for(n = 0; !rv && n < max(spec_from.channels, spec_to.channels); n++){ + channel_from = config_glob_resolve(instance_from, &spec_from, min(n, spec_from.channels)); + channel_to = config_glob_resolve(instance_to, &spec_to, min(n, spec_to.channels)); if(!channel_from || !channel_to){ rv = 1; |