source: roaraudio/roard/include/midi.h @ 5961:06e7fd9e4c25

Last change on this file since 5961:06e7fd9e4c25 was 5961:06e7fd9e4c25, checked in by phi, 10 years ago

Updates of copyright and license headers

File size: 4.2 KB
Line 
1//midi.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2014
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, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#ifndef _MIDI_H_
27#define _MIDI_H_
28
29#include <roaraudio.h>
30
31// CB has MIDI as dep
32#if defined(ROAR_WITHOUT_DCOMP_MIDI) && !defined(ROAR_WITHOUT_DCOMP_CB)
33#define ROAR_WITHOUT_DCOMP_CB
34#endif
35
36#ifndef ROAR_WITHOUT_DCOMP_MIDI
37
38#ifndef ROAR_WITHOUT_DCOMP_CB
39#ifdef __linux__
40#include <sys/ioctl.h>
41#include <linux/kd.h>
42#endif
43
44#define MIDI_CB_NOOVERRIDE 0
45#define MIDI_CB_OVERRIDE   1
46#endif
47
48#define MIDI_RATE    31250
49
50// standard MIDI commands:
51#define MIDI_TYPE_NOTE_OFF      0x80
52#define MIDI_TYPE_NOTE_ON       0x90
53#define MIDI_TYPE_PA            0xA0
54#define MIDI_TYPE_CONTROLER     0xB0
55#define MIDI_TYPE_PROGRAM       0xC0
56#define MIDI_TYPE_MA            0xD0
57#define MIDI_TYPE_PB            0xE0
58#define MIDI_TYPE_SYSEX         0xF0
59#define MIDI_TYPE_CLOCK_TICK    0xF8
60#define MIDI_TYPE_CLOCK_START   0xFA
61#define MIDI_TYPE_CLOCK_STOP    0xFC
62
63// RoarAudio MIDI Commands:
64#define MIDI_TYPE_NONE          0x00
65#define MIDI_TYPE_RAW_PASS      0x10
66#define MIDI_TYPE_RAW_NOPASS    0x20
67
68// controller events:
69#define MIDI_CCE_MAIN_VOL        7
70#define MIDI_CCE_BALANCE         8
71#define MIDI_CCE_PANORAMA       10
72#define MIDI_CCE_LOCAL_CONTR   122
73#define MIDI_CCE_ALL_NOTE_OFF  123
74
75
76#define MIDI_MES_BUFSIZE        4
77#define MIDI_READ_SIZE          256 /* this should be big enoth in both cfreq=20..100Hz mode */
78
79#define MIDI_MFLAG_FREE_DP     (1<<0)
80
81#define MIDI_INITED_MAIN        0x01
82#define MIDI_INITED_CB          0x02
83#define MIDI_INITED_CLOCK       0x04
84
85extern struct midi_config {
86 int init;
87 int inited;
88
89#ifndef ROAR_WITHOUT_DCOMP_CB
90 int init_cb;
91 char * console_dev;
92#endif
93} midi_config;
94
95struct midi_message {
96 unsigned char   type;
97 unsigned char   channel;
98 unsigned char   flags;
99 unsigned char   kk;
100 unsigned char   vv;
101 size_t          datalen;
102 unsigned char * dataptr;
103 union {
104  unsigned char           ldata[MIDI_MES_BUFSIZE];
105  struct roar_note_octave note;
106 }               d;
107};
108
109extern struct midi_state_mess {
110 struct roar_buffer * buf;
111} g_midi_mess;
112
113#ifndef ROAR_WITHOUT_DCOMP_CB
114extern struct midi_state_cb {
115 int      console;
116 int      stream;
117 uint32_t stoptime;
118 int      playing;
119} g_midi_cb;
120#endif
121
122extern struct midi_clock {
123 int stream;
124 uint_least32_t bph; // beats per hour
125 uint_least32_t spt; // samples per tick
126 uint32_t       nt;  // time of next tick
127} g_midi_clock;
128
129extern struct midi_mixer {
130 int stream;
131} g_midi_mixer;
132
133
134// general midi interface:
135int midi_init_config(void);
136
137int midi_init (void);
138int midi_free (void);
139
140int midi_update(void);
141int midi_reinit(void);
142
143// streams:
144int midi_check_stream  (int id);
145int midi_send_stream   (int id);
146
147int midi_conv_midi2mes (int id);
148int midi_conv_mes2midi (int id);
149
150int midi_conv_mes2ssynth(void);
151
152int midi_new_bufmes    (struct roar_buffer ** buf, struct midi_message ** mes);
153int midi_add_buf       (int id, struct roar_buffer ** buf);
154
155// bridges:
156int midi_check_bridge  (int id);
157
158// clock:
159int midi_clock_init (void);
160int midi_clock_set_bph (uint_least32_t bph);
161int midi_clock_tick (void);
162
163// cb = console beep
164#ifndef ROAR_WITHOUT_DCOMP_CB
165int midi_cb_init(void);
166int midi_cb_free(void);
167int midi_cb_play(float t, float freq, int override);
168int midi_cb_update (void);
169int midi_cb_start(float freq);
170int midi_cb_stop (void);
171int midi_cb_readbuf(void);
172#endif
173
174// dummys:
175int     midi_vio_set_dummy(int stream);
176
177#endif
178
179#endif
180
181//ll
Note: See TracBrowser for help on using the repository browser.