source: roaraudio/include/libroardsp/midi.h @ 6052:d48765b2475e

Last change on this file since 6052:d48765b2475e was 6052:d48765b2475e, checked in by phi, 9 years ago

updated copyright headers

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