Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Keyboard Class Reference

Class describing the piano keyboard, holding a collection of keys. More...

#include <keyboard.h>

Public Types

using Keys = std::vector< Key >
 

Public Member Functions

 Keyboard (size_t initialSize)
 Keyboard constructor. More...
 
 ~Keyboard ()
 
size_t size () const
 
void resize (size_t newSize)
 
void changeKeyboardConfiguration (int numberOfKeys, int keyNumberOfA)
 Change keyboard configuration. More...
 
void clearAllKeys ()
 Clear all keys completely. More...
 
void clearComputedPitches ()
 Set all computed pitches to zero. More...
 
void clearTunedPitches ()
 Set all tuned pitches to zero. More...
 
void clearOverpulls ()
 Set all overpull markers to zero. More...
 
const Keyoperator[] (size_t i) const
 
Keyoperator[] (size_t i)
 
const Keyat (size_t i) const
 
Keyat (size_t i)
 
const KeygetKeyPtr (int i) const
 Get pointer to a key with a given number, returning nullptr if the number is out of range (read-only version). More...
 
KeygetKeyPtr (int i)
 Get pointer to a key with a given number, returning nullptr if the number is out of range (read-write version). More...
 
KeysgetKeys ()
 
int getNumberOfKeys () const
 
int getKeyNumberOfA4 () const
 
int & getKeyNumberOfA4 ()
 
int getNumberOfBassKeys () const
 
int & getNumberOfBassKeys ()
 
void setNumberOfBassKeys (int keys)
 
std::string getNoteName (int keynumber) const
 Get the name of the key as a string. More...
 
piano::KeyColor getKeyColor (int keynumber) const
 Get the color of the key (black / white) More...
 

Private Attributes

Keys mKeys
 Vector holding the keys. More...
 
int mKeyNumberOfA4
 Index of the key A4 (440Hz) More...
 
int mNumberOfBassKeys
 Number of keys on bass bridge. More...
 

Detailed Description

Class describing the piano keyboard, holding a collection of keys.

This class describes all data related to the keyboard of the piano. The most important data is a vector of keys. In addition, this class tells us where the key A4 is located and how many of the keys belong to the bass bridge.

Definition at line 39 of file keyboard.h.

Member Typedef Documentation

using Keyboard::Keys = std::vector<Key>

Definition at line 42 of file keyboard.h.

Constructor & Destructor Documentation

Keyboard::Keyboard ( size_t  initialSize)

Keyboard constructor.

Parameters
initialSize: Initial size of the keyboard (standard = 88)

Definition at line 33 of file keyboard.cpp.

Keyboard::~Keyboard ( )
inline

Definition at line 46 of file keyboard.h.

Member Function Documentation

const Key& Keyboard::at ( size_t  i) const
inline

Definition at line 61 of file keyboard.h.

Key& Keyboard::at ( size_t  i)
inline

Definition at line 62 of file keyboard.h.

void Keyboard::changeKeyboardConfiguration ( int  numberOfKeys,
int  keyNumberOfA 
)

Change keyboard configuration.

This function allows the configuration (size and location of A4) to be changed while the application is running. Keys for which data is available are automatically shifted to the new component.

Parameters
numberOfKeys: new number of piano keys (standard 88).
keyNumberOfA: New index of A4 key (standard 48, counting from 0)

Definition at line 73 of file keyboard.cpp.

void Keyboard::clearAllKeys ( )

Clear all keys completely.

Definition at line 45 of file keyboard.cpp.

void Keyboard::clearComputedPitches ( )

Set all computed pitches to zero.

Definition at line 48 of file keyboard.cpp.

void Keyboard::clearOverpulls ( )

Set all overpull markers to zero.

Definition at line 54 of file keyboard.cpp.

void Keyboard::clearTunedPitches ( )

Set all tuned pitches to zero.

Definition at line 51 of file keyboard.cpp.

piano::KeyColor Keyboard::getKeyColor ( int  keynumber) const

Get the color of the key (black / white)

Parameters
keynumber: Number of the key
Returns
Color of the key

Definition at line 160 of file keyboard.cpp.

+ Here is the call graph for this function:

int Keyboard::getKeyNumberOfA4 ( ) const
inline

Definition at line 73 of file keyboard.h.

int& Keyboard::getKeyNumberOfA4 ( )
inline

Definition at line 74 of file keyboard.h.

const Key * Keyboard::getKeyPtr ( int  i) const

Get pointer to a key with a given number, returning nullptr if the number is out of range (read-only version).

Parameters
i: Number of the key
Returns
: Pointer to the key

Definition at line 104 of file keyboard.cpp.

Key * Keyboard::getKeyPtr ( int  i)

Get pointer to a key with a given number, returning nullptr if the number is out of range (read-write version).

Parameters
i: Number of the key
Returns
: Pointer to the key

Definition at line 117 of file keyboard.cpp.

Keys& Keyboard::getKeys ( )
inline

Definition at line 69 of file keyboard.h.

std::string Keyboard::getNoteName ( int  keynumber) const

Get the name of the key as a string.

Parameters
keynumber: Number of the key
Returns
: Name of the corresponding note (American notation).

Definition at line 135 of file keyboard.cpp.

+ Here is the call graph for this function:

int Keyboard::getNumberOfBassKeys ( ) const
inline

Definition at line 75 of file keyboard.h.

int& Keyboard::getNumberOfBassKeys ( )
inline

Definition at line 76 of file keyboard.h.

int Keyboard::getNumberOfKeys ( ) const
inline

Definition at line 72 of file keyboard.h.

+ Here is the call graph for this function:

const Key& Keyboard::operator[] ( size_t  i) const
inline

Definition at line 59 of file keyboard.h.

Key& Keyboard::operator[] ( size_t  i)
inline

Definition at line 60 of file keyboard.h.

void Keyboard::resize ( size_t  newSize)
inline

Definition at line 49 of file keyboard.h.

void Keyboard::setNumberOfBassKeys ( int  keys)
inline

Definition at line 77 of file keyboard.h.

size_t Keyboard::size ( ) const
inline

Definition at line 48 of file keyboard.h.

Member Data Documentation

int Keyboard::mKeyNumberOfA4
private

Index of the key A4 (440Hz)

Definition at line 86 of file keyboard.h.

Keys Keyboard::mKeys
private

Vector holding the keys.

Definition at line 85 of file keyboard.h.

int Keyboard::mNumberOfBassKeys
private

Number of keys on bass bridge.

Definition at line 87 of file keyboard.h.


The documentation for this class was generated from the following files: