function ret=Pascalize(S,L)
%
% ret=Pascalize2(S,L)
%
% Scales a signal S so that the average sound pressure level 
% corresponds to L dB.
% 
% This follows Meddis's rule: rms=1 -> 0 dB(SPL)
%
% This file is a part of HUTear- Matlab toolbox for auditory
% modeling. The toolbox is available at 
% http://www.acoustics.hut.fi/software/HUTear/

% Copyrights: Aki Härmä, Helsinki University of Technology, 
% Laboratory of Acoustics and Audio Signal Processing, 
% Espoo, Finland.
% Date: August 20 1999
% Email: Aki.Harma@hut.fi

e=energy(S)/length(S);
%b=10^(-1.5); 30 dB rule
b=1;         % 0 dB rule
rms1=S/sqrt(e); % RMS=1

c=b*10^(L/20);

ret=rms1*c;


