source: roaraudio/roard/include/midi.h @ 3516:2becb65c23b6

Last change on this file since 3516:2becb65c23b6 was 2941:e54be79a2eb2, checked in by phi, 15 years ago

added mixer for MIDI subsystem

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