1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-14 08:36:27 +01:00

Code cleanup: Changed a few pointers to const pointers in FFT code

This commit is contained in:
Raphaël Marinier
2016-06-25 20:36:00 +02:00
parent 6ac68db5be
commit 3120fa361e
4 changed files with 22 additions and 18 deletions

View File

@@ -137,7 +137,8 @@ inline int FastReverseBits(int i, int NumBits)
void FFT(int NumSamples, void FFT(int NumSamples,
bool InverseTransform, bool InverseTransform,
float *RealIn, float *ImagIn, float *RealOut, float *ImagOut) const float *RealIn, const float *ImagIn,
float *RealOut, float *ImagOut)
{ {
int NumBits; /* Number of bits needed to store indices */ int NumBits; /* Number of bits needed to store indices */
int i, j, k, n; int i, j, k, n;
@@ -236,7 +237,7 @@ void FFT(int NumSamples,
* This is merely a wrapper of RealFFTf() from RealFFTf.h. * This is merely a wrapper of RealFFTf() from RealFFTf.h.
*/ */
void RealFFT(int NumSamples, float *RealIn, float *RealOut, float *ImagOut) void RealFFT(int NumSamples, const float *RealIn, float *RealOut, float *ImagOut)
{ {
int i; int i;
HFFT hFFT = GetFFT(NumSamples); HFFT hFFT = GetFFT(NumSamples);
@@ -277,7 +278,8 @@ void RealFFT(int NumSamples, float *RealIn, float *RealOut, float *ImagOut)
* *
* This is merely a wrapper of InverseRealFFTf() from RealFFTf.h. * This is merely a wrapper of InverseRealFFTf() from RealFFTf.h.
*/ */
void InverseRealFFT(int NumSamples, float *RealIn, float *ImagIn, float *RealOut) void InverseRealFFT(int NumSamples, const float *RealIn, const float *ImagIn,
float *RealOut)
{ {
int i; int i;
HFFT hFFT = GetFFT(NumSamples); HFFT hFFT = GetFFT(NumSamples);
@@ -316,7 +318,7 @@ void InverseRealFFT(int NumSamples, float *RealIn, float *ImagIn, float *RealOut
* of its code. * of its code.
*/ */
void PowerSpectrum(int NumSamples, float *In, float *Out) void PowerSpectrum(int NumSamples, const float *In, float *Out)
{ {
int i; int i;
HFFT hFFT = GetFFT(NumSamples); HFFT hFFT = GetFFT(NumSamples);

View File

@@ -61,7 +61,7 @@
* input array, and that NumSamples must be a power of two. * input array, and that NumSamples must be a power of two.
*/ */
void PowerSpectrum(int NumSamples, float *In, float *Out); void PowerSpectrum(int NumSamples, const float *In, float *Out);
/* /*
* Computes an FFT when the input data is real but you still * Computes an FFT when the input data is real but you still
@@ -71,7 +71,7 @@ void PowerSpectrum(int NumSamples, float *In, float *Out);
*/ */
void RealFFT(int NumSamples, void RealFFT(int NumSamples,
float *RealIn, float *RealOut, float *ImagOut); const float *RealIn, float *RealOut, float *ImagOut);
/* /*
* Computes an Inverse FFT when the input data is conjugate symmetric * Computes an Inverse FFT when the input data is conjugate symmetric
@@ -79,7 +79,7 @@ void RealFFT(int NumSamples,
* two. * two.
*/ */
void InverseRealFFT(int NumSamples, void InverseRealFFT(int NumSamples,
float *RealIn, float *ImagIn, float *RealOut); const float *RealIn, const float *ImagIn, float *RealOut);
/* /*
* Computes a FFT of complex input and returns complex output. * Computes a FFT of complex input and returns complex output.
@@ -89,7 +89,7 @@ void InverseRealFFT(int NumSamples,
void FFT(int NumSamples, void FFT(int NumSamples,
bool InverseTransform, bool InverseTransform,
float *RealIn, float *ImagIn, float *RealOut, float *ImagOut); const float *RealIn, const float *ImagIn, float *RealOut, float *ImagOut);
/* /*
* Multiply values in data by values of the chosen function * Multiply values in data by values of the chosen function

View File

@@ -191,9 +191,9 @@ void CleanupFFT()
void RealFFTf(fft_type *buffer,HFFT h) void RealFFTf(fft_type *buffer,HFFT h)
{ {
fft_type *A,*B; fft_type *A,*B;
fft_type *sptr; const fft_type *sptr;
fft_type *endptr1,*endptr2; const fft_type *endptr1,*endptr2;
int *br1,*br2; const int *br1,*br2;
fft_type HRplus,HRminus,HIplus,HIminus; fft_type HRplus,HRminus,HIplus,HIminus;
fft_type v1,v2,sin,cos; fft_type v1,v2,sin,cos;
@@ -293,9 +293,9 @@ void RealFFTf(fft_type *buffer,HFFT h)
void InverseRealFFTf(fft_type *buffer,HFFT h) void InverseRealFFTf(fft_type *buffer,HFFT h)
{ {
fft_type *A,*B; fft_type *A,*B;
fft_type *sptr; const fft_type *sptr;
fft_type *endptr1,*endptr2; const fft_type *endptr1,*endptr2;
int *br1; const int *br1;
fft_type HRplus,HRminus,HIplus,HIminus; fft_type HRplus,HRminus,HIplus,HIminus;
fft_type v1,v2,sin,cos; fft_type v1,v2,sin,cos;
@@ -373,7 +373,8 @@ void InverseRealFFTf(fft_type *buffer,HFFT h)
} }
} }
void ReorderToFreq(HFFT hFFT, fft_type *buffer, fft_type *RealOut, fft_type *ImagOut) void ReorderToFreq(HFFT hFFT, const fft_type *buffer,
fft_type *RealOut, fft_type *ImagOut)
{ {
// Copy the data into the real and imaginary outputs // Copy the data into the real and imaginary outputs
for(int i=1;i<hFFT->Points;i++) { 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
ImagOut[hFFT->Points] = 0; ImagOut[hFFT->Points] = 0;
} }
void ReorderToTime(HFFT hFFT, fft_type *buffer, fft_type *TimeOut) void ReorderToTime(HFFT hFFT, const fft_type *buffer, fft_type *TimeOut)
{ {
// Copy the data into the real outputs // Copy the data into the real outputs
for(int i=0;i<hFFT->Points;i++) { for(int i=0;i<hFFT->Points;i++) {

View File

@@ -21,8 +21,9 @@ void ReleaseFFT(HFFT);
void CleanupFFT(); void CleanupFFT();
void RealFFTf(fft_type *,HFFT); void RealFFTf(fft_type *,HFFT);
void InverseRealFFTf(fft_type *,HFFT); void InverseRealFFTf(fft_type *,HFFT);
void ReorderToTime(HFFT hFFT, fft_type *buffer, fft_type *TimeOut); void ReorderToTime(HFFT hFFT, const fft_type *buffer, fft_type *TimeOut);
void ReorderToFreq(HFFT hFFT, fft_type *buffer, fft_type *RealOut, fft_type *ImagOut); void ReorderToFreq(HFFT hFFT, const fft_type *buffer,
fft_type *RealOut, fft_type *ImagOut);
#endif #endif