?? adc_1_differential.m
字號(hào):
clc; clear; clf;
% Audio lossless differential codding
% difficulties:
% 1). Audio samples have real values,
% in oposition with image samples (integers, in general)
p = 'D:\adorel\a_master_DATA_COMPRESS\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);
Ns = 0.8*1e5;
Ns = 1e3;
I = I_all(1:Ns);
% a = int16(I.* 2^15); % here is already a quantization..
t = (0:Ns-1)./fs;
% preprocessing..
xm = max(I); % the scalling factor (must be stored..!)
I1 = I ./ xm; % scale in [-1,1];
I2 = I1 .* 2^7; % map to [-127:127];
a = int8(I2);
a = double(a);
% compuite differencess ...
da(1) = a(1);
for i=2:length(a),
da(i) = a(i) - a(i-1);
end;
max_a = max(abs(a));
step = 1;
ta = [-max_a : step : max_a - step];
apdf = hist(a,ta);
subplot(221), plot(t,a); title('Original signal'); xlabel('t[s]');
subplot(223), plot(ta,apdf); title('probability distribution function');
max_da = max(abs(da));
tda = [- max_da : step : max_da] ;
dapdf = hist(da,tda);
subplot(222), plot(t,da); title('Succesive differences of the original signal');
xlabel('t[s]');
subplot(224), plot(tda, dapdf);
save data_input.mat t I a da dapdf xm;
% prepare the inputs for Huffman coding
S = tda;
% all "zero" elemets wil become "1" for the sake of generality..
dapdf_new = dapdf;
for i = 1 :length(dapdf_new),
if dapdf_new(i) == 0, dapdf_new(i) = 1; end;
end;
P = dapdf_new / sum(dapdf_new);
save SP.mat S P
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -