Programmer Guide/Command Reference/EVAL/hth: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
No edit summary |
No edit summary |
||
(6 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}} | {{DISPLAYTITLE:{{SUBPAGENAME}}}} | ||
Compute spectral weights. | Compute spectral weights. | ||
;Usage: <code>hth(<var>f</var>, <var>type</var>)</code> | ;Usage: <code>hth(<var>f</var>, <var>type</var>)</code> | ||
:;<var>f</var>:A scalar, vector or matrix containing the frequency value(s) in Hz. | :;<var>f</var>:A scalar, vector or matrix containing the frequency value(s) in Hz. | ||
;<var>type</var>:The type of the spectral weight to be computed. | :;<var>type</var>: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''. | |||
:<code>''w''[i,j] = '''weight'''(''f''[i,j],''type'')</code> | |||
:{| | |||
! ''type'' !! description !! | ! ''type'' !! description !! result | ||
|- | |- | ||
| | | 0 || hearing threshold in dB || L<sub>TH</sub> | ||
| < | |||
|- | |- | ||
| | | 1 || hearing threshold weighting factor || 10^(-L<sub>TH</sub> / 20) | ||
|- | |- | ||
| | | 2 || value of the '''A''' weighting function in dB || L<sub>A</sub> | ||
|- | |- | ||
| | | 3 || '''A''' weighting factor || 10^(-L<sub>A</sub> / 20) | ||
|- | |- | ||
| | | 4 || value of the '''C''' weighting function in dB || L<sub>C</sub> | ||
|- | |- | ||
| | | 5 || '''C''' weighting factor || 10^(-L<sub>C</sub> / 20) | ||
|- | |- | ||
|} | |} | ||
:For L<sub>TH</sub> the algorithm published by E.Terhardt (JASA 71(3), March 1982) is used: | |||
: | ::<code>L<sub>TH</sub>(f) = 3.64 * f^-0.8 - 6.5 * exp(-0.6 * (f - 3.3)^2) + 1e-3 * f^4</code> | ||
::<code>with: L<sub>TH</sub> = hearing threshold in dB, f = frequency in kHz</code> | |||
::* | ;See also: [[../fft|fft]], [[../window|window]] | ||
: | |||
;See also: [[ | |||
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] | [[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] | ||
Example: | |||
<pre> | |||
// 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) | |||
</pre> |
Latest revision as of 10:49, 21 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 factor 10^(-LA / 20) 4 value of the C weighting function in dB LC 5 C weighting factor 10^(-LC / 20)
- For LTH the algorithm published by E.Terhardt (JASA 71(3), March 1982) is used:
LTH(f) = 3.64 * f^-0.8 - 6.5 * exp(-0.6 * (f - 3.3)^2) + 1e-3 * f^4
with: LTH = hearing threshold in dB, f = frequency in kHz
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)