From d841f9243c97c1d6fb61946b780c8959897af69b Mon Sep 17 00:00:00 2001 From: cbdev Date: Thu, 1 Jun 2017 01:30:49 +0200 Subject: Sample config and basic headers --- .gitignore | 3 +++ makefile | 7 +++++++ midimonster.c | 22 ++++++++++++++++++++++ midimonster.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ monster.cfg | 26 ++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 .gitignore create mode 100644 makefile create mode 100644 midimonster.c create mode 100644 midimonster.h create mode 100644 monster.cfg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..36d8a83 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +midimonster +*.swp +*.o diff --git a/makefile b/makefile new file mode 100644 index 0000000..81ab1d3 --- /dev/null +++ b/makefile @@ -0,0 +1,7 @@ +LDLIBS = -lasound +CFLAGS = -g -Wall + +all: midimonster + +clean: + $(RM) midimonster diff --git a/midimonster.c b/midimonster.c new file mode 100644 index 0000000..58166d6 --- /dev/null +++ b/midimonster.c @@ -0,0 +1,22 @@ +#include "midimonster.h" + +int usage(char* fn){ + fprintf(stderr, "MIDIMonster v0.1\n"); + fprintf(stderr, "Usage:\n"); + fprintf(stderr, "\t%s \n", fn); + return EXIT_FAILURE; +} + +int main(int argc, char** argv){ + char* cfg_file = DEFAULT_CFG; + if(argc > 1){ + cfg_file = argv[1]; + } + + //initialize backends + //read config + //wait for events + //free all data + + return EXIT_SUCCESS; +} diff --git a/midimonster.h b/midimonster.h new file mode 100644 index 0000000..59c97eb --- /dev/null +++ b/midimonster.h @@ -0,0 +1,57 @@ +#include +#include +#include + +#define DEFAULT_CFG "monster.cfg" + +struct _channel_value; +struct _backend_channel; +struct _backend_instance; + +typedef int (*mmbackend_handle_event)(struct _backend_channel* c, struct _channel_value v); +typedef struct _backend_channel* (*mmbackend_parse_channel)(char* spec); +typedef int (*mmbackend_configure)(char* option, char* value); +typedef struct _backend_instance* (*mmbackend_create_instance)(); +typedef int (*mmbackend_configure_instance)(char* option, char* value); +typedef int (*mmbackend_process_fd)(int fd, void** impl); +typedef int (*mmbackend_shutdown)(); + +typedef struct _channel_value { + double raw_double; + uint64_t raw_u64; + double normalised; +} channel_value; + +typedef struct /*_mm_backend*/ { + char* name; + mmbackend_configure conf; + mmbackend_create_instance create; + mmbackend_configure_instance conf_instance; + mmbackend_parse_channel channel; + mmbackend_handle_event handle; + mmbackend_process_fd process; + mmbackend_shutdown shutdown; +} backend; + +typedef struct _backend_instance { + backend* backend; + size_t ident; + void* impl; + char* name; +} instance; + +typedef struct _backend_channel { + instance* instance; + size_t ident; + void* impl; +} channel; + +typedef struct /*_mm_managed_fd*/ { + int fd; + backend* backend; + void* impl; +} managed_fd; + +backend* mm_backend_register(backend b); +int mm_manage_fd(int fd, backend* b, int manage, void* impl); +int mm_channel_event(channel* c, channel_value v); diff --git a/monster.cfg b/monster.cfg new file mode 100644 index 0000000..6391d40 --- /dev/null +++ b/monster.cfg @@ -0,0 +1,26 @@ +[backend midi] +name = MIDIMonster + +[backend artnet] + +[backend osc] + +[midi indisc] +name = MIDIMonster Input 1 +mode = input,output,create + +[midi lc1] +device = 20:0 +mode = input,output + +[midi xlate] +name = Translation Output 1 +mode = input,output,create + +[artnet net1] +mode = input,output +net = 0 +uni = 1 + +[map] + -- cgit v1.2.3