Skip to content

Commit 3120fa3

Browse files
Code cleanup: Changed a few pointers to const pointers in FFT code
1 parent 6ac68db commit 3120fa3

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

src/FFT.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ inline int FastReverseBits(int i, int NumBits)
137137

138138
void FFT(int NumSamples,
139139
bool InverseTransform,
140-
float *RealIn, float *ImagIn, float *RealOut, float *ImagOut)
140+
const float *RealIn, const float *ImagIn,
141+
float *RealOut, float *ImagOut)
141142
{
142143
int NumBits; /* Number of bits needed to store indices */
143144
int i, j, k, n;
@@ -236,7 +237,7 @@ void FFT(int NumSamples,
236237
* This is merely a wrapper of RealFFTf() from RealFFTf.h.
237238
*/
238239

239-
void RealFFT(int NumSamples, float *RealIn, float *RealOut, float *ImagOut)
240+
void RealFFT(int NumSamples, const float *RealIn, float *RealOut, float *ImagOut)
240241
{
241242
int i;
242243
HFFT hFFT = GetFFT(NumSamples);
@@ -277,7 +278,8 @@ void RealFFT(int NumSamples, float *RealIn, float *RealOut, float *ImagOut)
277278
*
278279
* This is merely a wrapper of InverseRealFFTf() from RealFFTf.h.
279280
*/
280-
void InverseRealFFT(int NumSamples, float *RealIn, float *ImagIn, float *RealOut)
281+
void InverseRealFFT(int NumSamples, const float *RealIn, const float *ImagIn,
282+
float *RealOut)
281283
{
282284
int i;
283285
HFFT hFFT = GetFFT(NumSamples);
@@ -316,7 +318,7 @@ void InverseRealFFT(int NumSamples, float *RealIn, float *ImagIn, float *RealOut
316318
* of its code.
317319
*/
318320

319-
void PowerSpectrum(int NumSamples, float *In, float *Out)
321+
void PowerSpectrum(int NumSamples, const float *In, float *Out)
320322
{
321323
int i;
322324
HFFT hFFT = GetFFT(NumSamples);

src/FFT.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* input array, and that NumSamples must be a power of two.
6262
*/
6363

64-
void PowerSpectrum(int NumSamples, float *In, float *Out);
64+
void PowerSpectrum(int NumSamples, const float *In, float *Out);
6565

6666
/*
6767
* Computes an FFT when the input data is real but you still
@@ -71,15 +71,15 @@ void PowerSpectrum(int NumSamples, float *In, float *Out);
7171
*/
7272

7373
void RealFFT(int NumSamples,
74-
float *RealIn, float *RealOut, float *ImagOut);
74+
const float *RealIn, float *RealOut, float *ImagOut);
7575

7676
/*
7777
* Computes an Inverse FFT when the input data is conjugate symmetric
7878
* so the output is purely real. NumSamples must be a power of
7979
* two.
8080
*/
8181
void InverseRealFFT(int NumSamples,
82-
float *RealIn, float *ImagIn, float *RealOut);
82+
const float *RealIn, const float *ImagIn, float *RealOut);
8383

8484
/*
8585
* Computes a FFT of complex input and returns complex output.
@@ -89,7 +89,7 @@ void InverseRealFFT(int NumSamples,
8989

9090
void FFT(int NumSamples,
9191
bool InverseTransform,
92-
float *RealIn, float *ImagIn, float *RealOut, float *ImagOut);
92+
const float *RealIn, const float *ImagIn, float *RealOut, float *ImagOut);
9393

9494
/*
9595
* Multiply values in data by values of the chosen function

src/RealFFTf.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ void CleanupFFT()
191191
void RealFFTf(fft_type *buffer,HFFT h)
192192
{
193193
fft_type *A,*B;
194-
fft_type *sptr;
195-
fft_type *endptr1,*endptr2;
196-
int *br1,*br2;
194+
const fft_type *sptr;
195+
const fft_type *endptr1,*endptr2;
196+
const int *br1,*br2;
197197
fft_type HRplus,HRminus,HIplus,HIminus;
198198
fft_type v1,v2,sin,cos;
199199

@@ -293,9 +293,9 @@ void RealFFTf(fft_type *buffer,HFFT h)
293293
void InverseRealFFTf(fft_type *buffer,HFFT h)
294294
{
295295
fft_type *A,*B;
296-
fft_type *sptr;
297-
fft_type *endptr1,*endptr2;
298-
int *br1;
296+
const fft_type *sptr;
297+
const fft_type *endptr1,*endptr2;
298+
const int *br1;
299299
fft_type HRplus,HRminus,HIplus,HIminus;
300300
fft_type v1,v2,sin,cos;
301301

@@ -373,7 +373,8 @@ void InverseRealFFTf(fft_type *buffer,HFFT h)
373373
}
374374
}
375375

376-
void ReorderToFreq(HFFT hFFT, fft_type *buffer, fft_type *RealOut, fft_type *ImagOut)
376+
void ReorderToFreq(HFFT hFFT, const fft_type *buffer,
377+
fft_type *RealOut, fft_type *ImagOut)
377378
{
378379
// Copy the data into the real and imaginary outputs
379380
for(int i=1;i<hFFT->Points;i++) {
@@ -386,7 +387,7 @@ void ReorderToFreq(HFFT hFFT, fft_type *buffer, fft_type *RealOut, fft_type *Ima
386387
ImagOut[hFFT->Points] = 0;
387388
}
388389

389-
void ReorderToTime(HFFT hFFT, fft_type *buffer, fft_type *TimeOut)
390+
void ReorderToTime(HFFT hFFT, const fft_type *buffer, fft_type *TimeOut)
390391
{
391392
// Copy the data into the real outputs
392393
for(int i=0;i<hFFT->Points;i++) {

src/RealFFTf.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ void ReleaseFFT(HFFT);
2121
void CleanupFFT();
2222
void RealFFTf(fft_type *,HFFT);
2323
void InverseRealFFTf(fft_type *,HFFT);
24-
void ReorderToTime(HFFT hFFT, fft_type *buffer, fft_type *TimeOut);
25-
void ReorderToFreq(HFFT hFFT, fft_type *buffer, fft_type *RealOut, fft_type *ImagOut);
24+
void ReorderToTime(HFFT hFFT, const fft_type *buffer, fft_type *TimeOut);
25+
void ReorderToFreq(HFFT hFFT, const fft_type *buffer,
26+
fft_type *RealOut, fft_type *ImagOut);
2627

2728
#endif
2829

0 commit comments

Comments
 (0)