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

📄 adc_1_differential_1.m

📁 audio compression matlab code
💻 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,'native');  % int16 format...
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;

% linear compander
%function y = f_lin_compand(x, type, nbits_in, nbits_out)

y = f_lin_compand(double(I), 1, 10, 7);

a = double(y);
% compute differencess ...
da(1) = a(1);
for i=2:length(a),
    da(i) = a(i) - a(i-1);
end;

max_a = max(abs(a));
%max_a = 127;
step = 0.01;
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));
max_da = 128;
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);

save data_input.mat t I a da dapdf 


% 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

⌨️ 快捷键说明

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