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
tuningcurvegraphdrawer.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 // Draw the tuning curve
22 //=============================================================================
23 
24 #ifndef TUNINGCURVEGRAPHADAPTER_H
25 #define TUNINGCURVEGRAPHADAPTER_H
26 
27 #include "../system/prerequisites.h"
28 #include "drawerbase.h"
29 #include "../piano/piano.h"
30 #include "../messages/messagelistener.h"
31 
32 #include <cstdint>
33 
37 
46 
48 {
49 protected:
50  static const int rangeInCents;
51 
52 private:
53 
61 
62  enum ItemRoles
63  {
64  ROLE_GRID = 0x01,
69  ROLE_OVERPULL = 0x20,
70 
75  };
76 
77 public:
78  TuningCurveGraphDrawer(GraphicsViewAdapter *graphics); // Constructor
80 
81  // Modify the tuning curve by mouse clicks:
82  void manuallyEditTuningCurveByClick (double relX, double relY);
83 
85 
86 protected:
87  virtual void draw() final;
88  virtual void handleMessage(MessagePtr m) override;
89 
90 protected:
91  static const PenType gridcolor;
92  static const PenType middleline;
93  static const PenType centlines;
94  static const PenType bmarkers;
95  static const PenType frmarkers;
96  static const PenType fgmarkers;
97  static const PenType fcmarkers;
98  static const PenType ftmarkers;
99  static const PenType opmarkers;
100  static const FillType allowdAreaFill;
101 
102  const Piano *mPiano;
103  double mConcertPitch;
106 
108 
109  // Private functions:
110  double convertCentsToY (double cents);
111  double getMarkerPosition(int keyindex, RoleType role);
112  void drawMarkers(int8_t key);
113  void drawGrid ();
115  void updateMarkerPosition(int keyindex, RoleType role);
116 };
117 
118 #endif // TUNINGCURVEGRAPHADAPTER_H
int mKeyNumberOfA4
Index of A4 (reference key)
std::shared_ptr< Message > MessagePtr
Global type of a shared message pointer.
Definition: message.h:98
std::uint32_t RoleType
Type of a user role that can be set in a GraphicsItem (bitwise flag).
Definition: graphicsitem.h:62
OperationMode
Operation mode of the tuner.
Definition: prerequisites.h:66
~TuningCurveGraphDrawer()
Empty destructor.
int mNumberOfKeys
Total number of keys (88)
double getMarkerPosition(int keyindex, RoleType role)
Compute the position of a marker.
static const PenType fcmarkers
Pen type for computed frequency markers.
GraphicsItem::RoleType RoleType
OperationMode mOperationMode
Current operation mode.
Definition: piano.h:40
virtual void draw() final
Main drawing function.
TuningCurveGraphDrawer(GraphicsViewAdapter *graphics)
Constructor, calls the DrawerBase constructor and resets variables.
Union of all key-specific markers.
static const PenType bmarkers
Pen type for inharmonicity markers.
const Piano * mPiano
Pointer to the actual piano.
FillTypes
Available filling colors (e.g. to fill rectangles)
static const FillType allowdAreaFill
Filling for the allowed tuning area.
static const PenType gridcolor
Pen type for background grid pentype.
static const PenType middleline
Pen type for bold middle line of grid.
static const PenType fgmarkers
Pen type for recorded frequency in background.
Inharmonicity marker (shown upside down)
static const PenType opmarkers
Pen type for tuned frequency markers.
static const PenType frmarkers
Pen type for recorded frequency markers.
PenType
Available pen types for drawing.
Marker indicating recorded frequency.
Abstract base class for implementations rendering graphics.
ItemRoles
The ItemRoles used in the TuningCurveGraphDrawer.
double convertCentsToY(double cents)
Convert cents to y-coordinate between 0 and 1.
static const PenType ftmarkers
Pen type for tuned frequency markers.
virtual void handleMessage(MessagePtr m) override
Message listener and dispatcher.
double mConcertPitch
Chosen concert pitch in Hz.
static const int rangeInCents
Constant, defining the visible range above and below the equal temperament level in cents...
void updateMarkerPosition(int keyindex, RoleType role)
void manuallyEditTuningCurveByClick(double relX, double relY)
Manually edit tuning curve by mouse click.
OperationMode getOperationMode() const
Marker indicating computed frequency.
void drawMarkers(int8_t key)
Draw the tuning markers in the tuning curve panel.
void drawGrid()
Draw the background grid in the tuning curve panel.
static const PenType centlines
Pen type for thin grid indicating cents.
Class for drawing various tuning curves.
Abstract base class for drawing 2d graphics.
Definition: drawerbase.h:40
PenType getMarkerPenType(RoleType role)
Get the pen type of a marker with a given role.