source: roaraudio/include/libroardsp/midi.h @ 370:925790633b2a

Last change on this file since 370:925790633b2a was 370:925790633b2a, checked in by phi, 16 years ago

added some BASIC PLAY like functions

File size: 1.7 KB
Line 
1//midi.h:
2
3#ifndef _LIBROARMIDI_H_
4#define _LIBROARMIDI_H_
5
6#include "libroar.h"
7#include <math.h>
8
9#define ROAR_MIDI_NOTE_NONE -1
10
11#define ROAR_MIDI_NOTE_C  26162
12#define ROAR_MIDI_NOTE_Cs 27718
13#define ROAR_MIDI_NOTE_D  29366
14#define ROAR_MIDI_NOTE_Ds 31112
15#define ROAR_MIDI_NOTE_E  32962
16#define ROAR_MIDI_NOTE_F  34922
17#define ROAR_MIDI_NOTE_Fs 36999
18#define ROAR_MIDI_NOTE_G  39199
19#define ROAR_MIDI_NOTE_Gs 41530
20#define ROAR_MIDI_NOTE_A  44000
21#define ROAR_MIDI_NOTE_As 46616
22#define ROAR_MIDI_NOTE_B  49388
23
24#define ROAR_MIDI_MAX_NOTENAME_LEN (1+8)
25
26#define ROAR_MIDI_TYPE_SINE 1
27
28struct roar_midi_len {
29 int mul;
30 int div;
31};
32
33struct roar_note_octave {
34 uint16_t       note;
35 char           name[ROAR_MIDI_MAX_NOTENAME_LEN+1];
36 int            octave;
37 float          freq;
38 struct roar_midi_len len;
39};
40
41
42struct roar_midi_basic_state {
43 struct roar_midi_len    len;
44 struct roar_note_octave note;
45};
46
47char         * roar_midi_note2name   (uint16_t note);
48uint16_t       roar_midi_name2note   (char * note);
49float          roar_midi_note2freq   (uint16_t note);
50
51//int            roar_midi_free_no     (struct roar_note_octave * note);
52
53int            roar_midi_find_octave (char * note);
54int            roar_midi_add_octave  (struct roar_note_octave * note);
55int            roar_midi_notefill    (struct roar_note_octave * note);
56
57int            roar_midi_gen_tone    (struct roar_note_octave * note, int16_t * samples, float t, int rate, int channels, int type, void * opts);
58
59
60int roar_midi_play_note  (struct roar_stream * stream, struct roar_note_octave * note, float len);
61
62int roar_midi_basic_init (struct roar_midi_basic_state * state);
63int roar_midi_basic_play (struct roar_stream * stream, struct roar_midi_basic_state * state, char * notes);
64
65#endif
66
67//ll
Note: See TracBrowser for help on using the repository browser.