Browse Source

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

master
Kevin Larke 9 years ago
parent
commit
bd5daa08bd
2 changed files with 32 additions and 6 deletions
  1. 21
    5
      cmMidi.c
  2. 11
    1
      cmMidi.h

+ 21
- 5
cmMidi.c View File

4
 #include "cmMidi.h"
4
 #include "cmMidi.h"
5
 
5
 
6
 
6
 
7
-enum
8
-{
9
-  mdStatusDescLabelCharCnt = 5
10
-};
11
 
7
 
12
 typedef struct
8
 typedef struct
13
 {
9
 {
14
   cmMidiByte_t   status;
10
   cmMidiByte_t   status;
15
   cmMidiByte_t  byteCnt;
11
   cmMidiByte_t  byteCnt;
16
-  char     label[ mdStatusDescLabelCharCnt+1 ];
12
+  const char*     label;
17
 } cmMidiStatusDesc;
13
 } cmMidiStatusDesc;
18
 
14
 
19
 cmMidiStatusDesc _cmMidiStatusDescArray[] =
15
 cmMidiStatusDesc _cmMidiStatusDescArray[] =
72
   { kInvalidMetaMdId, kInvalidMidiByte, "ERROR"}
68
   { kInvalidMetaMdId, kInvalidMidiByte, "ERROR"}
73
 };
69
 };
74
 
70
 
71
+cmMidiStatusDesc _cmMidiPedalLabel[] = 
72
+{
73
+  { kSustainCtlMdId,    0, "sustn" },
74
+  { kPortamentoCtlMdId, 0, "porta" },
75
+  { kSostenutoCtlMdId,  0, "sostn" },
76
+  { kSoftPedalCtlMdId,  0, "soft"  },
77
+  { kLegatoCtlMdId,     0, "legat" },
78
+  { kInvalidMidiByte, kInvalidMidiByte, "ERROR"}
79
+};
80
+
75
 //====================================================================================================
81
 //====================================================================================================
76
 
82
 
77
 const char* cmMidiStatusToLabel( cmMidiByte_t status )
83
 const char* cmMidiStatusToLabel( cmMidiByte_t status )
102
   return _cmMidiMetaStatusDescArray[i].label; 
108
   return _cmMidiMetaStatusDescArray[i].label; 
103
 }
109
 }
104
 
110
 
111
+const char* cmMidiPedalLabel( cmMidiByte_t d0 )
112
+{
113
+  int i;
114
+  for(i=0; _cmMidiPedalLabel[i].status != kInvalidMidiByte; ++i)
115
+    if( _cmMidiPedalLabel[i].status == d0 )
116
+      break;
117
+
118
+  return _cmMidiPedalLabel[i].label;
119
+}
120
+
105
 cmMidiByte_t cmMidiStatusToByteCount( cmMidiByte_t status )
121
 cmMidiByte_t cmMidiStatusToByteCount( cmMidiByte_t status )
106
 {
122
 {
107
   unsigned i;
123
   unsigned i;

+ 11
- 1
cmMidi.h View File

68
     kSeqSpecMdId     = 0x7f,
68
     kSeqSpecMdId     = 0x7f,
69
     kInvalidMetaMdId = 0x80,
69
     kInvalidMetaMdId = 0x80,
70
 
70
 
71
-    kSustainCtlMdId = 64
71
+    kSustainCtlMdId    = 0x40,
72
+    kPortamentoCtlMdId = 0x41,
73
+    kSostenutoCtlMdId  = 0x42,
74
+    kSoftPedalCtlMdId  = 0x43,
75
+    kLegatoCtlMdId     = 0x44
72
   
76
   
73
   };
77
   };
74
 
78
 
89
 #define cmMidiIsSustainPedalDown( s, d0, d1) ( cmMidiIsSustainPedal(s,d0) && (d1)>=64 )
93
 #define cmMidiIsSustainPedalDown( s, d0, d1) ( cmMidiIsSustainPedal(s,d0) && (d1)>=64 )
90
 #define cmMidiIsSustainPedalUp(   s, d0, d1) ( cmMidiIsSustainPedal(s,d0) && (d1)<64 )
94
 #define cmMidiIsSustainPedalUp(   s, d0, d1) ( cmMidiIsSustainPedal(s,d0) && (d1)<64 )
91
 
95
 
96
+#define cmMidiIsPedal(     s, d0 )      ( kCtlMdId <= (s) && (s) <= (kCtlMdId + kMidiChCnt) && (d0)>=kSustainCtlMdId && (d0)<=kLegatoCtlMdId )
97
+#define cmMidiIsPedalDown( s, d0, d1 )  ( cmMidiIsPedal(s,d0) && (d1)>=64 )
98
+#define cmMidiIsPedalUp(   s, d0, d1 )  ( cmMidiIsPedal(s,d0) && (d1)<64  )
99
+
100
+
92
   const char*   cmMidiStatusToLabel(     cmMidiByte_t status );
101
   const char*   cmMidiStatusToLabel(     cmMidiByte_t status );
93
   const char*   cmMidiMetaStatusToLabel( cmMidiByte_t metaStatus );
102
   const char*   cmMidiMetaStatusToLabel( cmMidiByte_t metaStatus );
103
+  const char*   cmMidiPedalLabel(        cmMidiByte_t d0 );
94
 
104
 
95
   // Returns kInvalidMidiByte if status is not a valid status byte
105
   // Returns kInvalidMidiByte if status is not a valid status byte
96
   cmMidiByte_t  cmMidiStatusToByteCount( cmMidiByte_t status );
106
   cmMidiByte_t  cmMidiStatusToByteCount( cmMidiByte_t status );

Loading…
Cancel
Save