?? test_3_mu_a.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]);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -