SAF
Loading...
Searching...
No Matches
afSTFT_internal.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2015 Juha Vilkamo
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
22
50#ifndef __afSTFTlib_INTERNAL_INCLUDED__
51#define __afSTFTlib_INTERNAL_INCLUDED__
52
53#ifdef __cplusplus
54extern "C" {
55#endif /* __cplusplus */
56
63#define AFSTFT_USE_SAF_UTILITIES
64#ifdef AFSTFT_USE_SAF_UTILITIES
66#include "saf_externals.h"
67#else
68# include <stdio.h>
69# include <stdlib.h>
70# include <string.h>
71#endif
72
73/* Coefficients for a half-band filter, i.e., the "hybrid filter" applied optionally at the bands 1--4. */
74#define COEFF1 0.031273141818515176604f
75#define COEFF2 0.28127313041521179171f
76#define COEFF3 0.5f
79/* ========================================================================== */
80/* Internal structures */
81/* ========================================================================== */
82
86typedef struct {
87 float *re;
88 float *im;
90
94typedef struct{
95 int inChannels;
96 int outChannels;
97 int hopSize;
98 int hLen;
99 int LDmode;
100 int hopIndexIn;
101 int hopIndexOut;
102 int totalHops;
103 float *protoFilter;
104 float *protoFilterI;
105 float **inBuffer;
106 float *fftProcessFrameTD;
107 float **outBuffer;
108#ifdef AFSTFT_USE_SAF_UTILITIES
109 void* hSafFFT;
110 float_complex *fftProcessFrameFD;
111 float* tempHopBuffer;
112#else
113 int pr;
114 int log2n;
115 void *vtFFT;
116 float *fftProcessFrameFD;
117#endif
118 void *h_afHybrid;
119 int hybridMode;
120
122
130typedef struct{
131 int inChannels;
132 int outChannels;
133 int hopSize;
134 float hybridCoeffs[3];
135 complexVector **analysisBuffer;
136 int loopPointer;
137} afHybrid;
138
139
140/* ========================================================================== */
141/* Internal functions */
142/* ========================================================================== */
143
158void afSTFTlib_init(void** handle,
159 int hopSize,
160 int inChannels,
161 int outChannels,
162 int LDmode,
163 int hybridMode);
164
168void afSTFTlib_channelChange(void* handle,
169 int new_inChannels,
170 int new_outChannels);
171
173void afSTFTlib_clearBuffers(void* handle);
174
176void afSTFTlib_forward(void* handle,
177 float** inTD,
178 complexVector* outFD);
179
181void afSTFTlib_inverse(void* handle,
182 complexVector* inFD,
183 float** outTD);
184
186void afSTFTlib_free(void* handle);
187
189void afHybridInit(void** handle,
190 int hopSize,
191 int inChannels,
192 int outChannels);
193
195void afHybridForward(void* handle,
196 complexVector* FD);
197
199void afHybridInverse(void* handle,
200 complexVector* FD);
201
203void afHybridFree(void* handle);
204
205
206#ifdef __cplusplus
207}/* extern "C" */
208#endif /* __cplusplus */
209
210#endif /* __afSTFTlib_INTERNAL_INCLUDED__ */
void afSTFTlib_channelChange(void *handle, int new_inChannels, int new_outChannels)
Re-allocates memory to support a change in the number of input/output channels.
void afSTFTlib_clearBuffers(void *handle)
Flushes time-domain buffers with zeros.
void afHybridForward(void *handle, complexVector *FD)
Forward hybrid-filtering transform.
void afHybridInverse(void *handle, complexVector *FD)
Inverse hybrid-filtering transform.
void afHybridInit(void **handle, int hopSize, int inChannels, int outChannels)
Creates and initialises an instance of the afHybrid filtering structure.
void afSTFTlib_forward(void *handle, float **inTD, complexVector *outFD)
Applies the forward afSTFT transform.
void afSTFTlib_inverse(void *handle, complexVector *inFD, float **outTD)
Applies the backward afSTFT transform.
void afSTFTlib_free(void *handle)
Destroys an instance of afSTFTlib.
void afSTFTlib_init(void **handle, int hopSize, int inChannels, int outChannels, int LDmode, int hybridMode)
Initialises an instance of afSTFTlib [1].
void afHybridFree(void *handle)
Frees an instnce of the afHybrid filtering structure.
Include header for SAF externals.
Main header for the utilities module (SAF_UTILITIES_MODULE)
Data structure for the hybrid filtering employed by afSTFTlib.
Main data structure for afSTFTlib.
Complex data type used by afSTFTlib.