-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresample.cpp
More file actions
26 lines (19 loc) · 805 Bytes
/
Copy pathresample.cpp
File metadata and controls
26 lines (19 loc) · 805 Bytes
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
#include "mex.h"
#include "libresamp.h"
//TODO: Document this function
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
//TODO: Make a better error message
if (nrhs != 3 || nlhs > 1) {
mexErrMsgTxt("Wrong number of arguments");
}
double* signal = (double*)mxGetData(prhs[0]);
unsigned length = (unsigned)mxGetDimensions(prhs[0])[0];
unsigned channels = (unsigned)mxGetDimensions(prhs[0])[1];
double resamplingFactor = mxGetScalar(prhs[1]);
unsigned sampleRadius = (unsigned)mxGetScalar(prhs[2]);
double* resampledSignal = resample(signal, &length, channels, resamplingFactor, sampleRadius);
mwSize outputSize[] = {(mwSize)(length), channels};
plhs[0] = mxCreateNumericArray(2, outputSize, mxDOUBLE_CLASS, mxREAL);
mxSetData(plhs[0], resampledSignal);
}