35 mKeyNumberOfA4(
Piano::DEFAULT_KEY_NUMBER_OF_A),
36 mNumberOfBassKeys(
Piano::DEFAULT_KEYS_ON_BASS_BRIDGE)
46 {
for (
auto &key :
mKeys) key.clear(); }
49 {
for (
auto &key :
mKeys) key.setComputedFrequency(0); }
52 {
for (
auto &key :
mKeys) key.setTunedFrequency(0); }
55 {
for (
auto &key :
mKeys) key.setOverpull(0); }
77 mKeys.resize(numberOfKeys);
80 for (
int toIndex = 0; toIndex < static_cast<int>(
mKeys.size()); ++toIndex)
83 if (fromIndex >= 0 && fromIndex < static_cast<int>(keyCopy.size()))
85 mKeys[toIndex] = keyCopy[fromIndex];
106 if (i < 0 || i >= static_cast<int>(
mKeys.size())) {
return nullptr;}
119 if (i < 0 || i >= static_cast<int>(
mKeys.size())) {
return nullptr;}
137 const int K =
size();
140 if (keynumber < 0 || keynumber >+ K)
return "--";
142 int octave = (keynumber - Ckey + 120) / 12 - 6;
143 int index = (keynumber - Ckey + 120) % 12;
144 const std::string names[12]={
"C",
"C#",
"D",
"D#",
"E",
"F",
"F#",
"G",
"G#",
"A",
"A#",
"B"};
145 char octchar = (char)(
'0' + octave);
146 return names[index] + octchar;
165 {White, Black, White, Black, White, White, Black, White, Black, White, Black, White};
Keys mKeys
Vector holding the keys.
void clearOverpulls()
Set all overpull markers to zero.
void changeKeyboardConfiguration(int numberOfKeys, int keyNumberOfA)
Change keyboard configuration.
Class describing a single piano key.
const Key * getKeyPtr(int i) const
Get pointer to a key with a given number, returning nullptr if the number is out of range (read-only ...
KeyColor
The KeyColor enum.
void clearComputedPitches()
Set all computed pitches to zero.
void clearTunedPitches()
Set all tuned pitches to zero.
std::string getNoteName(int keynumber) const
Get the name of the key as a string.
void clearAllKeys()
Clear all keys completely.
Keyboard(size_t initialSize)
Keyboard constructor.
int getKeyNumberOfA4() const
piano::KeyColor getKeyColor(int keynumber) const
Get the color of the key (black / white)
int mKeyNumberOfA4
Index of the key A4 (440Hz)