aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/jack.h
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-11-06 18:50:57 +0100
committercbdev <cb@cbcdn.com>2019-11-06 18:50:57 +0100
commitff587cb77ee4a7e9169affbfefd84547da6fea38 (patch)
treefefa6e701021af25aee8371ede8682d554fd768c /backends/jack.h
parent24e5594c754ec74918848d33d513db69d54aba47 (diff)
downloadmidimonster-ff587cb77ee4a7e9169affbfefd84547da6fea38.tar.gz
midimonster-ff587cb77ee4a7e9169affbfefd84547da6fea38.tar.bz2
midimonster-ff587cb77ee4a7e9169affbfefd84547da6fea38.zip
Implement JACK backend
Diffstat (limited to 'backends/jack.h')
-rw-r--r--backends/jack.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/backends/jack.h b/backends/jack.h
new file mode 100644
index 0000000..dd59cd2
--- /dev/null
+++ b/backends/jack.h
@@ -0,0 +1,76 @@
+#include "midimonster.h"
+#include <jack/jack.h>
+#include <pthread.h>
+
+int init();
+static int mmjack_configure(char* option, char* value);
+static int mmjack_configure_instance(instance* inst, char* option, char* value);
+static instance* mmjack_instance();
+static channel* mmjack_channel(instance* inst, char* spec);
+static int mmjack_set(instance* inst, size_t num, channel** c, channel_value* v);
+static int mmjack_handle(size_t num, managed_fd* fds);
+static int mmjack_start();
+static int mmjack_shutdown();
+
+#define JACK_DEFAULT_CLIENT_NAME "MIDIMonster"
+#define JACK_DEFAULT_SERVER_NAME "default"
+#define JACK_MIDIQUEUE_CHUNK 10
+
+enum /*mmjack_midi_channel_type*/ {
+ midi_none = 0,
+ midi_note = 0x90,
+ midi_cc = 0xB0,
+ midi_pressure = 0xA0,
+ midi_aftertouch = 0xD0,
+ midi_pitchbend = 0xE0
+};
+
+typedef union {
+ struct {
+ uint32_t port;
+ uint8_t pad;
+ uint8_t sub_type;
+ uint8_t sub_channel;
+ uint8_t sub_control;
+ } fields;
+ uint64_t label;
+} mmjack_channel_ident;
+
+typedef enum /*_mmjack_port_type*/ {
+ port_none = 0,
+ port_midi,
+ port_osc,
+ port_cv
+} mmjack_port_type;
+
+typedef struct /*_mmjack_midiqueue_entry*/ {
+ mmjack_channel_ident ident;
+ uint16_t raw;
+} mmjack_midiqueue;
+
+typedef struct /*_mmjack_port_data*/ {
+ char* name;
+ mmjack_port_type type;
+ uint8_t input;
+ jack_port_t* port;
+
+ double max;
+ double min;
+ uint8_t mark;
+ double last;
+ size_t queue_len;
+ size_t queue_alloc;
+ mmjack_midiqueue* queue;
+
+ pthread_mutex_t lock;
+} mmjack_port;
+
+typedef struct /*_jack_instance_data*/ {
+ char* server_name;
+ char* client_name;
+ int fd;
+
+ jack_client_t* client;
+ size_t ports;
+ mmjack_port* port;
+} mmjack_instance_data;