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
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
20 #ifndef ALGORITHM_H
21 #define ALGORITHM_H
23 #include "../system/simplethreadhandler.h"
24 #include "../system/log.h"
25 #include "../piano/piano.h"
39 {
40 public:
41  Algorithm(const Piano &piano, const AlgorithmFactoryDescription &desciption);
42  virtual ~Algorithm();
44  virtual void workerFunction() override final;
46 protected:
47  virtual void algorithmWorkerFunction() = 0;
49  void updateTuningCurve(int keynumber, double frequency);
51  bool terminateThread() { return cancelThread(); }
53  void showCalculationProgress (double fraction);
54  void showCalculationProgress (const Key &key, double start=0, double range=1);
57 protected:
65  // useful variables that
68  const int mNumberOfKeys;
69  const int mKeyNumberOfA4;
70 };
72 #endif // ALGORITHM_H
Class describing the piano keyboard, holding a collection of keys.
Definition: keyboard.h:39
virtual ~Algorithm()
Definition: algorithm.cpp:38
virtual void algorithmWorkerFunction()=0
virtual void workerFunction() overridefinal
Virtual worker function, executed within the new thread.
Definition: algorithm.cpp:43
bool terminateThread()
Definition: algorithm.h:51
Class describing a single piano key.
Definition: key.h:45
static const int NumberOfBins
Total number of slots: 9 octaves.
Definition: key.h:50
Definition: piano.h:40
Keyboard::Keys Keys
Definition: algorithm.h:58
Keyboard & mKeyboard
Reference to the keyboard.
Definition: algorithm.h:66
Key::SpectrumType SpectrumType
Definition: algorithm.h:59
const int mKeyNumberOfA4
Number of A4.
Definition: algorithm.h:69
const AlgorithmFactoryDescription & mFactoryDescription
Definition: algorithm.h:63
virtual void start()
Start the thread.
void showCalculationProgress(double fraction)
Transmit the current percentage of progress to the messaging system.
Definition: algorithm.cpp:79
void updateTuningCurve(int keynumber, double frequency)
Definition: algorithm.cpp:60
Keys & mKeys
Reference to the keys.
Definition: algorithm.h:67
std::vector< double > SpectrumType
Type of a log-binned spectrum.
Definition: key.h:54
The Algorithm class is a basic abstract class for any algorithm.
Definition: algorithm.h:38
Algorithm(const Piano &piano, const AlgorithmFactoryDescription &desciption)
Definition: algorithm.cpp:27
Piano mPiano
Copy of the piano.
Definition: algorithm.h:62
bool cancelThread() const
Cancel-flag getter method, thread-safe.
std::vector< Key > Keys
Definition: keyboard.h:42
const size_t NumberOfBins
Definition: algorithm.h:60
Simple thread handler.
const int mNumberOfKeys
The number of keys.
Definition: algorithm.h:68