1 | //midi.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008 |
---|
5 | * |
---|
6 | * This file is part of roard a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | * |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef _MIDI_H_ |
---|
26 | #define _MIDI_H_ |
---|
27 | |
---|
28 | #include <roaraudio.h> |
---|
29 | |
---|
30 | #ifdef __linux__ |
---|
31 | #include <sys/ioctl.h> |
---|
32 | #include <linux/kd.h> |
---|
33 | #endif |
---|
34 | |
---|
35 | #define MIDI_CB_NOOVERRIDE 0 |
---|
36 | #define MIDI_CB_OVERRIDE 1 |
---|
37 | |
---|
38 | #define MIDI_RATE 31250 |
---|
39 | |
---|
40 | // standard MIDI commands: |
---|
41 | #define MIDI_TYPE_NOTE_ON 0x80 |
---|
42 | #define MIDI_TYPE_NOTE_OFF 0x90 |
---|
43 | #define MIDI_TYPE_PA 0xA0 |
---|
44 | #define MIDI_TYPE_CONTROLER 0xB0 |
---|
45 | #define MIDI_TYPE_PROGRAM 0xC0 |
---|
46 | #define MIDI_TYPE_MA 0xD0 |
---|
47 | #define MIDI_TYPE_PB 0xE0 |
---|
48 | #define MIDI_TYPE_SYSEX 0xF0 |
---|
49 | #define MIDI_TYPE_CLOCK_TICK 0xF8 |
---|
50 | #define MIDI_TYPE_CLOCK_START 0xFA |
---|
51 | #define MIDI_TYPE_CLOCK_STOP 0xFC |
---|
52 | |
---|
53 | // RoarAudio MIDI Commands: |
---|
54 | #define MIDI_TYPE_NONE 0x00 |
---|
55 | #define MIDI_TYPE_RAW_PASS 0x10 |
---|
56 | #define MIDI_TYPE_RAW_NOPASS 0x20 |
---|
57 | |
---|
58 | #define MIDI_MES_BUFSIZE 4 |
---|
59 | #define MIDI_READ_SIZE 256 /* this should be big enoth in both cfreq=20..100Hz mode */ |
---|
60 | |
---|
61 | #define MIDI_MFLAG_FREE_DP (1<<0) |
---|
62 | |
---|
63 | struct midi_message { |
---|
64 | unsigned char type; |
---|
65 | unsigned char channel; |
---|
66 | unsigned char flags; |
---|
67 | unsigned char kk; |
---|
68 | unsigned char vv; |
---|
69 | size_t datalen; |
---|
70 | unsigned char * dataptr; |
---|
71 | union { |
---|
72 | unsigned char ldata[MIDI_MES_BUFSIZE]; |
---|
73 | struct roar_note_octave note; |
---|
74 | } d; |
---|
75 | }; |
---|
76 | |
---|
77 | struct { |
---|
78 | struct roar_buffer * buf; |
---|
79 | } g_midi_mess; |
---|
80 | |
---|
81 | struct { |
---|
82 | int console; |
---|
83 | int stream; |
---|
84 | uint32_t stoptime; |
---|
85 | int playing; |
---|
86 | } g_midi_cb; |
---|
87 | |
---|
88 | struct { |
---|
89 | int stream; |
---|
90 | uint_least32_t bph; // beats per hour |
---|
91 | uint_least32_t spt; // samples per tick |
---|
92 | uint32_t nt; // time of next tick |
---|
93 | } g_midi_clock; |
---|
94 | |
---|
95 | |
---|
96 | // general midi interface: |
---|
97 | int midi_init (void); |
---|
98 | int midi_free (void); |
---|
99 | |
---|
100 | int midi_update(void); |
---|
101 | int midi_reinit(void); |
---|
102 | |
---|
103 | // streams: |
---|
104 | int midi_check_stream (int id); |
---|
105 | int midi_send_stream (int id); |
---|
106 | |
---|
107 | int midi_conv_midi2mes (int id); |
---|
108 | int midi_conv_mes2midi (int id); |
---|
109 | |
---|
110 | int midi_new_bufmes (struct roar_buffer ** buf, struct midi_message ** mes); |
---|
111 | |
---|
112 | // bridges: |
---|
113 | int midi_check_bridge (int id); |
---|
114 | |
---|
115 | // clock: |
---|
116 | int midi_clock_init (void); |
---|
117 | int midi_clock_set_bph (uint_least32_t bph); |
---|
118 | int midi_clock_tick (void); |
---|
119 | |
---|
120 | // cb = console beep |
---|
121 | int midi_cb_init(void); |
---|
122 | int midi_cb_free(void); |
---|
123 | int midi_cb_play(float t, float freq, int override); |
---|
124 | int midi_cb_update (void); |
---|
125 | int midi_cb_start(float freq); |
---|
126 | int midi_cb_stop (void); |
---|
127 | |
---|
128 | // dummys: |
---|
129 | int midi_vio_set_dummy(int stream); |
---|
130 | int midi_vio_ok(struct roar_vio_calls * vio, ...); |
---|
131 | |
---|
132 | #endif |
---|
133 | |
---|
134 | //ll |
---|