Entropy Piano Tuner
1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
|
Class of functions for auditory preprocessing. More...
#include <auditorypreprocessing.h>
Public Types | |
using | SpectrumType = Key::SpectrumType |
using | Keys = Keyboard::Keys |
Public Member Functions | |
AuditoryPreprocessing (Piano &piano) | |
Constructor. More... | |
~AuditoryPreprocessing () | |
bool | checkDataConsistency () |
Check consistency of the piano dataset. More... | |
void | normalizeSpectrum (Key &key) |
Normalize spectrum. More... | |
double | getInharmonicPartial (double n, double f1, double B) |
Compute frequency of inharmonic partial. More... | |
double | getInharmonicPartialIndex (double f, double f1, double B) |
void | cleanSpectrum (Key &key) |
Clean logarithmically binned spectrum. More... | |
void | cutLowFrequencies (Key &key) |
Cut all frequencies below 5/6*f1 in order to reduce noise. More... | |
void | initializeSPLAFilter () |
Initialize the filter function in the vector mdBA. More... | |
void | convertToSPLA (SpectrumType &s) |
Compute A-weighted sound pressure level SPLA. More... | |
void | convertToLoudness (SpectrumType &s) |
void | extrapolateInharmonicity () |
Extrapolate inharmonicity and estimate missing values. More... | |
void | improveHighFrequencyPeaks () |
Improve high-frequency spectral lines. More... | |
void | applyMollifier (Key &key) |
Public Attributes | |
const size_t | NumberOfBins = Key::NumberOfBins |
Static Private Member Functions | |
static double | ftom (double f) |
static double | mtof (int m) |
Private Attributes | |
Piano & | mPiano |
Keyboard & | mKeyboard |
Keys & | mKeys |
int | mNumberOfKeys |
int | mKeyNumberOfA4 |
std::vector< double > | mdBA |
Class of functions for auditory preprocessing.
This class includes functions needed for the preparation of the spectra. It is controlled by the CalculationManager.
Definition at line 41 of file auditorypreprocessing.h.
Definition at line 48 of file auditorypreprocessing.h.
Definition at line 47 of file auditorypreprocessing.h.
entropyminimizer::AuditoryPreprocessing::AuditoryPreprocessing | ( | Piano & | piano | ) |
Constructor.
Initializes the member variables.
Definition at line 49 of file auditorypreprocessing.cpp.
|
inline |
Definition at line 45 of file auditorypreprocessing.h.
void entropyminimizer::AuditoryPreprocessing::applyMollifier | ( | Key & | key | ) |
bool entropyminimizer::AuditoryPreprocessing::checkDataConsistency | ( | ) |
Check consistency of the piano dataset.
This function tests the consistency of the incoming Piano dataset.
Definition at line 71 of file auditorypreprocessing.cpp.
void entropyminimizer::AuditoryPreprocessing::cleanSpectrum | ( | Key & | key | ) |
Clean logarithmically binned spectrum.
The purpose of this function is to cut away all contributions in the logarithmically binned spectrum which are not close to the location of expected partials (for given ground frequency f1 and inharmonicity B). To this end we define an envelope function in the range [0,1] which exhibits sharp peaks around the low-lying partials and broader peaks for the higher partials. This ensures that possible inaccuracies in the previous determination of the inharmonicity do not load to an errorneous cancellation of higher partials.
key | : Reference to the key |
Definition at line 230 of file auditorypreprocessing.cpp.
void entropyminimizer::AuditoryPreprocessing::convertToLoudness | ( | SpectrumType & | s | ) |
void entropyminimizer::AuditoryPreprocessing::convertToSPLA | ( | SpectrumType & | spectrum | ) |
Compute A-weighted sound pressure level SPLA.
This function computes the dBA-weighted sound pressure level (SPLA). The SPLA is basically the logarithm of the power of each spectral line with respect to a suitable lower cutoff. For simplicity the SPLA is stored in the same spectrum vector of the local copy, destroying the existing data which is not used for tuning.
spectrum | : Reference to the spectrum |
Definition at line 310 of file auditorypreprocessing.cpp.
void entropyminimizer::AuditoryPreprocessing::cutLowFrequencies | ( | Key & | key | ) |
Cut all frequencies below 5/6*f1 in order to reduce noise.
key | : Reference to the key |
Definition at line 255 of file auditorypreprocessing.cpp.
void entropyminimizer::AuditoryPreprocessing::extrapolateInharmonicity | ( | ) |
Extrapolate inharmonicity and estimate missing values.
In the upper half of the manual, the inharmonicity of the strings of a piano grows typically exponentially with the key index. During recording, however, some of the inharmonicity values are usually not correctly measured. This function identifies the outlyers and replaces them by a suitable interpolated value. Note that this works only with the standard design of pianos (parallel strings of the same kind in the upper half).
Definition at line 340 of file auditorypreprocessing.cpp.
|
inlinestaticprivate |
double entropyminimizer::AuditoryPreprocessing::getInharmonicPartial | ( | double | n, |
double | f1, | ||
double | B | ||
) |
Compute frequency of inharmonic partial.
This is the well-known function \(f_n=f_1 \sqrt{\frac{1+B n^2}{1+B} } \).
n | : Number of the partial |
f1 | : Frequency of the first partial |
B | : Inharmonicity coefficient |
Definition at line 182 of file auditorypreprocessing.cpp.
double entropyminimizer::AuditoryPreprocessing::getInharmonicPartialIndex | ( | double | f, |
double | f1, | ||
double | B | ||
) |
This function is the inverse of the function InharmonicPartialFrequency. It computes the number of the actual partial (as a floating point) for given f, f1, and B. This is an exact inverse function.
f | : Frequency of the n+th partial |
f1 | : Frequency of the first partial |
B | : Inharmonicity coefficient |
Definition at line 203 of file auditorypreprocessing.cpp.
void entropyminimizer::AuditoryPreprocessing::improveHighFrequencyPeaks | ( | ) |
Improve high-frequency spectral lines.
Depending on the microphone the high-frequency spectral lines above 5kHz are sometimes very weak.
Definition at line 384 of file auditorypreprocessing.cpp.
void entropyminimizer::AuditoryPreprocessing::initializeSPLAFilter | ( | ) |
Initialize the filter function in the vector mdBA.
Here we use ordinary dBA filtering. The empirical function is given by
\[ _A(f)= {12200^2\cdot f^4\over (f^2+20.6^2) \quad\sqrt{(f^2+107.7^2)\,(f^2+737.9^2)} \quad (f^2+12200^2)}\]
For the sake of efficiency the values according to the logarithmically binned spectra are stored in a vector mdBA.
Definition at line 279 of file auditorypreprocessing.cpp.
|
inlinestaticprivate |
void entropyminimizer::AuditoryPreprocessing::normalizeSpectrum | ( | Key & | key | ) |
Normalize spectrum.
This function normalizes the logarithmic power spectra in such a way that the sum over all components is equal to 1.
Definition at line 160 of file auditorypreprocessing.cpp.
|
private |
Definition at line 79 of file auditorypreprocessing.h.
|
private |
Definition at line 75 of file auditorypreprocessing.h.
|
private |
Definition at line 78 of file auditorypreprocessing.h.
|
private |
Definition at line 76 of file auditorypreprocessing.h.
|
private |
Definition at line 77 of file auditorypreprocessing.h.
|
private |
Definition at line 74 of file auditorypreprocessing.h.
const size_t entropyminimizer::AuditoryPreprocessing::NumberOfBins = Key::NumberOfBins |
Definition at line 49 of file auditorypreprocessing.h.