Changeset 1880:ebb1117d8189 in roaraudio


Ignore:
Timestamp:
05/23/09 19:02:14 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_midi_note_from_midiid()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroardsp/midi.h

    r1854 r1880  
    7777//int            roar_midi_free_no     (struct roar_note_octave * note); 
    7878 
     79int            roar_midi_note_from_midiid(struct roar_note_octave * note, unsigned char midiid); 
     80 
    7981int            roar_midi_find_octave (char * note); 
    8082int            roar_midi_add_octave  (struct roar_note_octave * note); 
  • libroardsp/midi.c

    r1854 r1880  
    8686} 
    8787 
     88int            roar_midi_note_from_midiid(struct roar_note_octave * note, unsigned char midiid) { 
     89 int oct; 
     90 
     91 if ( note == NULL || midiid > 127 ) 
     92  return -1; 
     93 
     94 memset(note, 0, sizeof(struct roar_note_octave)); 
     95 
     96 note->octave = ((int) midiid/12) - 5; 
     97 note->note   = roar_midi_midi2note((midiid % 12) + 60); 
     98 
     99 oct = 1 << abs(note->octave); 
     100 
     101 note->freq = roar_midi_note2freq(note->note); 
     102 
     103 if ( note->octave < 0 ) { 
     104  note->freq /= oct; 
     105 } else { 
     106  note->freq *= oct; 
     107 } 
     108 
     109 return 0; 
     110} 
     111 
    88112int            roar_midi_find_octave (char * note); 
    89113int            roar_midi_add_octave  (struct roar_note_octave * note) { 
Note: See TracChangeset for help on using the changeset viewer.