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
fourierspectrumgraphdrawer.h
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  *****************************************************************************/
19 
20 //=============================================================================
21 // Drawer for drawing the spectrum with the peak markers
22 //=============================================================================
23 
24 #ifndef FOURIERSPECTRUMGRAPHDRAWER_H
25 #define FOURIERSPECTRUMGRAPHDRAWER_H
26 
27 #include "../system/prerequisites.h"
28 #include "drawerbase.h"
29 #include "../piano/keyboard.h"
30 #include "../messages/messagelistener.h"
31 #include "../analyzers/signalanalyzer.h"
32 
41 
43 {
44 public:
45  const double updateInterval = 1.0;
46 
47  enum RoleType
48  {
50  ROLE_CHART = 2,
51  ROLE_PEAK = 4
52  };
53 
54 public:
57 
58 protected:
59  virtual void draw() override final;
60  virtual void clear() override final;
61  virtual void handleMessage(MessagePtr m) override;
62 
63  void updateSpectrum();
64 
65 private:
66  double mConcertPitch;
71  std::shared_ptr<FFTPolygon> mPolygon;
72  std::shared_ptr<Key> mKey;
73 };
74 
75 #endif // FOURIERSPECTRUMGRAPHDRAWER_H
std::shared_ptr< Message > MessagePtr
Global type of a shared message pointer.
Definition: message.h:98
OperationMode
Operation mode of the tuner.
Definition: prerequisites.h:66
OperationMode mCurrentOperationMode
Current mode of operation.
RoleType
< Roles of the items used here
int mNumberOfKeys
Total number of keys.
virtual void handleMessage(MessagePtr m) override
Message dispatcher for FourierSpectrumGraphDrawer.
Class describing a single piano key.
Definition: key.h:45
int mSamplingRate
copy of sample rate
std::map< double, double > FFTPolygon
Type for a frequency-to-intensity map for graphics.
Definition: fftadapter.h:45
The FourierSpectrumGraphDrawer class.
void updateSpectrum()
Function for updating the red curve showing the spectrum.
~FourierSpectrumGraphDrawer()
Empty destructor.
virtual void draw() overridefinal
Draw the spectrum.
const double updateInterval
Update interval at least 1 sec.
double mConcertPitch
Target freuqency of A4.
std::shared_ptr< Key > mKey
Shared pointer to selected key, holding the peaks.
Abstract base class for implementations rendering graphics.
std::shared_ptr< FFTPolygon > mPolygon
Shared pointer to spectral polygon.
virtual void clear() overridefinal
Clear the spectrum.
FourierSpectrumGraphDrawer(GraphicsViewAdapter *graphics)
Constructor of a FourierSpectrumGraphDrawer.
Abstract base class for drawing 2d graphics.
Definition: drawerbase.h:40