?? adc_1_differential_m6.m
字號:
clc; clear; clf;
% Audio lossless differential codding
% difficulties:
% 1). Audio samples have real values,
% in oposition with image samples (integers, in general)
% A solution is scalling to an integer interval, [-128:127], for example
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); % matlab6 syntax
I_all = (I_all(:,1) + I_all(:,2) )./2;
Ia1 = I_all .* 2^15;
Ia = int16(Ia1);
I_all = Ia; % int16 format;
Ns = length(I_all);
Ns = 1e3;
I = I_all(1:Ns);
% scale to [-1,1]:
y = double(I);
mx = max(abs(y));
a = y ./ mx;
% scale to [-128, 127];
a = a .* 128;
% compute differencess ...
da = zeros(1,length(a));
da(1) = a(1);
for i=2:length(a),
da(i) = a(i) - a(i-1);
end;
% da = int8(da);
% check properties ... (value distribution)
max_a = max(abs(a));
step = 1;
ta = [-max_a : step : max_a - step];
apdf = hist(a,ta);
t = (0:Ns-1)./fs;
subplot(221), plot(t,a); title('Original signal'); xlabel('t[s]');
subplot(223), plot(ta,apdf); title('Probability density function');
da = double(da);
max_da = max(abs(da));
tda = [- max_da : 1 : 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);
title('Probability density function');
da = int8(da);
save data_input.mat t I a da dapdf mx
% prepare the inputs for Huffman coding
S = [ceil(- max_da) : 1 : ceil(max_da)];
S = int8(S);
% 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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -