Entropy Piano Tuner
1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
|
Class for drawing various tuning curves. More...
#include <tuningcurvegraphdrawer.h>
Public Member Functions | |
TuningCurveGraphDrawer (GraphicsViewAdapter *graphics) | |
Constructor, calls the DrawerBase constructor and resets variables. More... | |
~TuningCurveGraphDrawer () | |
Empty destructor. More... | |
void | manuallyEditTuningCurveByClick (double relX, double relY) |
Manually edit tuning curve by mouse click. More... | |
OperationMode | getOperationMode () const |
Public Member Functions inherited from DrawerBase | |
DrawerBase (GraphicsViewAdapter *graphics, double intervall=1.0/24.0) | |
Constructor of a drawer. More... | |
~DrawerBase () | |
void | redraw (bool force=false) |
Function to completely redraw the scene. More... | |
bool | requestRedraw (bool force=false) |
Check whether the content has to be redrawn. More... | |
Protected Member Functions | |
virtual void | draw () final |
Main drawing function. More... | |
virtual void | handleMessage (MessagePtr m) override |
Message listener and dispatcher. More... | |
double | convertCentsToY (double cents) |
Convert cents to y-coordinate between 0 and 1. More... | |
double | getMarkerPosition (int keyindex, RoleType role) |
Compute the position of a marker. More... | |
void | drawMarkers (int8_t key) |
Draw the tuning markers in the tuning curve panel. More... | |
void | drawGrid () |
Draw the background grid in the tuning curve panel. More... | |
PenType | getMarkerPenType (RoleType role) |
Get the pen type of a marker with a given role. More... | |
void | updateMarkerPosition (int keyindex, RoleType role) |
Protected Member Functions inherited from DrawerBase | |
virtual void | clear () |
Clear the whole view. More... | |
Protected Attributes | |
const Piano * | mPiano |
Pointer to the actual piano. More... | |
double | mConcertPitch |
Chosen concert pitch in Hz. More... | |
int | mKeyNumberOfA4 |
Index of A4 (reference key) More... | |
int | mNumberOfKeys |
Total number of keys (88) More... | |
OperationMode | mOperationMode |
Current operation mode. More... | |
Protected Attributes inherited from DrawerBase | |
GraphicsViewAdapter * | mGraphics |
Pointer to the graphics view adapter. More... | |
Static Protected Attributes | |
static const int | rangeInCents = 60 |
Constant, defining the visible range above and below the equal temperament level in cents. More... | |
static const PenType | gridcolor = GraphicsViewAdapter::PEN_THIN_DARK_GRAY |
Pen type for background grid pentype. More... | |
static const PenType | middleline = GraphicsViewAdapter::PEN_MEDIUM_DARK_GRAY |
Pen type for bold middle line of grid. More... | |
static const PenType | centlines = GraphicsViewAdapter::PEN_THIN_VERY_LIGHT_GRAY |
Pen type for thin grid indicating cents. More... | |
static const PenType | bmarkers = GraphicsViewAdapter::PEN_MEDIUM_LIGHT_GRAY |
Pen type for inharmonicity markers. More... | |
static const PenType | frmarkers = GraphicsViewAdapter::PEN_THIN_BLUE |
Pen type for recorded frequency markers. More... | |
static const PenType | fgmarkers = GraphicsViewAdapter::PEN_THIN_LIGHT_GRAY |
Pen type for recorded frequency in background. More... | |
static const PenType | fcmarkers = GraphicsViewAdapter::PEN_MEDIUM_DARK_GREEN |
Pen type for computed frequency markers. More... | |
static const PenType | ftmarkers = GraphicsViewAdapter::PEN_MEDIUM_RED |
Pen type for tuned frequency markers. More... | |
static const PenType | opmarkers = GraphicsViewAdapter::PEN_MEDIUM_MAGENTA |
Pen type for tuned frequency markers. More... | |
static const FillType | allowdAreaFill = GraphicsViewAdapter::FILL_LIGHT_GREEN |
Filling for the allowed tuning area. More... | |
Private Types | |
enum | ItemRoles { ROLE_GRID = 0x01, ROLE_INHARMONICITY = 0x02, ROLE_RECORDED_FREQUENCY = 0x04, ROLE_COMPUTED_FREQUENCY = 0x08, ROLE_TUNED_FREQUENCY = 0x10, ROLE_OVERPULL = 0x20, ROLE_GLOBAL = ROLE_GRID, ROLE_KEY_INDIVIDUAL } |
The ItemRoles used in the TuningCurveGraphDrawer. More... | |
Class for drawing various tuning curves.
This drawer class take draws various curves, namely, the recorded pitch compared to equal temperament, the inharmonicity, the computed pitch and the tuning deviations. In order to update the markers individually, a different role is assigned to each marker.
Definition at line 47 of file tuningcurvegraphdrawer.h.
|
private |
The ItemRoles used in the TuningCurveGraphDrawer.
This enum defines the possible roles of the marker. It is encoded in terms of dual numbers so that bitwise logical operations are possible.
Definition at line 62 of file tuningcurvegraphdrawer.h.
TuningCurveGraphDrawer::TuningCurveGraphDrawer | ( | GraphicsViewAdapter * | graphics | ) |
Constructor, calls the DrawerBase constructor and resets variables.
Definition at line 70 of file tuningcurvegraphdrawer.cpp.
|
inline |
Empty destructor.
Definition at line 79 of file tuningcurvegraphdrawer.h.
|
protected |
Convert cents to y-coordinate between 0 and 1.
This function converts a given deviation in cent to the corresponding y-coordinate in the tuning curve window. In the tuning mode this map is nonlinear, amplifying the vicinity of optimal tune visually, while in all other operation modes the map is linear.
cents | : Deviation in cents. |
Definition at line 155 of file tuningcurvegraphdrawer.cpp.
|
finalprotectedvirtual |
Main drawing function.
This function draws the background grid and the markers in the tuning curve panel.
Implements DrawerBase.
Definition at line 280 of file tuningcurvegraphdrawer.cpp.
|
protected |
Draw the background grid in the tuning curve panel.
This function draws the background grid consisting of gray vertical lines according to the key positions and thin horizontal lines spaced by 10 cents. The middle line is emphasized.
Definition at line 211 of file tuningcurvegraphdrawer.cpp.
|
protected |
Draw the tuning markers in the tuning curve panel.
keynumber | : Number of the key |
Definition at line 248 of file tuningcurvegraphdrawer.cpp.
Get the pen type of a marker with a given role.
This function maps a role of a marker (see enum definded above) onto the required pen type (thickness and color) depending on the actual operation mode.
role | : Role of the marker (see enum RoleType). |
Definition at line 389 of file tuningcurvegraphdrawer.cpp.
|
protected |
Compute the position of a marker.
This function computes the vertical position (the y-coordinate) of a marker. The y-coordinate depends on the role of the element (such as recorded, computed and tuned frequency as well as the inharmonicity) and the actual operation mode of the tuner.
keyindex | : Number of the key where the marker is located. |
role | : RoleType of the marker. |
Definition at line 304 of file tuningcurvegraphdrawer.cpp.
|
inline |
Definition at line 84 of file tuningcurvegraphdrawer.h.
|
overrideprotectedvirtual |
Message listener and dispatcher.
This function is called by the message handler and takes action in the tuning curve window according to the incoming messages.
m | : Pointer to the incoming message |
Implements MessageListener.
Definition at line 93 of file tuningcurvegraphdrawer.cpp.
void TuningCurveGraphDrawer::manuallyEditTuningCurveByClick | ( | double | relX, |
double | relY | ||
) |
Manually edit tuning curve by mouse click.
In the calculation mode this function allows the user to manually edit the computed tuning curve by clicking into the tuning curve window. In the recording and tuning mode this functionality is used to select the corresponding key.
relX | : Relative x-coordinate of the mouse click. |
relY | : Relative y-coordinate of the mouse click. |
Definition at line 179 of file tuningcurvegraphdrawer.cpp.
|
protected |
Definition at line 405 of file tuningcurvegraphdrawer.cpp.
|
staticprotected |
Filling for the allowed tuning area.
Definition at line 100 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Pen type for inharmonicity markers.
Definition at line 94 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Pen type for thin grid indicating cents.
Definition at line 93 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Pen type for computed frequency markers.
Definition at line 97 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Pen type for recorded frequency in background.
Definition at line 96 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Pen type for recorded frequency markers.
Definition at line 95 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Pen type for tuned frequency markers.
Definition at line 98 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Pen type for background grid pentype.
Definition at line 91 of file tuningcurvegraphdrawer.h.
|
protected |
Chosen concert pitch in Hz.
Definition at line 103 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Pen type for bold middle line of grid.
Definition at line 92 of file tuningcurvegraphdrawer.h.
|
protected |
Index of A4 (reference key)
Definition at line 104 of file tuningcurvegraphdrawer.h.
|
protected |
Total number of keys (88)
Definition at line 105 of file tuningcurvegraphdrawer.h.
|
protected |
Current operation mode.
Definition at line 107 of file tuningcurvegraphdrawer.h.
|
protected |
Pointer to the actual piano.
Definition at line 102 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Pen type for tuned frequency markers.
Definition at line 99 of file tuningcurvegraphdrawer.h.
|
staticprotected |
Constant, defining the visible range above and below the equal temperament level in cents.
Definition at line 50 of file tuningcurvegraphdrawer.h.