SAF
Loading...
Searching...
No Matches
saf_utility_fft.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Leo McCormack
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
39#ifndef SAF_FFT_H_INCLUDED
40#define SAF_FFT_H_INCLUDED
41
42#ifdef __cplusplus
43extern "C" {
44#endif /* __cplusplus */
45
46#include "saf_utility_complex.h"
47
54
55/* ========================================================================== */
56/* Misc. Functions */
57/* ========================================================================== */
58
67void getUniformFreqVector(int fftSize,
68 float fs,
69 float* freqVector);
70
86void fftconv(float* x,
87 float* h,
88 int x_len,
89 int h_len,
90 int nCH,
91 float* y);
92
107void fftfilt(float* x,
108 float* h,
109 int x_len,
110 int h_len,
111 int nCH,
112 float* y);
113
128void hilbert(float_complex* x,
129 int x_len,
130 float_complex* y);
131
132
133/* ========================================================================== */
134/* Short-time Fourier Transform (STFT) */
135/* ========================================================================== */
136
150void saf_stft_create(void ** const phSTFT,
151 int winsize,
152 int hopsize,
153 int nCHin,
154 int nCHout,
155 SAF_STFT_FDDATA_FORMAT FDformat);
156
162void saf_stft_destroy(void ** const phSTFT);
163
172void saf_stft_forward(void * const hSTFT,
173 float** dataTD,
174 int framesize,
175 float_complex*** dataFD);
176
185void saf_stft_backward(void * const hSTFT,
186 float_complex*** dataFD,
187 int framesize,
188 float** dataTD);
189
195void saf_stft_flushBuffers(void * const hSTFT);
196
204void saf_stft_channelChange(void * const hSTFT,
205 int new_nCHin,
206 int new_nCHout);
207
208
209/* ========================================================================== */
210/* Real<->Half-Complex (Conjugate-Symmetric) FFT */
211/* ========================================================================== */
212
240void saf_rfft_create(void ** const phFFT,
241 int N);
242
248void saf_rfft_destroy(void ** const phFFT);
249
260void saf_rfft_forward(void * const hFFT,
261 float* inputTD,
262 float_complex* outputFD);
263
274void saf_rfft_backward(void * const hFFT,
275 float_complex* inputFD,
276 float* outputTD);
277
278
279/* ========================================================================== */
280/* Complex<->Complex FFT */
281/* ========================================================================== */
282
291void saf_fft_create(void ** const phFFT,
292 int N);
293
299void saf_fft_destroy(void ** const phFFT);
300
309void saf_fft_forward(void * const hFFT,
310 float_complex* inputTD,
311 float_complex* outputFD);
312
321void saf_fft_backward(void * const hFFT,
322 float_complex* inputFD,
323 float_complex* outputTD);
324
325
326#ifdef __cplusplus
327}/* extern "C" */
328#endif /* __cplusplus */
329
330#endif /* SAF_FFT_H_INCLUDED */
331
332 /* doxygen addtogroup Utilities */
void fftfilt(float *x, float *h, int x_len, int h_len, int nCH, float *y)
FFT-based convolution for FIR filters.
void saf_stft_backward(void *const hSTFT, float_complex ***dataFD, int framesize, float **dataTD)
Performs the backward-STFT operation for the current frame.
void saf_stft_forward(void *const hSTFT, float **dataTD, int framesize, float_complex ***dataFD)
Performs the forward-STFT operation for the current frame.
void fftconv(float *x, float *h, int x_len, int h_len, int nCH, float *y)
FFT-based convolution of signal 'x' with filter 'h'.
SAF_STFT_FDDATA_FORMAT
Options for how the frequency domain data is permuted when using saf_stft.
void saf_fft_backward(void *const hFFT, float_complex *inputFD, float_complex *outputTD)
Performs the backward-FFT operation; use for complex to complex transformations.
void saf_fft_create(void **const phFFT, int N)
Creates an instance of saf_fft; complex<->complex FFT.
void saf_stft_channelChange(void *const hSTFT, int new_nCHin, int new_nCHout)
Changes the number of input/output channels.
void hilbert(float_complex *x, int x_len, float_complex *y)
Computes the discrete-time analytic signal via the Hilbert transform [1].
void saf_rfft_create(void **const phFFT, int N)
Creates an instance of saf_rfft; real<->half-complex (conjugate-symmetric) FFT.
void saf_fft_forward(void *const hFFT, float_complex *inputTD, float_complex *outputFD)
Performs the forward-FFT operation; use for complex to complex transformations.
void saf_rfft_forward(void *const hFFT, float *inputTD, float_complex *outputFD)
Performs the forward-FFT operation; use for real to complex (conjugate symmetric) transformations.
void getUniformFreqVector(int fftSize, float fs, float *freqVector)
Calculates the frequencies (in Hz) of uniformly spaced bins, for a given FFT size and sampling rate.
void saf_rfft_backward(void *const hFFT, float_complex *inputFD, float *outputTD)
Performs the backward-FFT operation; use for complex (conjugate symmetric) to real transformations.
void saf_rfft_destroy(void **const phFFT)
Destroys an instance of saf_rfft.
void saf_stft_destroy(void **const phSTFT)
Destroys an instance of saf_stft.
void saf_stft_flushBuffers(void *const hSTFT)
Flushes the internal buffers with zeros.
void saf_fft_destroy(void **const phFFT)
Destroys an instance of saf_fft.
void saf_stft_create(void **const phSTFT, int winsize, int hopsize, int nCHin, int nCHout, SAF_STFT_FDDATA_FORMAT FDformat)
Creates an instance of saf_stft.
@ SAF_STFT_TIME_CH_BANDS
nTimeHops x nChannels x nBands
@ SAF_STFT_BANDS_CH_TIME
nBands x nChannels x nTimeHops
Contains wrappers for handling complex numbers across both C99-compliant compilers and Microsoft Visu...