X-Git-Url: https://git.cworth.org/git?p=scherzo;a=blobdiff_plain;f=pitch.h;fp=pitch.h;h=4467aa86a825c239faa6842819c21d85b58fb1e6;hp=657e8fe07f8f291f1a4846c4cf0e596f1f2cdf7d;hb=54d2b1cb13bf52df22c93e58377a00b757644b94;hpb=aae6b7f55870ab7f9cd41f95e22231e66a673aea diff --git a/pitch.h b/pitch.h index 657e8fe..4467aa8 100644 --- a/pitch.h +++ b/pitch.h @@ -54,6 +54,12 @@ typedef uint32_t pitch_t; #define PITCH_NATURAL(literal_name, octave) \ PITCH_LITERAL(literal_name, NATURAL, octave) +/* PITCH_CLASS is useful for comparing pitches while ignoring any octave. */ +#define PITCH_CLASS(name, accidental) PITCH(name, accidental, 0) + +#define PITCH_CLASS_LITERAL(literal_name, literal_accidental) \ + PITCH_LITERAL(literal_name, literal_accidental, 0) + typedef enum pitch_accidental { PITCH_ACCIDENTAL_DOUBLE_FLAT, @@ -78,4 +84,28 @@ typedef enum pitch_name * middle C to the B above middle C). */ +/* Get a string representation of a pitch_t value. + * + * Note: The returned value is static to the pithc_string function and + * may be modified by future calls to pitch_string. So the caller + * should copy the value if needed. */ +const char * +pitch_string (pitch_t pitch); + +/* Return a new pitch, a number of octaves above 'pitch' + * + * Note: Maximum octave value is 8. A pitch with octave 8 will not be + * raised. + */ +pitch_t +pitch_raise_by_octaves (pitch_t pitch, int octaves); + +/* Return a new pitch, a number of octaves below 'pitch' + * + * Note: Minimum octave value is 9. A pitch with octave 8 will not be + * lowered. + */ +pitch_t +pitch_lower_by_octaves (pitch_t pitch, int octaves); + #endif /* PITCH_H */