⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_3_mu_a.m

📁 audio compression matlab code
💻 M
字号:
clc; clear; clf;

p = 'D:\adorel\a_master_DC\standard_test_audio\';
filename = 'Windows XP Startup.wav';

file = strcat(p,filename);
[I_all,fs,nbits, opts] = wavread(file);
I_all = (I_all(:,1) + I_all(:,2) )./2;

Ns = length(I_all);
I = I_all(1:Ns);
a = I;
t=(0:Ns-1).*(1/fs);

%1. Comparation among original and compressed signal..
mu=255; V = max(a); 
out = compand(a,mu,V, 'mu/compressor');
figure(1);
subplot(211), plot(t,a,t,out,'r');
title('original and mapped signal (red)');
n = [2000:1:2100];
subplot(212), plot(t(n),a(n),t(n),out(n),'r')
xlabel('time[s]'); title('Details in original and mapped signal (red)');


%2. plot the compression transfer characteristics..
x = -100:0.1:100; V = max(x); 
ymu = compand(x,mu, V, 'mu/compressor');
figure(2);
subplot(221), stairs(x,ymu); 
title('miu-law transfer characteristic');
xlabel('input'); ylabel('output');

A = 87.6;
yA = compand(x,A, V, 'A/compressor');
subplot(222), stairs(x,yA);
title('A-law transfer characteristic');
xlabel('input'); ylabel('output');

subplot(223), stairs(x, ymu); hold on; stairs( x, yA, 'r');
title('miu-law and A-law expander transfer characteristics');
xlabel('input'); ylabel('output');

subplot(224), stairs(x, ymu-yA);
title('The difference miu -law expander transfer characteristics');
xlabel('input'); ylabel('output');



%3. plot the expander transfer characteristics..
x= -100:0.1:100; 
V = max(x); 
ymuexp = compand(x, mu, V, 'mu/expander');
figure(3);
subplot(221), stairs(x, ymuexp); 
title('miu-law expander transfer characteristic');
xlabel('input'); ylabel('output');

yAexp = compand(x,A, V, 'A/expander');
subplot(222), stairs(x,yAexp);
title('A-law expander transfer characteristic');
xlabel('input'); ylabel('output');

subplot(223), stairs(x, ymuexp); hold on; stairs( x, yAexp, 'r');
title('miu-law and A-law transfer characteristic');
xlabel('input'); ylabel('output');

subplot(224), stairs(x,  yAexp -ymuexp);
title('The dfifference miu -law transfer characteristic');
xlabel('input'); ylabel('output');
% axis([-100 100 -5 5]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -