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
Algorithm Class Referenceabstract

The Algorithm class is a basic abstract class for any algorithm. More...

#include <algorithm.h>

+ Inheritance diagram for Algorithm:
+ Collaboration diagram for Algorithm:

Public Member Functions

 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 Types

using Keys = Keyboard::Keys
 
using SpectrumType = Key::SpectrumType
 

Protected Member Functions

virtual void algorithmWorkerFunction ()=0
 
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...
 

Protected Attributes

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...
 

Additional Inherited Members

- Static Public Member Functions inherited from SimpleThreadHandler
static void setThreadName (std::string s)
 Specify the name of the thread. More...
 

Detailed Description

The Algorithm class is a basic abstract class for any algorithm.

It creates a copy of the actual Piano in mPiano. The algorithm is allowed to change this data in any way.

Definition at line 38 of file algorithm.h.

Member Typedef Documentation

using Algorithm::Keys = Keyboard::Keys
protected

Definition at line 58 of file algorithm.h.

Definition at line 59 of file algorithm.h.

Constructor & Destructor Documentation

Algorithm::Algorithm ( const Piano piano,
const AlgorithmFactoryDescription desciption 
)

Definition at line 27 of file algorithm.cpp.

Algorithm::~Algorithm ( )
virtual

Definition at line 38 of file algorithm.cpp.

Member Function Documentation

virtual void Algorithm::algorithmWorkerFunction ( )
protectedpure virtual
void Algorithm::showCalculationProgress ( double  fraction)
protected

Transmit the current percentage of progress to the messaging system.

Parameters
percentage: value in [0,1], corresponding to 0% and 100%

Definition at line 79 of file algorithm.cpp.

void Algorithm::showCalculationProgress ( const Key key,
double  start = 0,
double  range = 1 
)
protected

Transmit the current percentage of progress to the messaging system.

Parameters
key: reference to the key that is being processed, converted to a percentage. The progress value is reconstructed from the measured frequency.
start: The starting value of the progress value
range: The range of the progress value (start ... start+range)

Definition at line 100 of file algorithm.cpp.

+ Here is the call graph for this function:

bool Algorithm::terminateThread ( )
inlineprotected

Definition at line 51 of file algorithm.h.

+ Here is the call graph for this function:

void Algorithm::updateTuningCurve ( int  keynumber,
double  frequency 
)
protected

Definition at line 60 of file algorithm.cpp.

void Algorithm::workerFunction ( )
finaloverridevirtual

Virtual worker function, executed within the new thread.

Overload this function with the code to be executed within the new thread. Make sure that it either returns by itself or when cancelThread() becomes true. This means that a typical implementation of the workerFunction() should contain a while(not cancelThread()) loop.

If you want the thread to stay idle call msleep.

Implements SimpleThreadHandler.

Definition at line 43 of file algorithm.cpp.

+ Here is the call graph for this function:

Member Data Documentation

const AlgorithmFactoryDescription& Algorithm::mFactoryDescription
protected

Definition at line 63 of file algorithm.h.

Keyboard& Algorithm::mKeyboard
protected

Reference to the keyboard.

Definition at line 66 of file algorithm.h.

const int Algorithm::mKeyNumberOfA4
protected

Number of A4.

Definition at line 69 of file algorithm.h.

Keys& Algorithm::mKeys
protected

Reference to the keys.

Definition at line 67 of file algorithm.h.

const int Algorithm::mNumberOfKeys
protected

The number of keys.

Definition at line 68 of file algorithm.h.

Piano Algorithm::mPiano
protected

Copy of the piano.

Definition at line 62 of file algorithm.h.

const size_t Algorithm::NumberOfBins = Key::NumberOfBins
protected

Definition at line 60 of file algorithm.h.


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