9.1数字信号处理算法的DSP实现 convoli函数实现线性卷积的算法 在实际应用中,参与卷积运算的两个序列 长度往往差距较大,比如我们要实时地对一长 序列语音信号进行“过滤”处理,可以采用有 限冲激响应序列与该语音信号进行分段卷积的 方法来实现。 比如:重叠保留法 >可用用圆周卷积计算线性卷积 6
9.1 数字信号处理算法的DSP实现 convol函数实现线性卷积的算法 6 在实际应用中,参与卷积运算的两个序列 长度往往差距较大,比如我们要实时地对一长 序列语音信号进行“过滤”处理,可以采用有 限冲激响应序列与该语音信号进行分段卷积的 方法来实现。 比如:重叠保留法 ➢可用用圆周卷积计算线性卷积
Circular Convolution as Linear Convolution with Aliasing is related to overlap-save method x(n] nr+nh-1=8 nr+nh-1 nr =5 h[可 nh 4 nh x3 [n=x n *h n nr+nh-1 nr+2nh-2 (a) N=nr+nh-1 xp[川=x[n]x[n] 圆周卷积有nr个值与线性卷积值相同 nh-1 nr+nh-1 10
10 nr nh 1 + − = 8 Circular Convolution as Linear Convolution with Aliasing is related to overlap-save method nr+nh-1 nh x n h n nh = 4 nr = 5 x n x n h n 3 = nr+2nh-2 nh-1 nr+nh-1 圆周卷积有nr个值与线性卷积值相同 N=nr+nh-1 x n x n 3 1 2 p = N x n nr+nh-1
h overlap-save method P点 input (1)segmentx(n)into sections of length L,overlap P-1 points; (2)fill 0 intoh(n)and some section of x(n),then do L points FFT 1P-1 L=25 points (③)calculate y(n) y(n)=IFFT(H(k)X(k) n=0,,L-1 P-1 vop[n] points P-1 (4)the output for this section is "points L-(P-1)points of y[n] L-(P-1),pQints n=P-1,.L-1 圆周卷积中后L-(P1)个点结果与线性卷积相等!
input 11 overlap-save method (4) the output for this section is L-(P-1) points of y[n] n=P-1,…L-1 (1) segment into sections of length L, overlap P-1 points; x(n) (2) fill 0 into and some section of , then do L points FFT h n( ) x n( ) y n IFFT H k X k ( ) { ( ) ( )} = (3) calculate y(n) n L = − 0,..., 1 L=25 圆周卷积中后L-(P-1)个点结果与线性卷积相等 P-1 points P-1 points P-1 points L L-(P-1) points P点
2.利用C54x自带的dsplib库函数实现卷积 DSPLIB库提供了一个直接进行线性卷积运算的函数, 形式如下:(见TMS320C54xDSP优化C函数库-用户指南) oflag short convol (DATA*x,DATA *h, DATA*r,ushort nr,ushort nh) 其中x,h为输入数组(长度nh),即进行卷积的两序列, r为输出(长度nr)。 nh 算法:r(j)=》h(k)x(j-k) k=0 通常将分段后待滤波数据放于x数组,而将滤波器系 数放于h数组。按圆周卷积,x长度nr+nh-1,h长度nh, 则r长度应为nr+nh-1。r前nh-1个值与线性卷积值不同, 舍弃后,r有效值长度为nr。 12
2. 利用C54x自带的dsplib库函数实现卷积 DSPLIB库提供了一个直接进行线性卷积运算的函数, 形式如下:(汇编文件见安装目录文件夹dsplib下54xdsp.src) oflag = short convol (DATA *x, DATA *h, DATA *r, ushort nr, ushort nh) 其中x, h为输入数组(长度nh), 即进行卷积的两序列, r为输出(长度nr)。 算法: 0 ( ) ( ) ( ) nh k r h x j k j k = = − 12 通常将分段后待滤波数据放于 x 数组,而将滤波器系 数放于h数组。按圆周卷积, x长度nr+nh-1,h长度nh, 则r长度应为nr+nh-1。r前nh-1个值与线性卷积值不同, 舍弃后, r有效值长度为nr 。 (见TMS320C54x DSP优化C函数库--用户指南)
2.利用C54x自带的dsplib库函数实现 convoli函数实现卷积的应用过程 #include“dsplib.h #define NH 3 川卷积核长度 #define NX 7 W输入矢量长度 main()l主函数 { short h[NH]={1000,3000,5000};/卷积核 short x[NX灯={0,0,2000,4000,6000,8000,10000};1∥输入矢量 short r[NR] /输出矢量 convol (x,h,r,NH,NR); /卷积计算 } 13
2.利用C54x自带的dsplib库函数实现 13 convol函数实现卷积的应用过程 #include “dsplib.h” #define NH 3 //卷积核长度 #define NX 7 //输入矢量长度 main( ) //主函数 { short h[NH]={1000,3000,5000} ; //卷积核 short x[NX]={0,0,2000,4000,6000,8000,10000} ; //输入矢量 short r[NR] ; //输出矢量 convol (x, h, r, NH, NR) ; //卷积计算 }