[ba1662]: mex / comp_atrousfilterbank_td.c Maximize Restore History

Download this file

comp_atrousfilterbank_td.c    82 lines (70 with data), 2.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef _LTFAT_MEX_FILE
#define _LTFAT_MEX_FILE
#define NARGINEQ 4
#define TYPEDEPARGS 0, 1
#define SINGLEARGS
#define COMPLEXINDEPENDENT
#endif /* _LTFAT_MEX_FILE */
#if defined(__GNUC__) || defined(__ICC)
#define MEX_FILE __BASE_FILE__
//#else
//#define MEX_FILE "comp_ifilterbank_td.c"
#endif
#include "ltfat_mex_template_helper.h"
#if defined(LTFAT_SINGLE) || defined(LTFAT_DOUBLE)
#include "mex.h"
#include "math.h"
#include "ltfat.h"
#include "ltfat_types.h"
/*
%COMP_ATROUSFILTERBANK_TD Uniform filterbank by conv2
% Usage: c=comp_atrousfilterbank_td(f,g,a,offset);
%
% Input parameters:
% f : Input data - L*W array.
% g : Filterbank filters - filtLen*M array.
% a : Filter upsampling factor - scalar.
% offset: Delay of the filters - scalar or array of length M.
%
% Output parameters:
% c : L*M*W array of coefficients
%
*/
void LTFAT_NAME(ltfatMexFnc)( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
const mxArray* mxf = prhs[0];
const mxArray* mxg = prhs[1];
double* aDouble = mxGetPr(prhs[2]);
double* offsetDouble = mxGetPr(prhs[3]);
// input data length
mwSize L = mxGetM(mxf);
// number of channels
mwSize W = mxGetN(mxf);
// filter number
mwSize M = mxGetN(mxg);
// filter length
mwSize filtLen = mxGetM(mxg);
// POINTER TO THE INPUT
LTFAT_TYPE* fPtr = mxGetData(prhs[0]);
// POINTER TO THE FILTERS
const LTFAT_TYPE* gPtrs[M];
ltfatInt offset[M];
ltfatInt a[M];
ltfatInt filtLens[M];
for(mwSize m=0; m<M; m++)
{
filtLens[m] = filtLen;
a[m] = *aDouble;
offset[m] = offsetDouble[m];
gPtrs[m] = ((LTFAT_TYPE*) mxGetData(mxg)) + m*filtLen;
}
mwSize ndim = 3;
mwSize dims[]= {L, M, W};
plhs[0] = ltfatCreateNdimArray(ndim,dims,
LTFAT_MX_CLASSID,LTFAT_MX_COMPLEXITY);
LTFAT_TYPE* cPtr = mxGetData(plhs[0]);
LTFAT_NAME(atrousfilterbank_td)(fPtr, gPtrs, L, filtLens,
W, a, offset, M, cPtr, PER);
}
#endif /* LTFAT_DOUBLE or LTFAT_SINGLE */