24 #ifndef SIGNALANALYZER_H
25 #define SIGNALANALYZER_H
31 #include "../system/simplethreadhandler.h"
32 #include "../messages/messagelistener.h"
33 #include "../audio/circularbuffer.h"
34 #include "../math/fftimplementation.h"
79 virtual void stop()
override;
103 virtual
void keyRecognized(
int keyIndex,
double frequency) override final;
131 #endif // SIGNALANALYZER_H
bool detectClipping(FFTWVector signal)
Clipping detector.
void changeRole(AnalyzerRole role)
Changes the current role of the signal analyzer.
std::shared_ptr< Message > MessagePtr
Global type of a shared message pointer.
std::mutex mKeyCountStatisticsMutex
Corresponding mutex.
int identifySelectedKey()
identify final key
Abstract adapter class for recording audio signals.
virtual void keyRecognized(int keyIndex, double frequency) overridefinal
static const int AUDIO_BUFFER_SIZE_IN_SECONDS
Maximal size of the audio buffer.
std::atomic< AnalyzerRole > mAnalyzerRole
void signalProcessing(FFTWVector &signal, int samplingrate)
Function for signal processing.
Performing rolling ffts in tuning mode.
AudioRecorderAdapter * mAudioRecorder
Pointer to the audio recorder.
void recordPostprocessing()
Process the singal after recording has finsihed.
Callback class for KeyRecognizer.
FFTDataPointer mPowerspectrum
the last recorded powerspectrum
std::map< double, double > FFTPolygon
Type for a frequency-to-intensity map for graphics.
void WriteFFT(std::string filename, const FFTWVector &fft)
static const int MINIMAL_FFT_INTERVAL_IN_MILLISECONDS
Time interval for at most one FFT.
std::mutex mDataBufferMutex
The data buffer might change its size during recording and key selection, lock it.
std::atomic< bool > mRecording
Flag indicating ongoing recording.
void handleMessage(MessagePtr m) overridefinal
Message receiver and dispatcer.
FFTAnalyzer mFFTAnalyser
Instance of the FFT analyzer.
bool mKeyForced
Is the key selection forced.
CircularBuffer< FFTWType > mDataBuffer
Local audio buffer.
std::map< int, int > mKeyCountStatistics
Count which key is selected how often.
void createPolygon(const FFTWVector &powerspec, FFTPolygon &poly) const
Create a polygon for drawing.
Template class for a circular buffer.
virtual void stop() override
Stop the thread.
KeyRecognizer mKeyRecognizer
Instance of the Key recognizer.
void updateDataBufferSize()
void analyzeSignal()
Analyze the final signal (in recording mode only)
FFT_Implementation mFFT
Instance of the Fourier transformer.
SignalAnalyzer(AudioRecorderAdapter *recorder)
Constructor of the SignalAnalyzer.
FFTRealType FFTWType
data type
void recordSignal()
Record signal and perform FFT's in regular intervals.
OverpullEstimator mOverpull
Instance of the overpull estimator.
void WriteSignal(std::string filename, const FFTWVector &signal)
FFTWVector mProprocessedSignal
the current signal (after preprocessing)
Module performing the final analysis of the Fourier transform.
Module for fast recognition of the pressed key.
void PerformFFT(FFTWVector &signal, FFTWVector &powerspec)
Perform fast Fourier transform.
Class for estimating the overpull needed in a pitch raise.
std::shared_ptr< FFTData > FFTDataPointer
Shared pointer of FFTData.
std::vector< FFTWType > FFTWVector
fftw array
Signal analyzer: Fourier transformation of the recorded audio signal.
double signalPreprocessing(FFTWVector &signal)
Function for signal preprocessing.
Recording a key stroke in recording operation mode.
int mSelectedKey
The selected key by the user.
const Piano * mPiano
Pointer to the piano.
void init()
Initializes the SignalAnalyzer and its components.
Thread-safe implementation of fftw3.
void workerFunction() overridefinal
Thread function of the SignalAnalyzer.