Human Pitch to Midi Pitch (uncommenting a comment)
Posted: Mon Aug 06, 2012 12:47 pm
I need to be able to use musical pitch names to represent midi pitch numbers.
Here's a couple of typical examples:
Middle C is typically referred to in shorthand as "C4" (C from the 4th octave on a piano keyboard) and the usual corresponding MIDI pitch representation is the integer 60.
Similarly, human "C#4" is the same-sounding pitch as Midi "61".
In my code, it would be quite convenient to use the shorthand "C#4" interchangeably with the integer 61. Without creating a table of strings and an obligatory function to convert back and forth, is there a simple way to overcome "#" being interpreted as a Cobra comment?
No doubt I'm overthinking this trivial matter and should just have human "C#4" equal Midi "61" equal Cobra "Cs4", which would easily permit constants or enums to be set up. But is there a better way that allows use of the # symbol?
Here's a couple of typical examples:
Middle C is typically referred to in shorthand as "C4" (C from the 4th octave on a piano keyboard) and the usual corresponding MIDI pitch representation is the integer 60.
Similarly, human "C#4" is the same-sounding pitch as Midi "61".
In my code, it would be quite convenient to use the shorthand "C#4" interchangeably with the integer 61. Without creating a table of strings and an obligatory function to convert back and forth, is there a simple way to overcome "#" being interpreted as a Cobra comment?
No doubt I'm overthinking this trivial matter and should just have human "C#4" equal Midi "61" equal Cobra "Cs4", which would easily permit constants or enums to be set up. But is there a better way that allows use of the # symbol?