[203] | 1 | //midi.h: |
---|
| 2 | |
---|
[687] | 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 | |
---|
[203] | 25 | #ifndef _LIBROARMIDI_H_ |
---|
| 26 | #define _LIBROARMIDI_H_ |
---|
| 27 | |
---|
[686] | 28 | #include "libroardsp.h" |
---|
[1105] | 29 | |
---|
| 30 | #ifdef ROAR_HAVE_LIBM |
---|
[367] | 31 | #include <math.h> |
---|
[1105] | 32 | #endif |
---|
[367] | 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 | |
---|
[370] | 53 | struct roar_midi_len { |
---|
| 54 | int mul; |
---|
| 55 | int div; |
---|
| 56 | }; |
---|
| 57 | |
---|
[367] | 58 | struct roar_note_octave { |
---|
| 59 | uint16_t note; |
---|
| 60 | char name[ROAR_MIDI_MAX_NOTENAME_LEN+1]; |
---|
| 61 | int octave; |
---|
| 62 | float freq; |
---|
[370] | 63 | struct roar_midi_len len; |
---|
[367] | 64 | }; |
---|
| 65 | |
---|
| 66 | |
---|
[370] | 67 | struct roar_midi_basic_state { |
---|
| 68 | struct roar_midi_len len; |
---|
| 69 | struct roar_note_octave note; |
---|
| 70 | }; |
---|
| 71 | |
---|
[367] | 72 | char * roar_midi_note2name (uint16_t note); |
---|
| 73 | uint16_t roar_midi_name2note (char * note); |
---|
[1854] | 74 | uint16_t roar_midi_midi2note (unsigned char midiid); |
---|
[367] | 75 | float roar_midi_note2freq (uint16_t note); |
---|
| 76 | |
---|
| 77 | //int roar_midi_free_no (struct roar_note_octave * note); |
---|
| 78 | |
---|
[1880] | 79 | int roar_midi_note_from_midiid(struct roar_note_octave * note, unsigned char midiid); |
---|
| 80 | |
---|
[367] | 81 | int roar_midi_find_octave (char * note); |
---|
| 82 | int roar_midi_add_octave (struct roar_note_octave * note); |
---|
| 83 | int roar_midi_notefill (struct roar_note_octave * note); |
---|
| 84 | |
---|
| 85 | int roar_midi_gen_tone (struct roar_note_octave * note, int16_t * samples, float t, int rate, int channels, int type, void * opts); |
---|
[203] | 86 | |
---|
[370] | 87 | |
---|
| 88 | int roar_midi_play_note (struct roar_stream * stream, struct roar_note_octave * note, float len); |
---|
| 89 | |
---|
| 90 | int roar_midi_basic_init (struct roar_midi_basic_state * state); |
---|
| 91 | int roar_midi_basic_play (struct roar_stream * stream, struct roar_midi_basic_state * state, char * notes); |
---|
| 92 | |
---|
[203] | 93 | #endif |
---|
| 94 | |
---|
| 95 | //ll |
---|