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
auditorypreprocessing.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 // Auditory preprocessing
22 //=============================================================================
23 
24 #ifndef AUDITORYPREPROCESSING_H
25 #define AUDITORYPREPROCESSING_H
26 
28 #include "core/system/log.h"
29 #include "core/piano/piano.h"
30 
31 namespace entropyminimizer
32 {
33 
40 
42 {
43 public:
46 
50 
51 public:
52 
53 
54  bool checkDataConsistency(); // check data consistency
55  void normalizeSpectrum(Key &key);
56  double getInharmonicPartial (double n,double f1,double B);
57  double getInharmonicPartialIndex (double f, double f1, double B);
58  void cleanSpectrum(Key &key); // reduce noise in the spectra
59  void cutLowFrequencies(Key &key); // cut irrelevant low and high frequ
60 
61  void initializeSPLAFilter(); // define dBA filtering curve
62  void convertToSPLA(SpectrumType &s); // compute A-weighted sound pressure
64 
67  void applyMollifier(Key &key);
68 
69 
70 private:
71  static double ftom (double f) { return Key::FrequencyToRealIndex(f); }
72  static double mtof (int m) { return Key::IndexToFrequency(m); }
73 
79  std::vector<double> mdBA; // vector holding dBA curve
80 
81 };
82 
83 } // namespace entropyminimizer
84 
85 #endif // AUDITORYPREPROCESSING_H
Class of functions for auditory preprocessing.
void extrapolateInharmonicity()
Extrapolate inharmonicity and estimate missing values.
Class describing the piano keyboard, holding a collection of keys.
Definition: keyboard.h:39
Class describing a single piano key.
Definition: key.h:45
static const int NumberOfBins
Total number of slots: 9 octaves.
Definition: key.h:50
void initializeSPLAFilter()
Initialize the filter function in the vector mdBA.
Definition: piano.h:40
double getInharmonicPartial(double n, double f1, double B)
Compute frequency of inharmonic partial.
static double IndexToFrequency(double m)
Convert continuous slot index to frequency in Hz.
Definition: key.cpp:102
AuditoryPreprocessing(Piano &piano)
Constructor.
void convertToSPLA(SpectrumType &s)
Compute A-weighted sound pressure level SPLA.
static double FrequencyToRealIndex(double f)
Convert frequency to real-valued logbin index.
Definition: key.cpp:70
Namespace for all entropy minimizer components.
bool checkDataConsistency()
Check consistency of the piano dataset.
std::vector< double > SpectrumType
Type of a log-binned spectrum.
Definition: key.h:54
double getInharmonicPartialIndex(double f, double f1, double B)
void improveHighFrequencyPeaks()
Improve high-frequency spectral lines.
void normalizeSpectrum(Key &key)
Normalize spectrum.
void convertToLoudness(SpectrumType &s)
void cutLowFrequencies(Key &key)
Cut all frequencies below 5/6*f1 in order to reduce noise.
std::vector< Key > Keys
Definition: keyboard.h:42
void cleanSpectrum(Key &key)
Clean logarithmically binned spectrum.