gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
RealFFT.C
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16 */
17 #include "fft/RealFFT.H"
18 
19 void RealFFT::createPlan(void) {
20  if (data) {
21  //fftw3
22  fwdPlan=fftw_plan_r2r_1d(data->getSize(), data->in, data->out, FFTW_R2HC, PLANTYPE);
23  invPlan=fftw_plan_r2r_1d(data->getSize(), data->out, data->in, FFTW_HC2R, PLANTYPE);
24  }
25 }
26 
28  if (data) {
29  fftw_destroy_plan(fwdPlan);
30  fftw_destroy_plan(invPlan);
31  }
32 }
33 
35  data=NULL;
36  createPlan();
37 }
38 
40  // cout <<"RealFFT init:"<<this<<std::endl;
41  data=d;
42  createPlan();
43 }
44 
46  destroyPlan();
47 }
48 
50  destroyPlan();
51  data=d;
52  createPlan();
53 }
54 
56  switchData(&d);
57 }
58 
60  if (!data)
61  printf("RealFFT::fwdTransform : data not present, please switch data");
62  else
63  fftw_execute(fwdPlan);
64 }
65 
67  if (!data)
68  printf("RealFFT::invTransform : data not present, please switch data");
69  else
70  fftw_execute(invPlan);
71 }
72 
73 #include "config.h"
74 #ifdef HAVE_EMSCRIPTEN
75 #include <emscripten/bind.h>
76 EMSCRIPTEN_BINDINGS(RealFFT_ex) {
77 emscripten::class_<RealFFT>("RealFFT")
78  .constructor() // empty constructor - requires switchData to be called
79  .constructor<RealFFTData*>() // the constructor takes in a data class
80  .function("switchData", emscripten::select_overload<void(RealFFTData&)>(&RealFFT::switchData))
81  .function("fwdTransform", &RealFFT::fwdTransform)
82  .function("invTransform", &RealFFT::invTransform);
83 }
84 #endif
void createPlan(void)
Method to create the plans.
Definition: RealFFT.C:19
fftw_plan invPlan
Definition: RealFFT.H:26
#define PLANTYPE
Definition: FFTCommon.H:20
void invTransform()
Inverse transform the data (out to in)
Definition: RealFFT.C:66
int getSize(void)
Returns the number of elements in the input and output arrays.
Definition: RealFFTData.H:48
fftw_plan fwdPlan
The fwd/inv plans.
Definition: RealFFT.H:26
RealFFTData * data
The pointer to the relevant data.
Definition: RealFFT.H:36
virtual ~RealFFT(void)
fft deconstructor
Definition: RealFFT.C:45
class RealFFTData controls and manipulates fft data
Definition: RealFFTData.H:24
void fwdTransform()
Forward transform the data (in to out)
Definition: RealFFT.C:59
fftw_real * out
Definition: RealFFTData.H:33
fftw_real * in
the input, output and power_spectrum arrays
Definition: RealFFTData.H:33
RealFFT(void)
fft init ... don&#39;t forget to associate data using switchData
Definition: RealFFT.C:34
void switchData(RealFFTData *d)
Use this to change associated fft data (for fft&#39;ing)
Definition: RealFFT.C:49
void destroyPlan(void)
Method to destroy the plans.
Definition: RealFFT.C:27
gtkIOStream: /tmp/gtkiostream/src/RealFFT.C Source File
GTK+ IOStream  Beta