|
@@ -210,18 +210,11 @@ const char* cmMidiToSciPitch( cmMidiByte_t pitch, char* label, unsigned labe
|
210
|
210
|
}
|
211
|
211
|
|
212
|
212
|
|
213
|
|
-cmMidiByte_t cmSciPitchToMidi( const char* sciPitchStr )
|
|
213
|
+cmMidiByte_t cmSciPitchToMidiPitch( cmChar_t pitch, int acc, int octave )
|
214
|
214
|
{
|
215
|
|
- const char* cp = sciPitchStr;
|
216
|
|
- bool sharpFl = false;
|
217
|
|
- bool flatFl = false;
|
218
|
|
- int octave;
|
219
|
|
- int idx = -1;
|
220
|
|
-
|
221
|
|
- if( sciPitchStr==NULL || strlen(sciPitchStr) > 5 )
|
222
|
|
- return kInvalidMidiPitch;
|
223
|
|
-
|
224
|
|
- switch(tolower(*cp))
|
|
215
|
+ int idx = -1;
|
|
216
|
+
|
|
217
|
+ switch(tolower(pitch))
|
225
|
218
|
{
|
226
|
219
|
case 'a': idx = 9; break;
|
227
|
220
|
case 'b': idx = 11; break;
|
|
@@ -234,6 +227,27 @@ cmMidiByte_t cmSciPitchToMidi( const char* sciPitchStr )
|
234
|
227
|
return kInvalidMidiPitch;
|
235
|
228
|
}
|
236
|
229
|
|
|
230
|
+ unsigned rv = (octave*12) + idx + acc + 12;
|
|
231
|
+
|
|
232
|
+ if( rv <= 127 )
|
|
233
|
+ return rv;
|
|
234
|
+
|
|
235
|
+ return kInvalidMidiPitch;
|
|
236
|
+
|
|
237
|
+}
|
|
238
|
+
|
|
239
|
+cmMidiByte_t cmSciPitchToMidi( const char* sciPitchStr )
|
|
240
|
+{
|
|
241
|
+ const char* cp = sciPitchStr;
|
|
242
|
+ bool sharpFl = false;
|
|
243
|
+ bool flatFl = false;
|
|
244
|
+ int octave;
|
|
245
|
+ int acc = 0;
|
|
246
|
+
|
|
247
|
+ if( sciPitchStr==NULL || strlen(sciPitchStr) > 5 )
|
|
248
|
+ return kInvalidMidiPitch;
|
|
249
|
+
|
|
250
|
+ // skip over leading letter
|
237
|
251
|
++cp;
|
238
|
252
|
|
239
|
253
|
if( !(*cp) )
|
|
@@ -241,10 +255,10 @@ cmMidiByte_t cmSciPitchToMidi( const char* sciPitchStr )
|
241
|
255
|
|
242
|
256
|
|
243
|
257
|
if((sharpFl = *cp=='#') == true )
|
244
|
|
- ++idx;
|
|
258
|
+ acc = 1;
|
245
|
259
|
else
|
246
|
260
|
if((flatFl = *cp=='b') == true )
|
247
|
|
- --idx;
|
|
261
|
+ acc = -1;
|
248
|
262
|
|
249
|
263
|
if( sharpFl || flatFl )
|
250
|
264
|
{
|
|
@@ -259,11 +273,7 @@ cmMidiByte_t cmSciPitchToMidi( const char* sciPitchStr )
|
259
|
273
|
|
260
|
274
|
octave = atoi(cp);
|
261
|
275
|
|
262
|
|
- unsigned rv = (octave*12) + idx + 12;
|
263
|
|
-
|
264
|
|
- if( rv <= 127 )
|
265
|
|
- return rv;
|
266
|
276
|
|
267
|
|
- return kInvalidMidiPitch;
|
|
277
|
+ return cmSciPitchToMidiPitch( *sciPitchStr, acc, octave );
|
268
|
278
|
|
269
|
279
|
}
|