模拟信号压缩与解压matlab.doc_第1页
模拟信号压缩与解压matlab.doc_第2页
模拟信号压缩与解压matlab.doc_第3页
模拟信号压缩与解压matlab.doc_第4页
模拟信号压缩与解压matlab.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

function y,g_out = expanderint16clip(x,fd,g_in,m)%expander% y = expanderint16clip(x,fd,g_in,m)%x - the input signal array%fd - the full deviated amplitude%g_in - the initial gain%m - update the expander gain every m samples%y - the expanded signal array%g_out - the output gain%companding specificationn% compression ratio 2:1% crossover point 60% of full audio deviation% attack time 3.3 ms% recovery time 14.85 ms%int16_scale = 32768;persistent ae ae_1 average counter mean old_x_array ae1 ae1_1 ae2 ae2_1 ae_diff ae_diff_1;%initializationif isempty(ae) ae1 = float2fract(0.99436); ae1_1 = 231 - fract2longfract(ae1); %float2longfract(1-0.99436); ae2 = float2fract(0.99985); ae2_1 = 231 - fract2longfract(ae2); %float2longfract(1-0.99985); ae_diff = float2fract(0.9995); ae_diff_1 = 231 - fract2longfract(ae_diff); counter = 0; average = 0; mean = 0; old_x_array = zeros(1,40);endue = fractmult(float2fract(0.6366),fd);ae = ae1;ae_1 = ae1_1;global mean_e_g average_e_g diff_e_g avg_dif_e_g ge_g flag_e_g avg_dif_float_e_g; %test onlyavg_dif = 0;avg_dif_float = 0; %test onlyoneforty = float2fract(1/40);temp1 = 0;temp2 = 0;scale_flag = 0;for i = 1:length(x) abstract = abs(x(i); temp1 = longlongfractmult(temp1,ae) + longlongfractmult(ae_1,abstract); %averager. divide 215 for fractional multiplication. average = longfract2fract(temp1); average_e_g(i) = average; %test only mean = mean - fractmult(oneforty,old_x_array(1) + fractmult(oneforty,abstract); %update mean mean_e_g(i)= mean; %test only if counter = 0 %update gain every m times g_in = average/ue; g_in_floor = floor(g_in); g_in_fract = float2fract(g_in - floor(g_in); counter = m; end ge_g(i) = g_in; %test only old_x_array(1:39) = old_x_array(2:40); old_x_array(40) = abs(x(i); difference = abs(mean-average); diff_e_g(i) = difference; %test only average_e_g(i) = average; %test only if difference fractmult(mean,float2fract(0.1) %0.1*mean avg_dif = fract2longfract(difference); %scale up 6 bits to prevent fix-point effect in calculating average difference avg_dif_float = difference; %test only ae = ae1; ae_1 = ae1_1; flag_e_g(i) = 0; %test only else avg_dif = longlongfractmult(ae_diff_1,difference) + longlongfractmult(avg_dif,ae_diff); avg_dif_float = difference + 0.9995*(avg_dif_float-difference); %test only if avg_dif = int16_scale - 1 temp = int16_scale - 1; end if temp fractmult(mean,float2fract(0.1) %0.1*mean avg_dif = fract2longfract(difference); %scale up 6 bits to prevent fix-point effect in calculating average difference avg_dif_float = difference; %test only ac = ac1; ac_1 = ac1_1; flag_g(i) = 0; %test only else avg_dif = longlongfractmult(ac_diff_1,difference) + longlongfractmult(avg_dif,ac_diff); avg_dif_float = difference + 0.9995*(avg_dif_float-difference); %test only if avg_dif

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论