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
RevLine 
[169]1//midi.h:
2
[668]3/*
[5961]4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2014
[668]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
[3517]21 *  the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
[668]23 *
24 */
25
[169]26#ifndef _MIDI_H_
27#define _MIDI_H_
28
29#include <roaraudio.h>
30
[2500]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
[2499]38#ifndef ROAR_WITHOUT_DCOMP_CB
[188]39#ifdef __linux__
40#include <sys/ioctl.h>
41#include <linux/kd.h>
42#endif
43
[189]44#define MIDI_CB_NOOVERRIDE 0
45#define MIDI_CB_OVERRIDE   1
[2487]46#endif
[189]47
[1848]48#define MIDI_RATE    31250
49
[1852]50// standard MIDI commands:
[2408]51#define MIDI_TYPE_NOTE_OFF      0x80
52#define MIDI_TYPE_NOTE_ON       0x90
[1852]53#define MIDI_TYPE_PA            0xA0
54#define MIDI_TYPE_CONTROLER     0xB0
55#define MIDI_TYPE_PROGRAM       0xC0
[1864]56#define MIDI_TYPE_MA            0xD0
[1852]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
[1892]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
[1852]76#define MIDI_MES_BUFSIZE        4
[1858]77#define MIDI_READ_SIZE          256 /* this should be big enoth in both cfreq=20..100Hz mode */
[1852]78
79#define MIDI_MFLAG_FREE_DP     (1<<0)
80
[1924]81#define MIDI_INITED_MAIN        0x01
82#define MIDI_INITED_CB          0x02
83#define MIDI_INITED_CLOCK       0x04
84
[5194]85extern struct midi_config {
[1924]86 int init;
87 int inited;
[2487]88
89#ifndef ROAR_WITHOUT_DCOMP_CB
[1924]90 int init_cb;
91 char * console_dev;
[2487]92#endif
[1924]93} midi_config;
94
[1852]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
[5194]109extern struct midi_state_mess {
[1863]110 struct roar_buffer * buf;
111} g_midi_mess;
[1852]112
[2487]113#ifndef ROAR_WITHOUT_DCOMP_CB
[5194]114extern struct midi_state_cb {
[1853]115 int      console;
116 int      stream;
117 uint32_t stoptime;
118 int      playing;
119} g_midi_cb;
[2487]120#endif
[1848]121
[5194]122extern struct midi_clock {
[1850]123 int stream;
124 uint_least32_t bph; // beats per hour
[1852]125 uint_least32_t spt; // samples per tick
126 uint32_t       nt;  // time of next tick
[1850]127} g_midi_clock;
[192]128
[5194]129extern struct midi_mixer {
[2941]130 int stream;
131} g_midi_mixer;
132
[1858]133
134// general midi interface:
[1924]135int midi_init_config(void);
136
[185]137int midi_init (void);
138int midi_free (void);
139
[1841]140int midi_update(void);
[1855]141int midi_reinit(void);
[1841]142
[1858]143// streams:
[1841]144int midi_check_stream  (int id);
145int midi_send_stream   (int id);
146
[1858]147int midi_conv_midi2mes (int id);
148int midi_conv_mes2midi (int id);
149
[2461]150int midi_conv_mes2ssynth(void);
151
[1863]152int midi_new_bufmes    (struct roar_buffer ** buf, struct midi_message ** mes);
[5305]153int midi_add_buf       (int id, struct roar_buffer ** buf);
[1863]154
[1858]155// bridges:
[1848]156int midi_check_bridge  (int id);
157
[1858]158// clock:
[1848]159int midi_clock_init (void);
[1852]160int midi_clock_set_bph (uint_least32_t bph);
161int midi_clock_tick (void);
[1848]162
[185]163// cb = console beep
[2487]164#ifndef ROAR_WITHOUT_DCOMP_CB
[1843]165int midi_cb_init(void);
166int midi_cb_free(void);
[185]167int midi_cb_play(float t, float freq, int override);
[190]168int midi_cb_update (void);
[185]169int midi_cb_start(float freq);
170int midi_cb_stop (void);
[1882]171int midi_cb_readbuf(void);
[2487]172#endif
[185]173
[1848]174// dummys:
175int     midi_vio_set_dummy(int stream);
176
[169]177#endif
178
[2500]179#endif
180
[169]181//ll
Note: See TracBrowser for help on using the repository browser.