scale_wvf
PURPOSE
[scaled] = scale_wvf(wvf,dB,nbits,is_wav);
SYNOPSIS
function [scaled] = scale_wvf(wvf,dB,nbits,is_wav)
DESCRIPTION
CROSS-REFERENCE INFORMATION
This function calls:
This function is called by:
SOURCE CODE
0001 function [scaled] = scale_wvf(wvf,dB,nbits,is_wav)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 try is_wav(1); catch is_wav = 0; end
0019
0020 try nbits(1); catch nbits = 16; end
0021
0022 max_dB = 20*log10(2^nbits);
0023 final_amp = 2^(nbits-1)/(10^((max_dB-dB)/20));
0024
0025
0026 wvf = detrend(wvf,0);
0027
0028
0029
0030 if all(max(abs(wvf))) <= 1
0031 IS_WAV = 1;
0032 wvf = wvf * 2^(nbits-1);
0033 end
0034
0035
0036 wvf_rms = sqrt(mean(wvf.^2));
0037
0038
0039 scale_factor = final_amp*sin(pi/4)./wvf_rms;
0040
0041
0042 scaled = wvf .* repmat(scale_factor,size(wvf,1),1);
0043
0044 if is_wav
0045 scaled = scaled ./ (2^(nbits-1));
0046 end
0047
0048 return
0049
Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003