Changeset 370:925790633b2a in roaraudio
- Timestamp:
- 08/03/08 14:49:05 (16 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroardsp/midi.h
r367 r370 26 26 #define ROAR_MIDI_TYPE_SINE 1 27 27 28 struct roar_midi_len { 29 int mul; 30 int div; 31 }; 32 28 33 struct roar_note_octave { 29 34 uint16_t note; … … 31 36 int octave; 32 37 float freq; 33 int len_mul; 34 int len_div; 38 struct roar_midi_len len; 35 39 }; 36 40 41 42 struct roar_midi_basic_state { 43 struct roar_midi_len len; 44 struct roar_note_octave note; 45 }; 37 46 38 47 char * roar_midi_note2name (uint16_t note); … … 48 57 int roar_midi_gen_tone (struct roar_note_octave * note, int16_t * samples, float t, int rate, int channels, int type, void * opts); 49 58 59 60 int roar_midi_play_note (struct roar_stream * stream, struct roar_note_octave * note, float len); 61 62 int roar_midi_basic_init (struct roar_midi_basic_state * state); 63 int roar_midi_basic_play (struct roar_stream * stream, struct roar_midi_basic_state * state, char * notes); 64 50 65 #endif 51 66 -
libroardsp/midi.c
r369 r370 117 117 } 118 118 119 120 int roar_midi_play_note (struct roar_stream * stream, struct roar_note_octave * note, float len) { 121 return -1; 122 } 123 124 int roar_midi_basic_init (struct roar_midi_basic_state * state) { 125 if (!state) 126 return -1; 127 128 state->len.mul = 1; 129 state->len.div = 60; 130 131 state->note.note = ROAR_MIDI_NOTE_NONE; 132 state->note.octave = 0; 133 134 return 0; 135 } 136 137 int roar_midi_basic_play (struct roar_stream * stream, struct roar_midi_basic_state * state, char * notes) { 138 struct roar_midi_basic_state is; 139 char cn[ROAR_MIDI_MAX_NOTENAME_LEN+1] = {0}; 140 int i; 141 int have = 0; 142 struct roar_note_octave * n; 143 144 if ( !notes ) 145 return -1; 146 147 if ( state == NULL ) { 148 state = &is; 149 roar_midi_basic_init(state); 150 } 151 152 n = &(state->note); 153 154 for (; *notes != 0; notes++) { 155 if ( *notes == '>' ) { 156 n->octave++; 157 } else if ( *notes == '<' ) { 158 n->octave--; 159 } else if ( *notes != ' ' ) { 160 have++; 161 } 162 163 if (have) { 164 roar_midi_play_note(stream, n, 60 * state->len.mul / state->len.div); 165 have = 0; 166 } 167 } 168 169 return 0; 170 } 171 119 172 //ll
Note: See TracChangeset
for help on using the changeset viewer.