source: roaraudio/roard/include/midi.h @ 2499:3581aa109b03

Last change on this file since 2499:3581aa109b03 was 2499:3581aa109b03, checked in by phi, 15 years ago

we only need those includes in case we have CB

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