Programmer Guide/Command Reference/EVAL/hth: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 8: Line 8:


::{|
::{|
! ''type'' !! description !! [[1]]
! ''type'' !! description !! result
|-
|-
| 0 || hearing threshold in dB || || <pre>w[i] = 1</pre>
| 0 || hearing threshold in dB || L<sub>TH</sub>
|-
|-
| 1 || '''hanning'''  || not used || <code>whanning(''x''{,''scale''})</code>
| 1 || hearing threshold weighting factor || 10^(-L<sub>TH</sub> / 20)
| <pre>w[i] = 0.5 - 0.5 * cos( a*i )
with: a = 2 * pi / (n-1)</pre>
|-
|-
| 2 || '''hamming'''   || not used || <code>whamming(''x''{,''scale''})</code>
| 2 || value of the '''A''' weighting function in dB || L<sub>A</sub>
| <pre>w[i] = 0.54 - 0.46 * cos( a*i )
with: a = 2 * pi / (n-1)</pre>
|-
|-
| 3 || '''blackman''' || 0<''par''<=0.25<BR>default=0.16 || <code>wblackman(''x''{,''scale''{,''par''}})</code>
| 3 || '''A''' weighting value || 10^(-L<sub>A</sub> / 20)
| <pre>w[i] = (1-par)/2 - 0.5 * cos( a*i ) + par/2 * cos( 2*a*i )
with: a = 2 * pi / (n-1)</pre>
|-
|-
| 4 || '''kaiser''' || 0<''par''<BR>default=8 || <code>wkaiser(''x''{,''scale''{,''par''}})</code>
| 4 || value of the '''C''' weighting function in dB || L<sub>C</sub>
| <pre>w[i] = I0( par / m * sqrt(m^2 - (i-m)^2) ) / I0( par )
with: m = (n-1) / 2
      I0(z) is the modfied zero-order bessel function</pre>
|-
|-
| 5 || '''bartlett'''<BR>(triangle)  || not used || <code>wbartlett(''x''{,''scale''})</code>
| 5 || '''C''' weighting value || 10^(-L<sub>C</sub> / 20)
| <pre>0 <= i <= m:  w[i] = i / m
m <  i <  n: w[i] = 2 - i / m
with: m = (n-1) / 2</pre>
|-
| 6 || '''tappered rectangle'''  || not used || <code>wtaprect(''x''{,''scale''})</code>
| A rectangle with to short hanning slopes.
|-
| 7 || '''nuttall'''  || not used || <code>wnuttall(''x''{,''scale''})</code>
| A 4-term blackman-harris window with high dynamic range, low frequency resolution and minimized maximum sidelobes.<BR>Nuttall, Albert H. "Some Windows with Very Good Sidelobe Behavior." IEEE Transactions on Acoustics, Speech, and Signal Processing. Vol. ASSP-29 (February 1981). pp. 84-91
|-
| 8 || '''flat-top'''  || not used || <code>wflattop(''x''{,''scale''})</code>
|  A 5-term blackman-harris window with high dynamic range, low frequency resolution and minimized passband ripple (< 0.01dB). Flat-top windows are primarily used for calibration purposes.
|-
| 9 || '''gauss'''  || 0<''par''<= 20<BR>default=3 || <code>wgauss(''x''{,''scale''{,''par''}})</code>
| <pre>w[i] = exp( -0.5 * (par * (m - i) / m) ^ 2 )
with: m = (n-1) / 2</pre>
|-
|-
|}
|}
::For L<sub>TH</sub> the algorithm published by E.Terhardt (JASA 71(3), March 1982) is used:
:::<L><sub>TH</sub>(f) = 3.64 * f^-0.8 - 6.5 * exp(-0.6 * (f - 3.3)^2) + 1e-3 * f^4
:::(L<sub>TH</sub> in dB, f in kHz)


::Notes:
;See also: [[Programmer_Guide/Command_Reference/EVAL/fft|fft]], [[Programmer_Guide/Command_Reference/EVAL/window|window]]
::*If the argument ''type'' has an invalid value, the rectangle window is used.
::*If the energy-correction is enabled (argument ''scale''!=0), the values w[i] scaled by a factor that approximately equalises the energy loss caused by the window function. The scaling factor is computed using white noise as test signal.
::*If the argument ''par'' is supplied to a function not using this argument, it is ignored.


;Result: The result ''r'' depends on the argument ''x'':
:*x is a number: The value is used as window length ''n''. The result ''r'' is vector with length ''n'' containing the window function.
:*x is a vector or matrix: The number of rows of ''x'' is used as window length. Each column of ''x'' is multiplied with the window function (element-wise) and stored in a column of ''r''. The result ''r'' has the same type as ''x''.


Example:
<pre>
// compute the amplitude spectrum $#spe (in dBA) of the signal $#sig (fs=44.1kHz)


;See also: [[Programmer_Guide/Command_Reference/EVAL/fft|fft]], [[Programmer_Guide/Command_Reference/EVAL/hth|hth]], [[Programmer_Guide/Command_Reference/EVAL/wconvert|wconvert]]
// method 1:
// a) compute linear amplitde spectrum of signal $#sig
#spe := eval cr2len( fft( whanning( $#sig ) )
// b) compute the frequecies of the spectral bins
#frq := eval fill( $#spe[] , 0 , 44100 / 2 / ( $#spe[]-1 ) )
// c) apply A-weights and convert to log. amplitudes
$#spe := eval lin2log( $#spe ?* hth( $#frq , 3 ) )


[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
// method 2: all-in-one
#n := int npow2($#sig)
#spe := eval lin2log(cr2len(fft(whanning($#sig)))) - hth(fill($#n/2+1,0,44100/$#n),2)
</pre>




 
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]]
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
=====hth=====
 
Hearing Threshold Level (HTH) or A/C spectral weightings.
 
=====Usage:=====
 
<code>hth(<var>f</var>, <var>type</var>)</code>
 
;<var>f</var>
 
:The frequency (scalar, vector or matrix).
 
;<var>type</var>
 
:The type of weighting function. The following values are supported:
 
:<code>0</code> - Hearing threshold level
 
:<code>1</code> - Hearing threshold weighting factor
 
:<code>2</code> - A weighting levels.
 
:<code>3</code> - A weighting factors.
 
:<code>4</code> - C weighting levels.
 
:<code>5</code> - C weighting factors.
 
=====Notes:=====
 
Factor = 1 / (10^(Level/20))
 
=====Result:=====
 
The result of the requested function (same datatype as <var>f</var>).

Revision as of 12:03, 11 April 2011

Compute spectral weights.

Usage
hth(f, type)
f
A scalar, vector or matrix containing the frequency value(s) in Hz.
type
The type of the spectral weight to be computed.
Result
The result w has the same type as the argument f and contains the values of the spectral weighting function selected by type (w[i,j] = weight(f[i,j],type)).
type description result
0 hearing threshold in dB LTH
1 hearing threshold weighting factor 10^(-LTH / 20)
2 value of the A weighting function in dB LA
3 A weighting value 10^(-LA / 20)
4 value of the C weighting function in dB LC
5 C weighting value 10^(-LC / 20)
For LTH the algorithm published by E.Terhardt (JASA 71(3), March 1982) is used:
<L>TH(f) = 3.64 * f^-0.8 - 6.5 * exp(-0.6 * (f - 3.3)^2) + 1e-3 * f^4
(LTH in dB, f in kHz)
See also
fft, window


Example:

// compute the amplitude spectrum $#spe (in dBA) of the signal $#sig (fs=44.1kHz)

// method 1:
// a) compute linear amplitde spectrum of signal $#sig
#spe := eval cr2len( fft( whanning( $#sig ) )
// b) compute the frequecies of the spectral bins
#frq := eval fill( $#spe[] , 0 , 44100 / 2 / ( $#spe[]-1 ) )
// c) apply A-weights and convert to log. amplitudes
$#spe := eval lin2log( $#spe ?* hth( $#frq , 3 ) )

// method 2: all-in-one
#n := int npow2($#sig)
#spe := eval lin2log(cr2len(fft(whanning($#sig)))) - hth(fill($#n/2+1,0,44100/$#n),2)


<function list>

Navigation menu

Personal tools