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

Class describing a single piano key. More...

#include <key.h>

Public Types

using SpectrumType = std::vector< double >
 Type of a log-binned spectrum. More...
 
using PeakListType = std::map< double, double >
 Type for a peak map. More...
 

Public Member Functions

 Key ()
 Constructor. More...
 
 ~Key ()
 Destructor. More...
 
void clear ()
 Clear all data elements of the Key. More...
 
void setSpectrum (const SpectrumType &s)
 Copy spectrum to mSpectrum. More...
 
const SpectrumTypegetSpectrum () const
 Get a read-only reference to mSpectrum. More...
 
SpectrumTypegetSpectrum ()
 Get a read-write reference of mSpectrum. More...
 
void setPeaks (const PeakListType &s)
 Copy map of peaks. More...
 
const PeakListTypegetPeaks () const
 Get a read-only reference to mPeaks. More...
 
PeakListTypegetPeaks ()
 Get a read-write reference of mPeaks. More...
 
void setRecordedFrequency (const double f)
 Set recorded frequency. More...
 
double getRecordedFrequency () const
 Get recorded frequency. More...
 
double & getRecordedFrequency ()
 Get recorded frequency. More...
 
void setMeasuredInharmonicity (double f)
 Set estimated inharmonicity. More...
 
double getMeasuredInharmonicity () const
 Get estimated inharmonicity. More...
 
double & getMeasuredInharmonicity ()
 Get estimated inharmonicity. More...
 
void setRecognitionQuality (double f)
 Set quality of recognition. More...
 
double getRecognitionQuality () const
 Get quality of recognition. More...
 
double & getRecognitionQuality ()
 Get quality of recognition. More...
 
void setComputedFrequency (double f)
 Set computed frequency. More...
 
double getComputedFrequency () const
 Get computed frequency. More...
 
double & getComputedFrequency ()
 Get computed frequency. More...
 
void setTunedFrequency (double f)
 Set tuned frequency. More...
 
double getTunedFrequency () const
 Get tuned frequency. More...
 
double & getTunedFrequency ()
 Get tuned frequency. More...
 
void setOverpull (double cents)
 Set overpull in cents. More...
 
double getOverpull () const
 Get overpull in cents. More...
 
double & getOverpull ()
 Get overpull in cents. More...
 
void setRecorded (bool r)
 Set recorded flag. More...
 
bool isRecorded () const
 Get recorded flag. More...
 
bool & isRecorded ()
 Get recorded flag. More...
 

Static Public Member Functions

static int FrequencyToIndex (double f)
 Convert frequency to logbin index. More...
 
static double FrequencyToRealIndex (double f)
 Convert frequency to real-valued logbin index. More...
 
static double IndexToFrequency (double m)
 Convert continuous slot index to frequency in Hz. More...
 

Static Public Attributes

static const int NumberOfBins = 10800
 Total number of slots: 9 octaves. More...
 
static const int BinsPerOctave = 1200
 Number of slots per ocatave (here 1 cent) More...
 
static const double fmin = 20.601722
 Mimimal frequency of logbinned spectrum in Hz. More...
 

Private Attributes

SpectrumType mSpectrum
 Logarithmically organized spectrum. More...
 
PeakListType mPeaks
 List of identified peaks. More...
 
double mRecordedFrequency
 Recorded frequency of 1st partial in Hz. More...
 
double mMeasuredInharmonicity
 Measured inharmonicity of recorded signal. More...
 
double mRecognitionQuality
 Accuracy of higher partials (in cents) More...
 
double mComputedFrequency
 Computed frequency in Hz (tuning curve) More...
 
double mTunedFrequency
 Tuned frequency in Hz. More...
 
double mOverpull
 Overpull in cents. More...
 
bool mRecorded
 Is the key already recorded? More...
 

Detailed Description

Class describing a single piano key.

This class holds all information related to an individual piano key of the keyboard. The most important element is the logarithmically binned power spectrum of the key (in short: logbin spectrum). In contrast to the ordinary FFT, which is linear in the frequency index, the logbin spectrum is a vector whose index is logarithmic in the frequency. The resolution is chosen in such a way that each vector component corresponds exactly to one cent (1/100 half tone).

In addition, the Key class comprises various member variables such as the mesured, the computed, and the tuned frequency.

Definition at line 45 of file key.h.

Member Typedef Documentation

using Key::PeakListType = std::map<double,double>

Type for a peak map.

Definition at line 55 of file key.h.

using Key::SpectrumType = std::vector<double>

Type of a log-binned spectrum.

Definition at line 54 of file key.h.

Constructor & Destructor Documentation

Key::Key ( )
inline

Constructor.

Definition at line 65 of file key.h.

+ Here is the call graph for this function:

Key::~Key ( )
inline

Destructor.

Definition at line 66 of file key.h.

Member Function Documentation

void Key::clear ( )

Clear all data elements of the Key.

Definition at line 42 of file key.cpp.

int Key::FrequencyToIndex ( double  f)
static

Convert frequency to logbin index.

Converts a frequency in Hz to the corresponding logbin index.

Parameters
f: Frequency in Hz in the range 0 < f < 20 kHz.
Returns
Logbin index. Note that this value may lie outside of the allowed index range of the logbin spectrum.

Definition at line 88 of file key.cpp.

+ Here is the call graph for this function:

double Key::FrequencyToRealIndex ( double  f)
static

Convert frequency to real-valued logbin index.

Converts a frequency in Hz to the corresponding logbin index. For reasons of invertibility this function returns a floating-point value. In order to get the actual logbin index the result of this function has to be rounded (not truncated) to an integer.

Parameters
f: Frequency in Hz in the range 0 < f < 20 kHz.
Returns
Floating point value representing the logbin index. Note that this value may lie outside of the allowed index range of the logbin spectrum.

Definition at line 70 of file key.cpp.

double Key::getComputedFrequency ( ) const

Get computed frequency.

Definition at line 174 of file key.cpp.

double & Key::getComputedFrequency ( )

Get computed frequency.

Definition at line 177 of file key.cpp.

double Key::getMeasuredInharmonicity ( ) const

Get estimated inharmonicity.

Definition at line 141 of file key.cpp.

double & Key::getMeasuredInharmonicity ( )

Get estimated inharmonicity.

Definition at line 144 of file key.cpp.

double Key::getOverpull ( ) const

Get overpull in cents.

Definition at line 211 of file key.cpp.

double & Key::getOverpull ( )

Get overpull in cents.

Definition at line 214 of file key.cpp.

const Key::PeakListType & Key::getPeaks ( ) const

Get a read-only reference to mPeaks.

Definition at line 259 of file key.cpp.

Key::PeakListType & Key::getPeaks ( )

Get a read-write reference of mPeaks.

Definition at line 256 of file key.cpp.

double Key::getRecognitionQuality ( ) const

Get quality of recognition.

Definition at line 155 of file key.cpp.

double & Key::getRecognitionQuality ( )

Get quality of recognition.

Definition at line 158 of file key.cpp.

double Key::getRecordedFrequency ( ) const

Get recorded frequency.

Definition at line 119 of file key.cpp.

double & Key::getRecordedFrequency ( )

Get recorded frequency.

Definition at line 122 of file key.cpp.

const Key::SpectrumType & Key::getSpectrum ( ) const

Get a read-only reference to mSpectrum.

Definition at line 237 of file key.cpp.

Key::SpectrumType & Key::getSpectrum ( )

Get a read-write reference of mSpectrum.

Definition at line 234 of file key.cpp.

double Key::getTunedFrequency ( ) const

Get tuned frequency.

Definition at line 193 of file key.cpp.

double & Key::getTunedFrequency ( )

Get tuned frequency.

Definition at line 196 of file key.cpp.

double Key::IndexToFrequency ( double  m)
static

Convert continuous slot index to frequency in Hz.

Converts a logbin index to the corresponding frequency in Hz.

Parameters
m: Index of the logbin spectrum in the range [0,NumberOfBins]
Returns
Frequency in Hz

Definition at line 102 of file key.cpp.

bool Key::isRecorded ( ) const
inline

Get recorded flag.

Definition at line 102 of file key.h.

bool& Key::isRecorded ( )
inline

Get recorded flag.

Definition at line 103 of file key.h.

void Key::setComputedFrequency ( double  f)

Set computed frequency.

Definition at line 168 of file key.cpp.

void Key::setMeasuredInharmonicity ( double  f)

Set estimated inharmonicity.

Definition at line 130 of file key.cpp.

void Key::setOverpull ( double  cents)

Set overpull in cents.

Definition at line 204 of file key.cpp.

void Key::setPeaks ( const PeakListType s)

Copy map of peaks.

Definition at line 245 of file key.cpp.

void Key::setRecognitionQuality ( double  f)

Set quality of recognition.

Definition at line 152 of file key.cpp.

void Key::setRecorded ( bool  r)
inline

Set recorded flag.

Definition at line 101 of file key.h.

void Key::setRecordedFrequency ( const double  f)

Set recorded frequency.

Definition at line 113 of file key.cpp.

void Key::setSpectrum ( const SpectrumType s)

Copy spectrum to mSpectrum.

Definition at line 222 of file key.cpp.

void Key::setTunedFrequency ( double  f)

Set tuned frequency.

Definition at line 187 of file key.cpp.

Member Data Documentation

const int Key::BinsPerOctave = 1200
static

Number of slots per ocatave (here 1 cent)

Definition at line 51 of file key.h.

const double Key::fmin = 20.601722
static

Mimimal frequency of logbinned spectrum in Hz.

Definition at line 52 of file key.h.

double Key::mComputedFrequency
private

Computed frequency in Hz (tuning curve)

Definition at line 111 of file key.h.

double Key::mMeasuredInharmonicity
private

Measured inharmonicity of recorded signal.

Definition at line 109 of file key.h.

double Key::mOverpull
private

Overpull in cents.

Definition at line 113 of file key.h.

PeakListType Key::mPeaks
private

List of identified peaks.

Definition at line 107 of file key.h.

double Key::mRecognitionQuality
private

Accuracy of higher partials (in cents)

Definition at line 110 of file key.h.

bool Key::mRecorded
private

Is the key already recorded?

Definition at line 114 of file key.h.

double Key::mRecordedFrequency
private

Recorded frequency of 1st partial in Hz.

Definition at line 108 of file key.h.

SpectrumType Key::mSpectrum
private

Logarithmically organized spectrum.

Definition at line 106 of file key.h.

double Key::mTunedFrequency
private

Tuned frequency in Hz.

Definition at line 112 of file key.h.

const int Key::NumberOfBins = 10800
static

Total number of slots: 9 octaves.

Definition at line 50 of file key.h.


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