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
fftimplementation.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 // FFTW3 implementation for fast Fourier transformations
22 //=============================================================================
23 
24 #ifndef FFT_IMPLEMENTATION_H
25 #define FFT_IMPLEMENTATION_H
26 
27 #include "fftadapter.h"
28 
59 
60 #include <fftw3.h>
61 #include <mutex>
62 
63 #include "../system/prerequisites.h"
64 
65 
67 {
68 public:
69 
72 
73  void calculateFFT (const FFTRealVector &in, FFTComplexVector &out);
74  void calculateFFT (const FFTComplexVector &in, FFTRealVector &out);
75 
76  void optimize (FFTRealVector &in);
77  void optimize (FFTComplexVector &in);
78 
79 
80 private:
81 
82  // R and C mean: real and complex
83  // CR means: complex to real
84  // RC means: real to complex
85 
86  double *mRvec1;
87  double *mRvec2;
88  fftw_complex *mCvec1;
89  fftw_complex *mCvec2;
90  size_t mNRC;
91  size_t mNCR;
92 
93  fftw_plan mPlanRC;
94  fftw_plan mPlanCR;
95  static std::mutex mPlanMutex;
96 
97  void updatePlan (const FFTRealVector &in, unsigned flags);
98  void updatePlan (const FFTComplexVector &in, unsigned flags);
99 };
100 
101 #endif // FFT_IMPLEMENTATION_H
fftw_complex * mCvec2
Local copy of outgoing complex data.
size_t mNRC
Size of the FFT real -> complex.
size_t mNCR
Size of the FFT complex -> real.
std::vector< FFTComplexType > FFTComplexVector
Definition: fftadapter.h:36
fftw_plan mPlanRC
Plan for FFT real -> complex.
double * mRvec1
Local copy of incoming real data.
Abstract base class for handling fast Fourier transforms.
Definition: fftadapter.h:100
void updatePlan(const FFTRealVector &in, unsigned flags)
Construct a new plan for the FFT transformation if necessary.
~FFT_Implementation()
Destructor, deletes plans and local vector copies if existing.
fftw_plan mPlanCR
Plan for FFT complex -> real.
fftw_complex * mCvec1
Local copy of incoming complex data.
std::vector< FFTRealType > FFTRealVector
Definition: fftadapter.h:35
double * mRvec2
Local copy of outgoing real data.
void optimize(FFTRealVector &in)
Optimize plan for the forward transfomation.
void calculateFFT(const FFTRealVector &in, FFTComplexVector &out)
Foward FFT, mapping a real vector with size N to a complex one with size N/2+1.
FFT_Implementation()
Constructor, clears member variables and checks type consistency.
Thread-safe implementation of fftw3.
static std::mutex mPlanMutex
Static mutex protecting planmaking.