aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2018-02-17 23:41:14 +0100
committercbdev <cb@cbcdn.com>2018-02-17 23:41:14 +0100
commitddf2409b2b2ded5d2ab65d45ebba8005755e2c35 (patch)
treeb5198b6e081dcdba660a5dd510fdb6f328a75117
parent99305b4ece22ce8c69729ffbf0da4d9b5f8daeae (diff)
parent8874c3bff295f93f2012ae016d5d34270bdb1ebb (diff)
downloadmidimonster-ddf2409b2b2ded5d2ab65d45ebba8005755e2c35.tar.gz
midimonster-ddf2409b2b2ded5d2ab65d45ebba8005755e2c35.tar.bz2
midimonster-ddf2409b2b2ded5d2ab65d45ebba8005755e2c35.zip
Merge branch 'master' into uinput
-rw-r--r--backend.c6
-rw-r--r--config.c6
-rw-r--r--configs/osc-kbd.cfg25
-rw-r--r--makefile1
-rw-r--r--midimonster.c3
-rw-r--r--midimonster.h33
-rw-r--r--monster.cfg1
7 files changed, 61 insertions, 14 deletions
diff --git a/backend.c b/backend.c
index eeb789d..38abc7f 100644
--- a/backend.c
+++ b/backend.c
@@ -26,6 +26,7 @@ int backends_handle(size_t nfds, managed_fd* fds){
}
}
+ DBGPF("Notifying backend %s of %zu waiting FDs\n", backends[u].name, n);
rv |= backends[u].process(n, fds);
}
return rv;
@@ -55,6 +56,7 @@ int backends_notify(size_t nev, channel** c, channel_value* v){
}
}
+ DBGPF("Calling handler for instance %s with %zu events\n", instances[u]->name, n);
rv |= instances[u]->backend->handle(instances[u], n, c, v);
}
@@ -65,14 +67,17 @@ channel* mm_channel(instance* i, uint64_t ident, uint8_t create){
size_t u;
for(u = 0; u < nchannels; u++){
if(channels[u]->instance == i && channels[u]->ident == ident){
+ DBGPF("Requested channel %zu on instance %s already exists, reusing\n", ident, i->name);
return channels[u];
}
}
if(!create){
+ DBGPF("Requested unknown channel %zu on instance %s\n", ident, i->name);
return NULL;
}
+ DBGPF("Creating previously unknown channel %zu on instance %s\n", ident, i->name);
channel** new_chan = realloc(channels, (nchannels + 1) * sizeof(channel*));
if(!new_chan){
fprintf(stderr, "Failed to allocate memory\n");
@@ -169,6 +174,7 @@ void instances_free(){
void channels_free(){
size_t u;
for(u = 0; u < nchannels; u++){
+ DBGPF("Destroying channel %zu on instance %s\n", channels[u]->ident, channels[u]->instance->name);
if(channels[u]->impl){
channels[u]->instance->backend->channel_free(channels[u]);
}
diff --git a/config.c b/config.c
index 708b057..f03d98a 100644
--- a/config.c
+++ b/config.c
@@ -213,10 +213,8 @@ int config_read(char* cfg_file){
else{
//pass to parser
//find separator
- for(separator = line; *separator && *separator != '='; separator++){
- }
-
- if(!*separator){
+ separator = strchr(line, '=');
+ if(!separator){
fprintf(stderr, "Not an assignment: %s\n", line);
goto bail;
}
diff --git a/configs/osc-kbd.cfg b/configs/osc-kbd.cfg
new file mode 100644
index 0000000..0abd131
--- /dev/null
+++ b/configs/osc-kbd.cfg
@@ -0,0 +1,25 @@
+; Maps a TouchOSC simpl keyboard layout to MIDI notes
+
+[backend midi]
+name = MIDIMonster
+
+[midi out]
+write = FLUID
+
+[osc pad]
+bind = * 8000
+dest = learn@8001
+
+[map]
+pad./1/push1 > out.note0.60
+pad./1/push2 > out.note0.61
+pad./1/push3 > out.note0.62
+pad./1/push4 > out.note0.63
+pad./1/push5 > out.note0.64
+pad./1/push6 > out.note0.65
+pad./1/push7 > out.note0.66
+pad./1/push8 > out.note0.67
+pad./1/push9 > out.note0.68
+pad./1/push10 > out.note0.69
+pad./1/push11 > out.note0.70
+pad./1/push12 > out.note0.71
diff --git a/makefile b/makefile
index 17faeb0..7778ebd 100644
--- a/makefile
+++ b/makefile
@@ -4,6 +4,7 @@ OBJS = config.o backend.o plugin.o
PLUGINDIR = "\"./\""
CFLAGS ?= -g -Wall
+#CFLAGS += -DDEBUG
%.so: CFLAGS += -fPIC
%.so: LDFLAGS += -shared
diff --git a/midimonster.c b/midimonster.c
index 8f30686..c8a0109 100644
--- a/midimonster.c
+++ b/midimonster.c
@@ -248,6 +248,7 @@ int main(int argc, char** argv){
}
//create initial fd set
+ DBGPF("Building selector set from %zu FDs registered to core\n", fds);
FD_ZERO(&all_fds);
for(u = 0; u < fds; u++){
if(fd[u].fd >= 0){
@@ -277,6 +278,7 @@ int main(int argc, char** argv){
}
//run backend processing, collect events
+ DBGPF("%zu backend FDs signaled\n", n);
if(backends_handle(n, signaled_fds)){
fprintf(stderr, "Backends failed to handle input\n");
goto bail;
@@ -284,6 +286,7 @@ int main(int argc, char** argv){
while(primary->n){
//swap primary and secondary event collectors
+ DBGPF("Swapping event collectors, %zu events in primary\n", primary->n);
for(u = 0; u < sizeof(event_pool)/sizeof(event_collection); u++){
if(primary != event_pool + u){
secondary = primary;
diff --git a/midimonster.h b/midimonster.h
index 3cf6771..630399a 100644
--- a/midimonster.h
+++ b/midimonster.h
@@ -4,6 +4,13 @@
#include <stdlib.h>
#include <stdint.h>
#define max(a,b) (((a) > (b)) ? (a) : (b))
+#ifdef DEBUG
+ #define DBGPF(format, ...) fprintf(stderr, (format), __VA_ARGS__)
+ #define DBG(message) fprintf(stderr, "%s", (message))
+#else
+ #define DBGPF(format, ...)
+ #define DBG(message)
+#endif
#define DEFAULT_CFG "monster.cfg"
@@ -150,24 +157,30 @@ instance* mm_instance_find(char* backend, uint64_t ident);
/*
* Provides a pointer to a channel structure, pre-filled with
* the provided instance reference and identifier.
- * Will return previous allocations if the provided fields
- * match.
- * This API is just a convenience function. The array
- * of channels is only used for mapping internally,
- * creating and managing your own channel store is
- * possible.
- * For each channel with a non-NULL impl field, the backend
- * will receive a call to its channel_free function.
+ * The `create` parameter is a boolean flag indicating whether
+ * a channel matching the `ident` parameter should be created if
+ * none exists. If the instance already registered a channel
+ * matching `ident`, a pointer to it is returned.
+ * This API is just a convenience function. The array of channels is
+ * only used for mapping internally, creating and managing your own
+ * channel store is possible.
+ * For each channel with a non-NULL `impl` field registered using
+ * this function, the backend will receive a call to its channel_free
+ * function.
*/
channel* mm_channel(instance* i, uint64_t ident, uint8_t create);
//TODO channel* mm_channel_find()
/*
* Register a file descriptor to be selected on. The backend
* will be notified via the mmbackend_process_fd call.
- * This function may only be called from within the
- * mmbackend_start procedure.
+ * This function may only be called from within the mmbackend_start
+ * procedure.
*/
int mm_manage_fd(int fd, char* backend, int manage, void* impl);
+/*
+ * Notifies the core of a channel event. Used by backends to
+ * inject events gathered from their backing implementation.
+ */
int mm_channel_event(channel* c, channel_value v);
/*
* Query all active instances for a given backend.
diff --git a/monster.cfg b/monster.cfg
index c459262..558478e 100644
--- a/monster.cfg
+++ b/monster.cfg
@@ -22,3 +22,4 @@ dest = learn@8001
[map]
osc1./1/xy:0 <> net1.1+2
osc1./1/xy:1 <> net1.3+4
+osc1./1/fader1 <> net1.20+21