|
|
@@ -1,6 +1,10 @@ |
|
|
|
#include "midi-utils.h" |
|
|
|
|
|
|
|
#if !defined _WIN32 |
|
|
|
/** |
|
|
|
* Converts a string to lowercase. |
|
|
|
* @param dest - The string to convert. |
|
|
|
*/ |
|
|
|
void _strlwr(char* dest) { |
|
|
|
for (unsigned int i = 0; i < strlen(dest); i += 1) { |
|
|
|
if ('A' <= dest[i] && dest[i] <= 'Z') { |
|
|
@@ -10,6 +14,13 @@ void _strlwr(char* dest) { |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
/** |
|
|
|
* Gets the name of a MIDI note value. |
|
|
|
* @param midi_note - The MIDI note value. |
|
|
|
* @note Valid values are from 0-127. |
|
|
|
* @return The MIDI note name. |
|
|
|
* @see MIDI_GetNoteFromName() |
|
|
|
*/ |
|
|
|
char* MIDI_GetNoteName(unsigned char midi_note) { |
|
|
|
static const char* pitch_names[] = { |
|
|
|
"C", |
|
|
@@ -33,7 +44,17 @@ char* MIDI_GetNoteName(unsigned char midi_note) { |
|
|
|
return note_name; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Gets the note value from a MIDI note name |
|
|
|
* @param name - The MIDI note name. |
|
|
|
* @return The MIDI note value, or 255 if an invalid name is passed. |
|
|
|
* @see MIDI_GetNoteName() |
|
|
|
*/ |
|
|
|
unsigned char MIDI_GetNoteFromName(const char* name) { |
|
|
|
if (!name) { |
|
|
|
return 255u; |
|
|
|
} |
|
|
|
|
|
|
|
char name_copy[8]; |
|
|
|
strcpy(name_copy, name); |
|
|
|
_strlwr(name_copy); |
|
|
|