aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-07-24 21:38:45 +0200
committercbdev <cb@cbcdn.com>2019-07-24 21:38:45 +0200
commit8d7fb5b7cb2f1deb6600f8cebfff27dba70193b1 (patch)
tree7cb3509f6039e5c467516c87943f83256816751e
parent27eba094a067a0879250a3cf73c83df0da5c63a1 (diff)
downloadmidimonster-8d7fb5b7cb2f1deb6600f8cebfff27dba70193b1.tar.gz
midimonster-8d7fb5b7cb2f1deb6600f8cebfff27dba70193b1.tar.bz2
midimonster-8d7fb5b7cb2f1deb6600f8cebfff27dba70193b1.zip
Allow n:1 multi-channel mapping
-rw-r--r--README.md3
-rw-r--r--config.c8
2 files changed, 6 insertions, 5 deletions
diff --git a/README.md b/README.md
index bce7b71..3704f5f 100644
--- a/README.md
+++ b/README.md
@@ -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:
diff --git a/config.c b/config.c
index 24f1223..6d5fd16 100644
--- a/config.c
+++ b/config.c
@@ -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;