zl程序教程

您现在的位置是:首页 >  后端

当前栏目

【语音编码】基于matlab ADPCM编解码(Matlab代码实现)

MATLAB编码代码 实现 基于 语音 编解码
2023-09-14 09:14:29 时间

 👨‍🎓个人主页:研学社的博客 

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🌈3 Matlab代码+语音

🎉4 参考文献


💥1 概述

图1显示了ADPCM编码过程的框图。将线性输入样本X(n)与该输入X(n-l)的先前估计进行比较。差值d(n)以及当前步长ss(n)被提供给编码器逻辑。如下所述,该逻辑产生ADPCM输出样本。该输出样本还用于更新步长计算ss(n+l),并提供给解码器以计算输入样本的线性估计。

编码器接受来自比较器的差值d(n)和步长,并计算4位ADPCM码。

📚2 运行结果

🌈3 Matlab代码+语音

部分代码:

%Quantizer Adaptation variable Declarations
rlt1=0;
al1=0;
rlt2=0;
al2=0;
detl =32;
dec_detl = 32;   
deth = 8;
dec_deth = 8;
nbl = 0;
plt1 =0;
plt2 =0;
deth=0;
nbh =0;
ah1 =0;
ah2 =0;
ph1 =0;
ph2 =0;
rh1 =0;
rh2 = 0;

%Lo and Hi Band Decoder Variable Declarations 
dec_nbl = 0;
dec_al1 =0;
dec_al2 =0;
dec_plt1 =0;
dec_plt2 =0;
dec_rlt1 =0;
dec_rlt2 = 0;
dec_nbh =0;
dec_ah1 =0;
dec_ah2 =0;
dec_ph1 =0;
dec_ph2 =0;
dec_rh1 =0;
dec_rh2 = 0;
% signal input to the quantizer and predi
xl=0;
sl=0;
el=0;

prev_sample=0;

%samples to be encoded and decoded
NumOfSamples=1022;
%the pcm code this is a uniform pcm code 16 bits
m=pcm('dantaleabrr.wav',NumOfSamples);

% the first 
m=floor((m(23:end)));


 

 for i=1:length(m)
     t2=m(i);
     t1=floor(0.5*(t2+prev_sample));
     prev_sample=t2;
   [il,ih,tqmf,rlt1,rlt2,al1,al2,ah1,ah2,plt1,plt2,ph1,ph2,rh1,rh2,nbh,nbl,deth,detl,delay_bpl, delay_dltx,delay_bph,delay_dhx,el,sl,xl]=encode(t1,t2,tqmf,delay_bpl,delay_dltx,delay_bph,delay_dhx,rlt1,rlt2,rh1,rh2,al1,al2,ah1,ah2,plt1,plt2,ph1,ph2,nbh,nbl,detl,deth);
 encode_var(1,i)=il;
 encode_var(2,i)=ih;
 
%Here there arrays are for debuging

xls(1,i)=xl;
els(1,i)=el;
sls(1,i)=sl;
%%%%
 end;
 for i=1:length(m)
     il=encode_var(1,i);
     ih=encode_var(2,i);
 [xout1,xout2,accumc,accumd,dec_del_dltx,dec_del_bpl,dec_del_dhx,dec_del_bph,dec_al1,dec_al2,dec_ah1,dec_ah2,dec_plt1,dec_plt2,dec_ph1,dec_ph2,dec_rlt1,dec_rlt2,dec_detl,dec_nbl,dec_nbh,dec_deth]=decode(il,ih,accumc,accumd,dec_del_bpl,dec_del_dltx,dec_del_bph,dec_del_dhx,dec_rh1,dec_rh2,dec_rlt1,dec_rlt2,dec_al1,dec_al2,dec_ah1,dec_ah2,dec_plt1,dec_plt2,dec_ph1,dec_ph2,dec_detl,dec_nbl,dec_nbh,dec_deth);
 outputcode(i)=0.5*(xout1+xout2);
 end;
%%get figures
subplot(2,1,1); plot(m);
subplot(2,1,2); plot(outputcode);
 

🎉4 参考文献

部分理论来源于网络,如有侵权请联系删除。

 [1]周江,杨清学,梁桃华,孟奕峰.基于EPG3231的ADPCM解码算法实现[J].电子设计工程,2017,25(12):175-177+181.DOI:10.14022/j.cnki.dzsjgc.2017.12.041.