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

📄 f_lin_compand.m

📁 audio compression matlab code
💻 M
字号:
function y = f_lin_compand(x, type, nbits_in, nbits_out)
% linear compander
% type == 1,    % compression; else extension;
% works on arrays..
% nbits, without the sign bit ...

% define the range
x_min = - 2^nbits_in  ;
x_max = + 2^nbits_in -1;
in_range =  x_max - x_min;

x_scale = x ./ (in_range / 2) ;

y_min = - 2^nbits_out  ;
y_max = + 2^nbits_out -1;
out_range =  y_max - y_min;


if type == 1,    % compression;
    if nbits_in < nbits_out,  disp('error 1'); end;
    y = (out_range / in_range) .* x_scale;    
else % extension
    if nbits_in > nbits_out,  disp('error 2'); end;
    y = (in_range / out_range) .* x_scale;    
end;

⌨️ 快捷键说明

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