source: roaraudio/roard/include/midi.h @ 2500:5e481907a8c0

Last change on this file since 2500:5e481907a8c0 was 2500:5e481907a8c0, checked in by phi, 15 years ago

support to disable MIDI subsystem completly

File size: 4.1 KB
RevLine 
[169]1//midi.h:
2
[668]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
[169]25#ifndef _MIDI_H_
26#define _MIDI_H_
27
28#include <roaraudio.h>
29
[2500]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
[2499]37#ifndef ROAR_WITHOUT_DCOMP_CB
[188]38#ifdef __linux__
39#include <sys/ioctl.h>
40#include <linux/kd.h>
41#endif
42
[189]43#define MIDI_CB_NOOVERRIDE 0
44#define MIDI_CB_OVERRIDE   1
[2487]45#endif
[189]46
[1848]47#define MIDI_RATE    31250
48
[1852]49// standard MIDI commands:
[2408]50#define MIDI_TYPE_NOTE_OFF      0x80
51#define MIDI_TYPE_NOTE_ON       0x90
[1852]52#define MIDI_TYPE_PA            0xA0
53#define MIDI_TYPE_CONTROLER     0xB0
54#define MIDI_TYPE_PROGRAM       0xC0
[1864]55#define MIDI_TYPE_MA            0xD0
[1852]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
[1892]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
[1852]75#define MIDI_MES_BUFSIZE        4
[1858]76#define MIDI_READ_SIZE          256 /* this should be big enoth in both cfreq=20..100Hz mode */
[1852]77
78#define MIDI_MFLAG_FREE_DP     (1<<0)
79
[1924]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;
[2487]87
88#ifndef ROAR_WITHOUT_DCOMP_CB
[1924]89 int init_cb;
90 char * console_dev;
[2487]91#endif
[1924]92} midi_config;
93
[1852]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
[1863]108struct {
109 struct roar_buffer * buf;
110} g_midi_mess;
[1852]111
[2487]112#ifndef ROAR_WITHOUT_DCOMP_CB
[1853]113struct {
114 int      console;
115 int      stream;
116 uint32_t stoptime;
117 int      playing;
118} g_midi_cb;
[2487]119#endif
[1848]120
[1850]121struct {
122 int stream;
123 uint_least32_t bph; // beats per hour
[1852]124 uint_least32_t spt; // samples per tick
125 uint32_t       nt;  // time of next tick
[1850]126} g_midi_clock;
[192]127
[1858]128
129// general midi interface:
[1924]130int midi_init_config(void);
131
[185]132int midi_init (void);
133int midi_free (void);
134
[1841]135int midi_update(void);
[1855]136int midi_reinit(void);
[1841]137
[1858]138// streams:
[1841]139int midi_check_stream  (int id);
140int midi_send_stream   (int id);
141
[1858]142int midi_conv_midi2mes (int id);
143int midi_conv_mes2midi (int id);
144
[2461]145int midi_conv_mes2ssynth(void);
146
[1863]147int midi_new_bufmes    (struct roar_buffer ** buf, struct midi_message ** mes);
[1866]148int midi_add_buf       (int id, struct roar_buffer * buf);
[1863]149
[1858]150// bridges:
[1848]151int midi_check_bridge  (int id);
152
[1858]153// clock:
[1848]154int midi_clock_init (void);
[1852]155int midi_clock_set_bph (uint_least32_t bph);
156int midi_clock_tick (void);
[1848]157
[185]158// cb = console beep
[2487]159#ifndef ROAR_WITHOUT_DCOMP_CB
[1843]160int midi_cb_init(void);
161int midi_cb_free(void);
[185]162int midi_cb_play(float t, float freq, int override);
[190]163int midi_cb_update (void);
[185]164int midi_cb_start(float freq);
165int midi_cb_stop (void);
[1882]166int midi_cb_readbuf(void);
[2487]167#endif
[185]168
[1848]169// dummys:
170int     midi_vio_set_dummy(int stream);
171int     midi_vio_ok(struct roar_vio_calls * vio, ...);
172
[169]173#endif
174
[2500]175#endif
176
[169]177//ll
Note: See TracBrowser for help on using the repository browser.