void enframe() { static uint16_t frame_num = 0; if(cbuffer.count < FRAME_SIZE) return; //nothing to do float32_t fdata[FFT_SIZE] = {0}; if(frame_num >= NUM_FRAME) post_process(); uint16_t i; uint16_t head_length = MAX_BUF_SIZE-cbuffer.header; if(head_length < MIN2(FRAME_SIZE,FFT_SIZE))//complex case { for(i = 0; i < head_length; i++) fdata[i] = Hamming[i]*cbuffer.data[cbuffer.header+i]; for(i = 0; i < MIN2(FRAME_SIZE,FFT_SIZE)-head_length; i++) fdata[head_length+i] = Hamming[head_length+i]*cbuffer.data[i]; } else //simple case for(i = 0; i < MIN2(FRAME_SIZE,FFT_SIZE); ++i) //SIMD not available fdata[i] = Hamming[i]*cbuffer.data[cbuffer.header+i]; #if(FFT_SIZE > FRAME_SIZE) memset(fdata+FRAME_SIZE, 0, (FFT_SIZE-FRAME_SIZE+1)*sizeof(float32_t));//zero padding #endif cbuffer.count -= FRAME_SHIFT; //counter modification cbuffer.header += FRAME_SHIFT; if(cbuffer.header >= MAX_BUF_SIZE) cbuffer.header -= MAX_BUF_SIZE; mfcc(fdata, feature_vec[frame_num]); post_proc_callback(&feature_vec[0][0], frame_num); frame_num++; }
void mfcc_api(const mxArray *prhs[1], const mxArray *plhs[1]) { emxArray_real_T *samples; emxArray_real_T *cepstra; emlrtStack st = { NULL, NULL, NULL }; st.tls = emlrtRootTLSGlobal; emlrtHeapReferenceStackEnterFcnR2012b(&st); emxInit_real_T(&st, &samples, 1, true); b_emxInit_real_T(&st, &cepstra, 2, true); prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1); /* Marshall function inputs */ emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "samples", samples); /* Invoke the target function */ mfcc(samples, cepstra); /* Marshall function outputs */ plhs[0] = h_emlrt_marshallOut(cepstra); cepstra->canFreeData = false; emxFree_real_T(&cepstra); samples->canFreeData = false; emxFree_real_T(&samples); emlrtHeapReferenceStackLeaveFcnR2012b(&st); }