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
pitchraise::PitchRaise Class Reference

Basic class to show how to implement own algorithms. More...

#include <pitchraise.h>

+ Inheritance diagram for pitchraise::PitchRaise:
+ Collaboration diagram for pitchraise::PitchRaise:

Public Member Functions

 PitchRaise (const Piano &piano, const AlgorithmFactoryDescription &description)
 Constructor of the pitch-raise algorithm. More...
 
- Public Member Functions inherited from Algorithm
 Algorithm (const Piano &piano, const AlgorithmFactoryDescription &desciption)
 
virtual ~Algorithm ()
 
virtual void workerFunction () overridefinal
 Virtual worker function, executed within the new thread. More...
 
- Public Member Functions inherited from SimpleThreadHandler
 SimpleThreadHandler ()
 Constructor. More...
 
virtual ~SimpleThreadHandler ()
 virtual destructor calls stop More...
 
virtual void start ()
 Start the thread. More...
 
virtual void stop ()
 Stop the thread. More...
 

Protected Member Functions

virtual void algorithmWorkerFunction () overridefinal
 PitchRaise::algorithmWorkerFunction. More...
 
- Protected Member Functions inherited from Algorithm
void updateTuningCurve (int keynumber, double frequency)
 
bool terminateThread ()
 
void showCalculationProgress (double fraction)
 Transmit the current percentage of progress to the messaging system. More...
 
void showCalculationProgress (const Key &key, double start=0, double range=1)
 Transmit the current percentage of progress to the messaging system. More...
 
- Protected Member Functions inherited from SimpleThreadHandler
virtual void exceptionCaught (const EptException &e)
 EPT exception handling. More...
 
void setCancelThread (bool b)
 Cancel-flag setter method, thread-safe. More...
 
bool cancelThread () const
 Cancel-flag getter method, thread-safe. More...
 
void msleep (double milliseconds)
 Sleep function for staying idle. More...
 
bool isThreadRunning () const
 Flag to check if the thread is running. More...
 

Private Member Functions

void updateTuningcurve (int keynumber)
 Update the tuning curve for a given key number. More...
 
void updateTuningcurve ()
 Update the entire tuning curve. More...
 

Private Attributes

std::vector< double > mPitch
 

Additional Inherited Members

- Static Public Member Functions inherited from SimpleThreadHandler
static void setThreadName (std::string s)
 Specify the name of the thread. More...
 
- Protected Types inherited from Algorithm
using Keys = Keyboard::Keys
 
using SpectrumType = Key::SpectrumType
 
- Protected Attributes inherited from Algorithm
const size_t NumberOfBins = Key::NumberOfBins
 
Piano mPiano
 Copy of the piano. More...
 
const AlgorithmFactoryDescriptionmFactoryDescription
 
KeyboardmKeyboard
 Reference to the keyboard. More...
 
KeysmKeys
 Reference to the keys. More...
 
const int mNumberOfKeys
 The number of keys. More...
 
const int mKeyNumberOfA4
 Number of A4. More...
 

Detailed Description

Basic class to show how to implement own algorithms.

This class will calculate an equidistant tuning curve.

Definition at line 39 of file pitchraise.h.

Constructor & Destructor Documentation

pitchraise::PitchRaise::PitchRaise ( const Piano piano,
const AlgorithmFactoryDescription description 
)

Constructor of the pitch-raise algorithm.

Parameters
piano: Reference to the original piano, will be copied to mPiano
description: Short description of the algorithm

Definition at line 53 of file pitchraise.cpp.

Member Function Documentation

void pitchraise::PitchRaise::algorithmWorkerFunction ( )
finaloverrideprotectedvirtual

PitchRaise::algorithmWorkerFunction.

This is the main worker function of the Pitch-Raise algorithm which is executed in an independent thread. All computations are carried out here. The main parts are the following. First the recorded keys are identified. their measured inharmonicity is loaded and the logarithm is taken. The assumption is that this logarithm varies linearly with the key index in both diagonal sections of the strings. Therefore, an ordinary linear regression is carried out. This allows one to define an approximated inharmonicity for all keys (implemented as a lambda function). With this data a tuning curve is computed by a mixed 4:2 6:3 ... tuning, similar to the initial condition in the entropy minimizer. The whole process is artificially slowed down (msleep) in order to show how the tuning curve grows.

Implements Algorithm.

Definition at line 116 of file pitchraise.cpp.

+ Here is the call graph for this function:

void pitchraise::PitchRaise::updateTuningcurve ( int  keynumber)
private

Update the tuning curve for a given key number.

This function translates the actual mPitch value into the corresponding frequency, stores the value in the local piano copy mPiano and sends a message that the tuning curve has to be redrawn.

Parameters
keynumber: Number of the key to be updated

Definition at line 73 of file pitchraise.cpp.

+ Here is the call graph for this function:

void pitchraise::PitchRaise::updateTuningcurve ( )
private

Update the entire tuning curve.

This function translates the all mPitch values into the corresponding frequencies, stores the values in the local piano copy mPiano and sends a sequence of messages that the tuning curve has to be redrawn.

Definition at line 89 of file pitchraise.cpp.

Member Data Documentation

std::vector<double> pitchraise::PitchRaise::mPitch
private

Definition at line 52 of file pitchraise.h.


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