aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md15
-rw-r--r--config.c79
-rw-r--r--monster.cfg120
-rw-r--r--unifest-17.cfg291
4 files changed, 303 insertions, 202 deletions
diff --git a/README.md b/README.md
index dca6e73..07cf30d 100644
--- a/README.md
+++ b/README.md
@@ -36,10 +36,19 @@ A configuration section may either be a *backend configuration* section, started
The `[map]` section consists of lines of channel-to-channel assignments, reading like
```
-instance.target-channel = instance.source-channel
+instance.channel-a < instance.channel-b
+instance.channel-a > instance.channel-b
+instance.channel-c <> instance.channel-d
```
-Assignments are one-way only, so to create a bi-directional mapping two assignments are needed.
+The first line above maps any event originating from `instance.channel-b` to be output
+on `instance.channel-a` (right-to-left mapping).
+
+The second line makes that mapping a bi-directional mapping, so both of those channels
+output eachothers events.
+
+The last line is a shorter way to create a bi-directional mapping.
+
An example configuration file can be found in [unifest-17.cfg](unifest-17.cfg).
## Backend documentation
@@ -151,6 +160,8 @@ loop.foo = loop.bar123
It is possible to configure loops using this backend. Triggering a loop
will create a deadlock, preventing any other backends from generating events.
+Be careful with bidirectional channel mappings, as any input will be immediately
+output to the same channel again.
### The `osc` backend
diff --git a/config.c b/config.c
index c41a614..708b057 100644
--- a/config.c
+++ b/config.c
@@ -11,6 +11,12 @@ static enum {
map
} parser_state = none;
+typedef enum {
+ map_ltr,
+ map_rtl,
+ map_bidir
+} map_type;
+
static backend* current_backend = NULL;
static instance* current_instance = NULL;
@@ -28,10 +34,18 @@ static char* config_trim_line(char* in){
return in;
}
-static int config_map(char* to, char* from){
+static int config_map(char* to_raw, char* from_raw){
+ //create a copy because the original pointer may be used multiple times
+ char* to = strdup(to_raw), *from = strdup(from_raw);
char* chanspec_to = to, *chanspec_from = from;
instance* instance_to = NULL, *instance_from = NULL;
channel* channel_from = NULL, *channel_to = NULL;
+ int rv = 1;
+
+ if(!from || !to){
+ fprintf(stderr, "Failed to allocate memory\n");
+ return 1;
+ }
//separate channel spec from instance
for(; *chanspec_to && *chanspec_to != '.'; chanspec_to++){
@@ -42,7 +56,7 @@ static int config_map(char* to, char* from){
if(!*chanspec_to || !*chanspec_from){
fprintf(stderr, "Mapping does not contain a proper instance specification\n");
- return 1;
+ goto done;
}
//terminate
@@ -56,7 +70,7 @@ static int config_map(char* to, char* from){
if(!instance_to || !instance_from){
fprintf(stderr, "No such instance %s\n", instance_from ? to : from);
- return 1;
+ goto done;
}
channel_from = instance_from->backend->channel(instance_from, chanspec_from);
@@ -64,16 +78,21 @@ static int config_map(char* to, char* from){
if(!channel_from || !channel_to){
fprintf(stderr, "Failed to parse channel specifications\n");
- return 1;
+ goto done;
}
- return mm_map_channel(channel_from, channel_to);
+ rv = mm_map_channel(channel_from, channel_to);
+done:
+ free(from);
+ free(to);
+ return rv;
}
int config_read(char* cfg_file){
int rv = 1;
size_t line_alloc = 0;
ssize_t status;
+ map_type mapping_type = map_rtl;
char* line_raw = NULL, *line, *separator;
FILE* source = fopen(cfg_file, "r");
if(!source){
@@ -149,6 +168,48 @@ int config_read(char* cfg_file){
fprintf(stderr, "Created %s instance %s\n", line, separator);
}
}
+ else if(parser_state == map){
+ mapping_type = map_rtl;
+ //find separator
+ for(separator = line; *separator && *separator != '<' && *separator != '>'; separator++){
+ }
+
+ switch(*separator){
+ case '>':
+ mapping_type = map_ltr;
+ //fall through
+ case '<': //default
+ *separator = 0;
+ separator++;
+ break;
+ case 0:
+ default:
+ fprintf(stderr, "Not a channel mapping: %s\n", line);
+ goto bail;
+ }
+
+ if((mapping_type == map_ltr && *separator == '<')
+ || (mapping_type == map_rtl && *separator == '>')){
+ mapping_type = map_bidir;
+ separator++;
+ }
+
+ line = config_trim_line(line);
+ separator = config_trim_line(separator);
+
+ if(mapping_type == map_ltr || mapping_type == map_bidir){
+ if(config_map(separator, line)){
+ fprintf(stderr, "Failed to map channel %s to %s\n", line, separator);
+ goto bail;
+ }
+ }
+ if(mapping_type == map_rtl || mapping_type == map_bidir){
+ if(config_map(line, separator)){
+ fprintf(stderr, "Failed to map channel %s to %s\n", separator, line);
+ goto bail;
+ }
+ }
+ }
else{
//pass to parser
//find separator
@@ -156,7 +217,7 @@ int config_read(char* cfg_file){
}
if(!*separator){
- fprintf(stderr, "No assignment: %s\n", line);
+ fprintf(stderr, "Not an assignment: %s\n", line);
goto bail;
}
@@ -173,12 +234,6 @@ int config_read(char* cfg_file){
fprintf(stderr, "Failed to configure instance %s\n", current_instance->name);
goto bail;
}
- else if(parser_state == map){
- if(config_map(line, separator)){
- fprintf(stderr, "Failed to map channel\n");
- goto bail;
- }
- }
}
}
diff --git a/monster.cfg b/monster.cfg
index d915fae..3eca560 100644
--- a/monster.cfg
+++ b/monster.cfg
@@ -10,53 +10,85 @@ bind = * 8000
dest = ::1 8001
root = /1
+[osc t2]
+bind = * 8002
+dest = ::1 8001
+root = /1
+
[midi lc]
write = FLUID
[loopback loop]
[map]
-loop.x = test./xy:0
-loop.y = test./xy:1
-loop.f1 = test./fader1
-loop.f2 = test./fader2
-loop.f3 = test./fader3
-loop.f4 = test./fader4
-loop.t1 = test./toggle1
-loop.t2 = test./toggle2
-loop.t3 = test./toggle3
-loop.pa1 = test./push1
-loop.pa2 = test./push2
-loop.pa3 = test./push3
-loop.pa4 = test./push4
-loop.pa5 = test./push5
-loop.pa6 = test./push6
-loop.pa7 = test./push7
-loop.pa8 = test./push8
-loop.pa9 = test./push9
-loop.pb0 = test./push10
-loop.pb1 = test./push11
-loop.pb2 = test./push12
-
-lc.note0.30 = loop.x
-lc.note0.31 = loop.y
-lc.note0.32 = loop.f1
-lc.note0.33 = loop.f2
-lc.note0.34 = loop.f3
-lc.note0.35 = loop.f4
-lc.note0.36 = loop.t1
-lc.note0.37 = loop.t2
-lc.note0.38 = loop.t3
-
-lc.note0.63 = loop.pa1
-lc.note0.64 = loop.pa2
-lc.note0.65 = loop.pa3
-lc.note0.66 = loop.pa4
-lc.note0.67 = loop.pa5
-lc.note0.68 = loop.pa6
-lc.note0.69 = loop.pa7
-lc.note0.70 = loop.pa8
-lc.note0.71 = loop.pa9
-lc.note0.72 = loop.pb0
-lc.note0.73 = loop.pb1
-lc.note0.74 = loop.pb2
+loop.x < test./xy:0
+loop.y < test./xy:1
+loop.f1 < test./fader1
+loop.f2 < test./fader2
+loop.f3 < test./fader3
+loop.f4 < test./fader4
+loop.t1 < test./toggle1
+loop.t2 < test./toggle2
+loop.t3 < test./toggle3
+loop.pa1 < test./push1
+loop.pa2 < test./push2
+loop.pa3 < test./push3
+loop.pa4 < test./push4
+loop.pa5 < test./push5
+loop.pa6 < test./push6
+loop.pa7 < test./push7
+loop.pa8 < test./push8
+loop.pa9 < test./push9
+loop.pb0 < test./push10
+loop.pb1 < test./push11
+loop.pb2 < test./push12
+
+loop.pc1 < t2./push1
+loop.pc2 < t2./push2
+loop.pc3 < t2./push3
+loop.pc4 < t2./push4
+loop.pc5 < t2./push5
+loop.pc6 < t2./push6
+loop.pc7 < t2./push7
+loop.pc8 < t2./push8
+loop.pc9 < t2./push9
+loop.pd0 < t2./push10
+loop.pd1 < t2./push11
+loop.pd2 < t2./push12
+
+
+lc.note0.30 < loop.x
+lc.note0.31 < loop.y
+lc.note0.32 < loop.f1
+lc.note0.33 < loop.f2
+lc.note0.34 < loop.f3
+lc.note0.35 < loop.f4
+lc.note0.36 < loop.t1
+lc.note0.37 < loop.t2
+lc.note0.38 < loop.t3
+
+lc.note0.48 < loop.pc1
+lc.note0.49 < loop.pc2
+lc.note0.50 < loop.pc3
+lc.note0.51 < loop.pc4
+lc.note0.52 < loop.pc5
+lc.note0.53 < loop.pc6
+lc.note0.54 < loop.pc7
+lc.note0.55 < loop.pc8
+lc.note0.56 < loop.pc9
+lc.note0.57 < loop.pd0
+lc.note0.58 < loop.pd1
+lc.note0.59 < loop.pd2
+
+lc.note0.60 < loop.pa1
+lc.note0.61 < loop.pa2
+lc.note0.62 < loop.pa3
+lc.note0.63 < loop.pa4
+lc.note0.64 < loop.pa5
+lc.note0.65 < loop.pa6
+lc.note0.66 < loop.pa7
+lc.note0.67 < loop.pa8
+lc.note0.68 < loop.pa9
+lc.note0.69 < loop.pb0
+lc.note0.70 < loop.pb1
+lc.note0.71 < loop.pb2
diff --git a/unifest-17.cfg b/unifest-17.cfg
index 0c43c1f..35f34b7 100644
--- a/unifest-17.cfg
+++ b/unifest-17.cfg
@@ -1,3 +1,6 @@
+; Note that this configuration file was originally written with
+; an older syntax and thus only contains right-to-left mappings
+
[backend midi]
name = MIDIMonster
@@ -39,156 +42,156 @@ read = 36:1
[map]
; ArtNet
-claudius.1 = lc1.cc0.1
-claudius.2 = lc1.cc0.2
-claudius.3 = lc1.cc0.3
-claudius.4 = lc1.cc0.4
-claudius.5 = lc1.cc0.5
-claudius.6 = lc1.cc0.6
-claudius.7 = lc1.cc0.7
-claudius.8 = lc1.cc0.8
-claudius.9 = lc1.cc0.9
-claudius.10 = lc1.cc0.10
-claudius.11 = lc1.cc0.11
-claudius.12 = lc1.cc0.12
-claudius.13 = lc1.cc0.13
-claudius.14 = lc1.cc0.14
-claudius.15 = lc1.cc0.15
-claudius.16 = lc1.cc0.16
+claudius.1 < lc1.cc0.1
+claudius.2 < lc1.cc0.2
+claudius.3 < lc1.cc0.3
+claudius.4 < lc1.cc0.4
+claudius.5 < lc1.cc0.5
+claudius.6 < lc1.cc0.6
+claudius.7 < lc1.cc0.7
+claudius.8 < lc1.cc0.8
+claudius.9 < lc1.cc0.9
+claudius.10 < lc1.cc0.10
+claudius.11 < lc1.cc0.11
+claudius.12 < lc1.cc0.12
+claudius.13 < lc1.cc0.13
+claudius.14 < lc1.cc0.14
+claudius.15 < lc1.cc0.15
+claudius.16 < lc1.cc0.16
; BCF Fader
-out.note0.0 = bcf1.cc0.81
-out.note0.1 = bcf1.cc0.82
-out.note0.2 = bcf1.cc0.83
-out.note0.3 = bcf1.cc0.84
-out.note0.4 = bcf1.cc0.85
-out.note0.5 = bcf1.cc0.86
-out.note0.6 = bcf1.cc0.87
-out.note0.7 = bcf1.cc0.88
-out.note0.8 = bcf2.cc0.81
-out.note0.9 = bcf2.cc0.82
-out.note0.10 = bcf2.cc0.83
-out.note0.11 = bcf2.cc0.84
-out.note0.12 = bcf2.cc0.85
-out.note0.13 = bcf2.cc0.86
-out.note0.14 = bcf2.cc0.87
-out.note0.15 = bcf2.cc0.88
+out.note0.0 < bcf1.cc0.81
+out.note0.1 < bcf1.cc0.82
+out.note0.2 < bcf1.cc0.83
+out.note0.3 < bcf1.cc0.84
+out.note0.4 < bcf1.cc0.85
+out.note0.5 < bcf1.cc0.86
+out.note0.6 < bcf1.cc0.87
+out.note0.7 < bcf1.cc0.88
+out.note0.8 < bcf2.cc0.81
+out.note0.9 < bcf2.cc0.82
+out.note0.10 < bcf2.cc0.83
+out.note0.11 < bcf2.cc0.84
+out.note0.12 < bcf2.cc0.85
+out.note0.13 < bcf2.cc0.86
+out.note0.14 < bcf2.cc0.87
+out.note0.15 < bcf2.cc0.88
; LC Rotary
-out.note0.16 = lc1.cc0.1
-out.note0.17 = lc1.cc0.2
-out.note0.18 = lc1.cc0.3
-out.note0.19 = lc1.cc0.4
-out.note0.20 = lc1.cc0.5
-out.note0.21 = lc1.cc0.6
-out.note0.22 = lc1.cc0.7
-out.note0.23 = lc1.cc0.8
-out.note0.24 = lc1.cc0.9
-out.note0.25 = lc1.cc0.10
-out.note0.26 = lc1.cc0.11
-out.note0.27 = lc1.cc0.12
-out.note0.28 = lc1.cc0.13
-out.note0.29 = lc1.cc0.14
-out.note0.30 = lc1.cc0.15
-out.note0.31 = lc1.cc0.16
-out.note0.32 = lc2.cc0.1
-out.note0.33 = lc2.cc0.2
-out.note0.34 = lc2.cc0.3
-out.note0.35 = lc2.cc0.4
-out.note0.36 = lc2.cc0.5
-out.note0.37 = lc2.cc0.6
-out.note0.38 = lc2.cc0.7
-out.note0.39 = lc2.cc0.8
-out.note0.40 = lc2.cc0.9
-out.note0.41 = lc2.cc0.10
-out.note0.42 = lc2.cc0.11
-out.note0.43 = lc2.cc0.12
-out.note0.44 = lc2.cc0.13
-out.note0.45 = lc2.cc0.14
-out.note0.46 = lc2.cc0.15
-out.note0.47 = lc2.cc0.16
+out.note0.16 < lc1.cc0.1
+out.note0.17 < lc1.cc0.2
+out.note0.18 < lc1.cc0.3
+out.note0.19 < lc1.cc0.4
+out.note0.20 < lc1.cc0.5
+out.note0.21 < lc1.cc0.6
+out.note0.22 < lc1.cc0.7
+out.note0.23 < lc1.cc0.8
+out.note0.24 < lc1.cc0.9
+out.note0.25 < lc1.cc0.10
+out.note0.26 < lc1.cc0.11
+out.note0.27 < lc1.cc0.12
+out.note0.28 < lc1.cc0.13
+out.note0.29 < lc1.cc0.14
+out.note0.30 < lc1.cc0.15
+out.note0.31 < lc1.cc0.16
+out.note0.32 < lc2.cc0.1
+out.note0.33 < lc2.cc0.2
+out.note0.34 < lc2.cc0.3
+out.note0.35 < lc2.cc0.4
+out.note0.36 < lc2.cc0.5
+out.note0.37 < lc2.cc0.6
+out.note0.38 < lc2.cc0.7
+out.note0.39 < lc2.cc0.8
+out.note0.40 < lc2.cc0.9
+out.note0.41 < lc2.cc0.10
+out.note0.42 < lc2.cc0.11
+out.note0.43 < lc2.cc0.12
+out.note0.44 < lc2.cc0.13
+out.note0.45 < lc2.cc0.14
+out.note0.46 < lc2.cc0.15
+out.note0.47 < lc2.cc0.16
; LC Button
-out.note0.48 = lc1.note0.0
-out.note0.49 = lc1.note0.1
-out.note0.50 = lc1.note0.2
-out.note0.51 = lc1.note0.3
-out.note0.52 = lc1.note0.4
-out.note0.53 = lc1.note0.5
-out.note0.54 = lc1.note0.6
-out.note0.55 = lc1.note0.7
+out.note0.48 < lc1.note0.0
+out.note0.49 < lc1.note0.1
+out.note0.50 < lc1.note0.2
+out.note0.51 < lc1.note0.3
+out.note0.52 < lc1.note0.4
+out.note0.53 < lc1.note0.5
+out.note0.54 < lc1.note0.6
+out.note0.55 < lc1.note0.7
-out.note0.56 = lc2.note0.0
-out.note0.57 = lc2.note0.1
-out.note0.58 = lc2.note0.2
-out.note0.59 = lc2.note0.3
-out.note0.60 = lc2.note0.4
-out.note0.61 = lc2.note0.5
-out.note0.62 = lc2.note0.6
-out.note0.63 = lc2.note0.7
+out.note0.56 < lc2.note0.0
+out.note0.57 < lc2.note0.1
+out.note0.58 < lc2.note0.2
+out.note0.59 < lc2.note0.3
+out.note0.60 < lc2.note0.4
+out.note0.61 < lc2.note0.5
+out.note0.62 < lc2.note0.6
+out.note0.63 < lc2.note0.7
; Launchpad
-out.note0.64 = pad.note0.0
-out.note0.65 = pad.note0.1
-out.note0.66 = pad.note0.2
-out.note0.67 = pad.note0.3
-out.note0.68 = pad.note0.4
-out.note0.69 = pad.note0.5
-out.note0.70 = pad.note0.6
-out.note0.71 = pad.note0.7
-out.note0.72 = pad.note0.16
-out.note0.73 = pad.note0.17
-out.note0.74 = pad.note0.18
-out.note0.75 = pad.note0.19
-out.note0.76 = pad.note0.20
-out.note0.77 = pad.note0.21
-out.note0.78 = pad.note0.22
-out.note0.79 = pad.note0.23
-out.note0.80 = pad.note0.32
-out.note0.81 = pad.note0.33
-out.note0.82 = pad.note0.34
-out.note0.83 = pad.note0.35
-out.note0.84 = pad.note0.36
-out.note0.85 = pad.note0.37
-out.note0.86 = pad.note0.38
-out.note0.87 = pad.note0.39
-out.note0.88 = pad.note0.48
-out.note0.89 = pad.note0.49
-out.note0.90 = pad.note0.50
-out.note0.91 = pad.note0.51
-out.note0.92 = pad.note0.52
-out.note0.93 = pad.note0.53
-out.note0.94 = pad.note0.54
-out.note0.95 = pad.note0.55
-out.note0.96 = pad.note0.64
-out.note0.97 = pad.note0.65
-out.note0.98 = pad.note0.66
-out.note0.99 = pad.note0.67
-out.note0.100 = pad.note0.68
-out.note0.101 = pad.note0.69
-out.note0.102 = pad.note0.70
-out.note0.103 = pad.note0.71
-out.note0.104 = pad.note0.80
-out.note0.105 = pad.note0.81
-out.note0.106 = pad.note0.82
-out.note0.107 = pad.note0.83
-out.note0.108 = pad.note0.84
-out.note0.109 = pad.note0.85
-out.note0.110 = pad.note0.86
-out.note0.111 = pad.note0.87
-out.note0.112 = pad.note0.96
-out.note0.113 = pad.note0.97
-out.note0.114 = pad.note0.98
-out.note0.115 = pad.note0.99
-out.note0.116 = pad.note0.100
-out.note0.117 = pad.note0.101
-out.note0.118 = pad.note0.102
-out.note0.119 = pad.note0.103
-out.note0.120 = pad.note0.112
-out.note0.121 = pad.note0.113
-out.note0.122 = pad.note0.114
-out.note0.123 = pad.note0.115
-out.note0.124 = pad.note0.116
-out.note0.125 = pad.note0.117
-out.note0.126 = pad.note0.118
-out.note0.127 = pad.note0.119
+out.note0.64 < pad.note0.0
+out.note0.65 < pad.note0.1
+out.note0.66 < pad.note0.2
+out.note0.67 < pad.note0.3
+out.note0.68 < pad.note0.4
+out.note0.69 < pad.note0.5
+out.note0.70 < pad.note0.6
+out.note0.71 < pad.note0.7
+out.note0.72 < pad.note0.16
+out.note0.73 < pad.note0.17
+out.note0.74 < pad.note0.18
+out.note0.75 < pad.note0.19
+out.note0.76 < pad.note0.20
+out.note0.77 < pad.note0.21
+out.note0.78 < pad.note0.22
+out.note0.79 < pad.note0.23
+out.note0.80 < pad.note0.32
+out.note0.81 < pad.note0.33
+out.note0.82 < pad.note0.34
+out.note0.83 < pad.note0.35
+out.note0.84 < pad.note0.36
+out.note0.85 < pad.note0.37
+out.note0.86 < pad.note0.38
+out.note0.87 < pad.note0.39
+out.note0.88 < pad.note0.48
+out.note0.89 < pad.note0.49
+out.note0.90 < pad.note0.50
+out.note0.91 < pad.note0.51
+out.note0.92 < pad.note0.52
+out.note0.93 < pad.note0.53
+out.note0.94 < pad.note0.54
+out.note0.95 < pad.note0.55
+out.note0.96 < pad.note0.64
+out.note0.97 < pad.note0.65
+out.note0.98 < pad.note0.66
+out.note0.99 < pad.note0.67
+out.note0.100 < pad.note0.68
+out.note0.101 < pad.note0.69
+out.note0.102 < pad.note0.70
+out.note0.103 < pad.note0.71
+out.note0.104 < pad.note0.80
+out.note0.105 < pad.note0.81
+out.note0.106 < pad.note0.82
+out.note0.107 < pad.note0.83
+out.note0.108 < pad.note0.84
+out.note0.109 < pad.note0.85
+out.note0.110 < pad.note0.86
+out.note0.111 < pad.note0.87
+out.note0.112 < pad.note0.96
+out.note0.113 < pad.note0.97
+out.note0.114 < pad.note0.98
+out.note0.115 < pad.note0.99
+out.note0.116 < pad.note0.100
+out.note0.117 < pad.note0.101
+out.note0.118 < pad.note0.102
+out.note0.119 < pad.note0.103
+out.note0.120 < pad.note0.112
+out.note0.121 < pad.note0.113
+out.note0.122 < pad.note0.114
+out.note0.123 < pad.note0.115
+out.note0.124 < pad.note0.116
+out.note0.125 < pad.note0.117
+out.note0.126 < pad.note0.118
+out.note0.127 < pad.note0.119