1 /* scherzo - Music notation training
3 * pitch.c - Common structures and functions for pitches, etc.
5 * Copyright © 2013 Carl Worth
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see http://www.gnu.org/licenses/ .
24 pitch_string (pitch_t pitch)
26 static char double_flat[] = "X𝄫";
27 static char flat[] = "X♭";
28 static char natural[] = "X";
29 static char sharp[] = "X♯";
30 static char double_sharp[] = "X𝄪";
33 switch (PITCH_ACCIDENTAL (pitch)) {
34 case PITCH_ACCIDENTAL_DOUBLE_FLAT:
37 case PITCH_ACCIDENTAL_FLAT:
40 case PITCH_ACCIDENTAL_NATURAL:
43 case PITCH_ACCIDENTAL_SHARP:
46 case PITCH_ACCIDENTAL_DOUBLE_SHARP:
51 switch (PITCH_NAME (pitch)) {
79 pitch_raise_by_octaves (pitch_t pitch, int octaves)
81 int new_octave = PITCH_OCTAVE (pitch) + octaves;
86 return PITCH (PITCH_NAME (pitch), PITCH_ACCIDENTAL (pitch), new_octave);
90 pitch_lower_by_octaves (pitch_t pitch, int octaves)
92 int new_octave = PITCH_OCTAVE (pitch) - octaves;
97 return PITCH (PITCH_NAME (pitch), PITCH_ACCIDENTAL (pitch), new_octave);