function y = expander(x,th,ratio) % expander --> Used to expand the dynamic range of a signal. % % % y = expander(x,th,ratio) % % % The function expand the dynamic range of the input % signal x by using a technique opposite to the compressor. % The threshold th is the signal level at which the gain % is increased and ratio is the amount of amplification % that takes place past the threshold. % % % compressor --> Used to compress the dynamic range of a signal. % % Peter S.K. Hansen, IMM, Technical University of Denmark % % Last revised: February 7, 2000 %----------------------------------------------------------------------- % Check the required input arguments. if (nargin < 3) error('Not enough input arguments.') end % First, apply normal unity gain. y = x; % Find sequence values larger than the threshold level. idx = find(abs(x)>th); % Apply the ratio-to-1 expansion for levels above the threshold. y(idx) = ((abs(x(idx))-th)*ratio + th).*sign(x(idx)); %----------------------------------------------------------------------- % End of function expander %-----------------------------------------------------------------------