matlab enframe函数 C++实现

Matlab在语音处理中用到了enframe对语音信号进行分帧处理。

我在网上查看了一下enframe的一些相关信息:

y=enframe(x,framelength,step);

x为信号向量,可以为航向量或者列向量,

framelength是每一帧的长度,

step 是指一帧与一帧之间移动的样点数,有的称为非重叠的长度,

分得的帧数是:nf = fix((nx-framelength+step)/step),

其中nx 是x的长度,y是framelength*nf的数组或者nf*framelength的数组,其取决于x是行向量还是列向量。

//C++实现enframe分帧函数
//输入:
//float* x:信号源(行向量)
//int framelength:每一帧的长度
//int step:一帧与一帧之间移动的样点数,有的称为非重叠的长度
//
//输出:
//一个帧数*每一帧长度的二维数组



static
float** enframe(const float x[], int srclength, int framelength, int step) { int nf = floor((srclength - framelength + step) / step);//算出帧数 float** yenframe;//用来存放结果 yenframe = new float *[nf]; for (int i = 0; i < nf; i++) { yenframe[i] = new float[framelength]; } int count = 0; int startNo = 0; while (count < nf) { for (int i = 0; i < framelength; i++) { yenframe[count][i] = x[startNo + i]; } count++; startNo += step; } return yenframe; }

 

posted @ 2015-08-05 10:01  Jt_Gu  阅读(1502)  评论(0编辑  收藏  举报