forked from polluxsynth/xtor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmidi.h
72 lines (56 loc) · 2.39 KB
/
midi.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
/****************************************************************************
* xtor - GTK based editor for MIDI synthesizers
*
* midi.h - MIDI subsystem for xtor.
*
* Copyright (C) 2014 Ricard Wanderlof <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/
#ifndef _MIDI_H_
#define _MIDI_H_
#include <poll.h>
/* Logical port numbers */
enum port_no { SYNTH_PORT = 0, CTRLR_PORT, MAX_PORTS };
/* Well-known MIDI constants */
#define SYSEX 240
#define EOX 247
/* Convert two byte MIDI data (7 bits per bytes) to single int */
#define MIDI_2BYTE(v1, v2) ((((int)(v1)) << 7) | (v2))
/* Structure for exporting poll fd's from MIDI handler to main loop */
struct polls
{
int npfd;
struct pollfd pollfds[];
};
/* Sysex receiver type */
typedef void (*midi_sysex_receiver)(void *buf, int len);
/* Control change receiver type */
typedef void (*midi_cc_receiver)(int chan, int controller_no, int value);
/* Initialize ALSA sequencer interface, and create MIDI port */
struct polls *midi_init_alsa(void);
/* Send sysex buffer (buffer must contain complete sysex msg w/ SYSEX & EOX) */
int midi_send_sysex(int port, void *buf, int buflen);
/* Process any potential incoming MIDI data */
void midi_input(void);
/* Make bidirectional MIDI connection to specified remote device */
int midi_connect(int port, const char *remote_device);
/* Register sysex receiver */
void midi_register_sysex(int port, int sysex_id, midi_sysex_receiver receiver,
int max_len);
/* Register sysex receiver */
void midi_register_cc(int port, midi_cc_receiver receiver);
#endif /* _MIDI_H_ */
/************************** End of file midi.h *****************************/