-
Notifications
You must be signed in to change notification settings - Fork 0
/
jack.h
86 lines (79 loc) · 1.66 KB
/
jack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* jack.h: interface to jack */
#ifndef KB_JACK_H
#define KB_JACK_H
#include <stdint.h>
enum {
/* valid MIDI data byte 0-127 */
MAX_DATA = (1u << 7u) - 1,
MIN_DATA = 0,
MAX_BANK = (1u << 14u) - 1,
};
enum Controls {
CTRL_BANK_SEL_MSB = 0,
CTRL_BANK_SEL_LSB = 32,
CTRL_ALL_SOUND_OFF = 120,
CTRL_RESET_CONTROLLERS = 121,
CTRL_ALL_NOTES_OFF = 123,
};
/*
* opcodes for keybindings
*
* >=0 values represent MIDI notes to be played
* < 0 values represent operations
*/
typedef enum {
OP_INVALID = -10,
OP_INC_OCTAVE,
OP_DEC_OCTAVE,
OP_INC_VELOCITY,
OP_DEC_VELOCITY,
OP_INC_BANK,
OP_DEC_BANK,
OP_INC_PROG,
OP_DEC_PROG,
OP_PANIC,
OP_C = 0,
OP_CSHARP,
OP_D,
OP_DSHARP,
OP_E,
OP_F,
OP_FSHARP,
OP_G,
OP_GSHARP,
OP_A,
OP_ASHARP,
OP_B,
} opcode_t;
/*
* writes NoteOn midi message to buffer.
* return: 1 on success, 0 on failure.
*/
int write_note_on(char channel, char pitch, char vel);
/*
* writes NoteOff midi message to buffer.
* return: 1 on success, 0 on failure.
*/
int write_note_off(char channel, char pitch, char vel);
/*
* writes control midi message to buffer.
* return: 1 on success, 0 on failure.
*/
int write_control(char channel, char controller, char val);
/*
* writes bank select midi message to buffer.
* return: 1 on success, 0 on failure.
*/
int write_bank_sel(char channel, uint_least16_t val);
/*
* writes prog change message to buffer.
* return: 1 on success, 0 on failure.
*/
int write_prog_change(char channel, char prog);
/* auto connect to any midi input port */
void refresh_ports(void);
/* init jack */
void jack_init(int auto_connect);
/* grace shutdown jack */
void jack_shutdown(void);
#endif