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 | #include <math.h> |
---|
30 | |
---|
31 | #define ROAR_MIDI_NOTE_NONE -1 |
---|
32 | |
---|
33 | #define ROAR_MIDI_NOTE_C 26162 |
---|
34 | #define ROAR_MIDI_NOTE_Cs 27718 |
---|
35 | #define ROAR_MIDI_NOTE_D 29366 |
---|
36 | #define ROAR_MIDI_NOTE_Ds 31112 |
---|
37 | #define ROAR_MIDI_NOTE_E 32962 |
---|
38 | #define ROAR_MIDI_NOTE_F 34922 |
---|
39 | #define ROAR_MIDI_NOTE_Fs 36999 |
---|
40 | #define ROAR_MIDI_NOTE_G 39199 |
---|
41 | #define ROAR_MIDI_NOTE_Gs 41530 |
---|
42 | #define ROAR_MIDI_NOTE_A 44000 |
---|
43 | #define ROAR_MIDI_NOTE_As 46616 |
---|
44 | #define ROAR_MIDI_NOTE_B 49388 |
---|
45 | |
---|
46 | #define ROAR_MIDI_MAX_NOTENAME_LEN (1+8) |
---|
47 | |
---|
48 | #define ROAR_MIDI_TYPE_SINE 1 |
---|
49 | |
---|
50 | struct roar_midi_len { |
---|
51 | int mul; |
---|
52 | int div; |
---|
53 | }; |
---|
54 | |
---|
55 | struct roar_note_octave { |
---|
56 | uint16_t note; |
---|
57 | char name[ROAR_MIDI_MAX_NOTENAME_LEN+1]; |
---|
58 | int octave; |
---|
59 | float freq; |
---|
60 | struct roar_midi_len len; |
---|
61 | }; |
---|
62 | |
---|
63 | |
---|
64 | struct roar_midi_basic_state { |
---|
65 | struct roar_midi_len len; |
---|
66 | struct roar_note_octave note; |
---|
67 | }; |
---|
68 | |
---|
69 | char * roar_midi_note2name (uint16_t note); |
---|
70 | uint16_t roar_midi_name2note (char * note); |
---|
71 | float roar_midi_note2freq (uint16_t note); |
---|
72 | |
---|
73 | //int roar_midi_free_no (struct roar_note_octave * note); |
---|
74 | |
---|
75 | int roar_midi_find_octave (char * note); |
---|
76 | int roar_midi_add_octave (struct roar_note_octave * note); |
---|
77 | int roar_midi_notefill (struct roar_note_octave * note); |
---|
78 | |
---|
79 | int roar_midi_gen_tone (struct roar_note_octave * note, int16_t * samples, float t, int rate, int channels, int type, void * opts); |
---|
80 | |
---|
81 | |
---|
82 | int roar_midi_play_note (struct roar_stream * stream, struct roar_note_octave * note, float len); |
---|
83 | |
---|
84 | int roar_midi_basic_init (struct roar_midi_basic_state * state); |
---|
85 | int roar_midi_basic_play (struct roar_stream * stream, struct roar_midi_basic_state * state, char * notes); |
---|
86 | |
---|
87 | #endif |
---|
88 | |
---|
89 | //ll |
---|