cmMidi.h/c : Added pedal related functions and control codes.

This commit is contained in:
Kevin Larke 2015-03-30 13:06:48 -07:00
parent 60de3ffb15
commit bd5daa08bd
2 changed files with 32 additions and 6 deletions

View File

@ -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;

View File

@ -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 );