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 Class Reference

Class for drawing various tuning curves. More...

#include <tuningcurvegraphdrawer.h>

+ Inheritance diagram for TuningCurveGraphDrawer:
+ Collaboration diagram for TuningCurveGraphDrawer:

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...
 
- Public Member Functions inherited from MessageListener
 MessageListener (bool defaultActivation=true)
 
virtual ~MessageListener ()
 
bool isMessageListenerActive () const
 
void activateMessageListener ()
 
void deactivateMessageListener ()
 

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

Detailed Description

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.

Member Enumeration Documentation

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.

Enumerator
ROLE_GRID 

Grid line.

ROLE_INHARMONICITY 

Inharmonicity marker (shown upside down)

ROLE_RECORDED_FREQUENCY 

Marker indicating recorded frequency.

ROLE_COMPUTED_FREQUENCY 

Marker indicating computed frequency.

ROLE_TUNED_FREQUENCY 

Marker indicating tuned frequency.

ROLE_OVERPULL 

Marker indicating overpull.

ROLE_GLOBAL 

Union of all global markers.

ROLE_KEY_INDIVIDUAL 

Union of all key-specific markers.

Definition at line 62 of file tuningcurvegraphdrawer.h.

Constructor & Destructor Documentation

TuningCurveGraphDrawer::TuningCurveGraphDrawer ( GraphicsViewAdapter graphics)

Constructor, calls the DrawerBase constructor and resets variables.

Definition at line 70 of file tuningcurvegraphdrawer.cpp.

TuningCurveGraphDrawer::~TuningCurveGraphDrawer ( )
inline

Empty destructor.

Definition at line 79 of file tuningcurvegraphdrawer.h.

Member Function Documentation

double TuningCurveGraphDrawer::convertCentsToY ( double  cents)
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.

Parameters
cents: Deviation in cents.
Returns
Corresponding y-coordinate

Definition at line 155 of file tuningcurvegraphdrawer.cpp.

void TuningCurveGraphDrawer::draw ( )
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.

+ Here is the call graph for this function:

void TuningCurveGraphDrawer::drawGrid ( )
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.

+ Here is the call graph for this function:

void TuningCurveGraphDrawer::drawMarkers ( int8_t  keynumber)
protected

Draw the tuning markers in the tuning curve panel.

Parameters
keynumber: Number of the key

Definition at line 248 of file tuningcurvegraphdrawer.cpp.

+ Here is the call graph for this function:

PenType TuningCurveGraphDrawer::getMarkerPenType ( RoleType  role)
protected

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.

Parameters
role: Role of the marker (see enum RoleType).
Returns
PenType of the marker depending on the actual operation mode.

Definition at line 389 of file tuningcurvegraphdrawer.cpp.

double TuningCurveGraphDrawer::getMarkerPosition ( int  keyindex,
RoleType  role 
)
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.

Parameters
keyindex: Number of the key where the marker is located.
role: RoleType of the marker.
Returns
y-coordinate between 0 and 1.

Definition at line 304 of file tuningcurvegraphdrawer.cpp.

+ Here is the call graph for this function:

OperationMode TuningCurveGraphDrawer::getOperationMode ( ) const
inline

Definition at line 84 of file tuningcurvegraphdrawer.h.

void TuningCurveGraphDrawer::handleMessage ( MessagePtr  m)
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.

Parameters
m: Pointer to the incoming message

Implements MessageListener.

Definition at line 93 of file tuningcurvegraphdrawer.cpp.

+ Here is the call graph for this function:

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.

Parameters
relX: Relative x-coordinate of the mouse click.
relY: Relative y-coordinate of the mouse click.

Definition at line 179 of file tuningcurvegraphdrawer.cpp.

+ Here is the call graph for this function:

void TuningCurveGraphDrawer::updateMarkerPosition ( int  keyindex,
RoleType  role 
)
protected

Definition at line 405 of file tuningcurvegraphdrawer.cpp.

+ Here is the call graph for this function:

Member Data Documentation

const FillType TuningCurveGraphDrawer::allowdAreaFill = GraphicsViewAdapter::FILL_LIGHT_GREEN
staticprotected

Filling for the allowed tuning area.

Definition at line 100 of file tuningcurvegraphdrawer.h.

const PenType TuningCurveGraphDrawer::bmarkers = GraphicsViewAdapter::PEN_MEDIUM_LIGHT_GRAY
staticprotected

Pen type for inharmonicity markers.

Definition at line 94 of file tuningcurvegraphdrawer.h.

const PenType TuningCurveGraphDrawer::centlines = GraphicsViewAdapter::PEN_THIN_VERY_LIGHT_GRAY
staticprotected

Pen type for thin grid indicating cents.

Definition at line 93 of file tuningcurvegraphdrawer.h.

const PenType TuningCurveGraphDrawer::fcmarkers = GraphicsViewAdapter::PEN_MEDIUM_DARK_GREEN
staticprotected

Pen type for computed frequency markers.

Definition at line 97 of file tuningcurvegraphdrawer.h.

const PenType TuningCurveGraphDrawer::fgmarkers = GraphicsViewAdapter::PEN_THIN_LIGHT_GRAY
staticprotected

Pen type for recorded frequency in background.

Definition at line 96 of file tuningcurvegraphdrawer.h.

const PenType TuningCurveGraphDrawer::frmarkers = GraphicsViewAdapter::PEN_THIN_BLUE
staticprotected

Pen type for recorded frequency markers.

Definition at line 95 of file tuningcurvegraphdrawer.h.

const PenType TuningCurveGraphDrawer::ftmarkers = GraphicsViewAdapter::PEN_MEDIUM_RED
staticprotected

Pen type for tuned frequency markers.

Definition at line 98 of file tuningcurvegraphdrawer.h.

const PenType TuningCurveGraphDrawer::gridcolor = GraphicsViewAdapter::PEN_THIN_DARK_GRAY
staticprotected

Pen type for background grid pentype.

Definition at line 91 of file tuningcurvegraphdrawer.h.

double TuningCurveGraphDrawer::mConcertPitch
protected

Chosen concert pitch in Hz.

Definition at line 103 of file tuningcurvegraphdrawer.h.

const PenType TuningCurveGraphDrawer::middleline = GraphicsViewAdapter::PEN_MEDIUM_DARK_GRAY
staticprotected

Pen type for bold middle line of grid.

Definition at line 92 of file tuningcurvegraphdrawer.h.

int TuningCurveGraphDrawer::mKeyNumberOfA4
protected

Index of A4 (reference key)

Definition at line 104 of file tuningcurvegraphdrawer.h.

int TuningCurveGraphDrawer::mNumberOfKeys
protected

Total number of keys (88)

Definition at line 105 of file tuningcurvegraphdrawer.h.

OperationMode TuningCurveGraphDrawer::mOperationMode
protected

Current operation mode.

Definition at line 107 of file tuningcurvegraphdrawer.h.

const Piano* TuningCurveGraphDrawer::mPiano
protected

Pointer to the actual piano.

Definition at line 102 of file tuningcurvegraphdrawer.h.

const PenType TuningCurveGraphDrawer::opmarkers = GraphicsViewAdapter::PEN_MEDIUM_MAGENTA
staticprotected

Pen type for tuned frequency markers.

Definition at line 99 of file tuningcurvegraphdrawer.h.

const int TuningCurveGraphDrawer::rangeInCents = 60
staticprotected

Constant, defining the visible range above and below the equal temperament level in cents.

Definition at line 50 of file tuningcurvegraphdrawer.h.


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