diff --git a/cmMidi.c b/cmMidi.c index b3a7dd8..6a375c2 100644 --- a/cmMidi.c +++ b/cmMidi.c @@ -4,16 +4,12 @@ #include "cmMidi.h" -enum -{ - mdStatusDescLabelCharCnt = 5 -}; typedef struct { cmMidiByte_t status; cmMidiByte_t byteCnt; - char label[ mdStatusDescLabelCharCnt+1 ]; + const char* label; } cmMidiStatusDesc; cmMidiStatusDesc _cmMidiStatusDescArray[] = @@ -72,6 +68,16 @@ cmMidiStatusDesc _cmMidiMetaStatusDescArray[] = { kInvalidMetaMdId, kInvalidMidiByte, "ERROR"} }; +cmMidiStatusDesc _cmMidiPedalLabel[] = +{ + { kSustainCtlMdId, 0, "sustn" }, + { kPortamentoCtlMdId, 0, "porta" }, + { kSostenutoCtlMdId, 0, "sostn" }, + { kSoftPedalCtlMdId, 0, "soft" }, + { kLegatoCtlMdId, 0, "legat" }, + { kInvalidMidiByte, kInvalidMidiByte, "ERROR"} +}; + //==================================================================================================== const char* cmMidiStatusToLabel( cmMidiByte_t status ) @@ -102,6 +108,16 @@ const char* cmMidiMetaStatusToLabel( cmMidiByte_t metaStatus ) return _cmMidiMetaStatusDescArray[i].label; } +const char* cmMidiPedalLabel( cmMidiByte_t d0 ) +{ + int i; + for(i=0; _cmMidiPedalLabel[i].status != kInvalidMidiByte; ++i) + if( _cmMidiPedalLabel[i].status == d0 ) + break; + + return _cmMidiPedalLabel[i].label; +} + cmMidiByte_t cmMidiStatusToByteCount( cmMidiByte_t status ) { unsigned i; diff --git a/cmMidi.h b/cmMidi.h index fa1245e..51373d4 100644 --- a/cmMidi.h +++ b/cmMidi.h @@ -68,7 +68,11 @@ extern "C" { kSeqSpecMdId = 0x7f, kInvalidMetaMdId = 0x80, - kSustainCtlMdId = 64 + kSustainCtlMdId = 0x40, + kPortamentoCtlMdId = 0x41, + kSostenutoCtlMdId = 0x42, + kSoftPedalCtlMdId = 0x43, + kLegatoCtlMdId = 0x44 }; @@ -89,8 +93,14 @@ extern "C" { #define cmMidiIsSustainPedalDown( s, d0, d1) ( cmMidiIsSustainPedal(s,d0) && (d1)>=64 ) #define cmMidiIsSustainPedalUp( s, d0, d1) ( cmMidiIsSustainPedal(s,d0) && (d1)<64 ) +#define cmMidiIsPedal( s, d0 ) ( kCtlMdId <= (s) && (s) <= (kCtlMdId + kMidiChCnt) && (d0)>=kSustainCtlMdId && (d0)<=kLegatoCtlMdId ) +#define cmMidiIsPedalDown( s, d0, d1 ) ( cmMidiIsPedal(s,d0) && (d1)>=64 ) +#define cmMidiIsPedalUp( s, d0, d1 ) ( cmMidiIsPedal(s,d0) && (d1)<64 ) + + const char* cmMidiStatusToLabel( cmMidiByte_t status ); const char* cmMidiMetaStatusToLabel( cmMidiByte_t metaStatus ); + const char* cmMidiPedalLabel( cmMidiByte_t d0 ); // Returns kInvalidMidiByte if status is not a valid status byte cmMidiByte_t cmMidiStatusToByteCount( cmMidiByte_t status );