source: roaraudio/include/libroardsp/midi.h @ 1854:0a8a71892f5e

Last change on this file since 1854:0a8a71892f5e was 1854:0a8a71892f5e, checked in by phi, 15 years ago

added basic MIDI Note IDs to lookup table, added very basic search function

File size: 2.7 KB
Line 
1//midi.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - August 2008
5 *
6 *  This file is part of libroardsp 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 *  libroardsp 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 _LIBROARMIDI_H_
26#define _LIBROARMIDI_H_
27
28#include "libroardsp.h"
29
30#ifdef ROAR_HAVE_LIBM
31#include <math.h>
32#endif
33
34#define ROAR_MIDI_NOTE_NONE -1
35
36#define ROAR_MIDI_NOTE_C  26162
37#define ROAR_MIDI_NOTE_Cs 27718
38#define ROAR_MIDI_NOTE_D  29366
39#define ROAR_MIDI_NOTE_Ds 31112
40#define ROAR_MIDI_NOTE_E  32962
41#define ROAR_MIDI_NOTE_F  34922
42#define ROAR_MIDI_NOTE_Fs 36999
43#define ROAR_MIDI_NOTE_G  39199
44#define ROAR_MIDI_NOTE_Gs 41530
45#define ROAR_MIDI_NOTE_A  44000
46#define ROAR_MIDI_NOTE_As 46616
47#define ROAR_MIDI_NOTE_B  49388
48
49#define ROAR_MIDI_MAX_NOTENAME_LEN (1+8)
50
51#define ROAR_MIDI_TYPE_SINE 1
52
53struct roar_midi_len {
54 int mul;
55 int div;
56};
57
58struct roar_note_octave {
59 uint16_t       note;
60 char           name[ROAR_MIDI_MAX_NOTENAME_LEN+1];
61 int            octave;
62 float          freq;
63 struct roar_midi_len len;
64};
65
66
67struct roar_midi_basic_state {
68 struct roar_midi_len    len;
69 struct roar_note_octave note;
70};
71
72char         * roar_midi_note2name   (uint16_t note);
73uint16_t       roar_midi_name2note   (char * note);
74uint16_t       roar_midi_midi2note   (unsigned char midiid);
75float          roar_midi_note2freq   (uint16_t note);
76
77//int            roar_midi_free_no     (struct roar_note_octave * note);
78
79int            roar_midi_find_octave (char * note);
80int            roar_midi_add_octave  (struct roar_note_octave * note);
81int            roar_midi_notefill    (struct roar_note_octave * note);
82
83int            roar_midi_gen_tone    (struct roar_note_octave * note, int16_t * samples, float t, int rate, int channels, int type, void * opts);
84
85
86int roar_midi_play_note  (struct roar_stream * stream, struct roar_note_octave * note, float len);
87
88int roar_midi_basic_init (struct roar_midi_basic_state * state);
89int roar_midi_basic_play (struct roar_stream * stream, struct roar_midi_basic_state * state, char * notes);
90
91#endif
92
93//ll
Note: See TracBrowser for help on using the repository browser.