Frequency Scale Conversion¶
Convert between Hz and perceptual or musical frequency scales.
Perceptual scales¶
v_frq2mel
¶
V_FRQ2MEL - Convert Hertz to Mel frequency scale.
v_frq2mel
¶
Convert frequencies in Hz to the Mel scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frq
|
array_like
|
Frequencies in Hz. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
mel |
ndarray
|
Mel-scale values. mel(1000 Hz) = 1000. |
mr |
ndarray
|
Gradient in Hz/mel. |
Notes
The relationship is: m = ln(1 + f/700) * 1000 / ln(1 + 1000/700) This means that m(1000) = 1000.
References
[1] J. Makhoul and L. Cosell. "Lpcw: An lpc vocoder with linear predictive spectral warping", Proc IEEE ICASSP, 1976.
Source code in pyvoicebox/v_frq2mel.py
v_mel2frq
¶
V_MEL2FRQ - Convert Mel frequency scale to Hertz.
v_mel2frq
¶
Convert Mel-scale values to frequencies in Hz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mel
|
array_like
|
Mel-scale values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
frq |
ndarray
|
Frequencies in Hz. |
mr |
ndarray
|
Gradient in Hz/mel. |
Notes
The relationship is: m = ln(1 + f/700) * 1000 / ln(1 + 1000/700) This means that m(1000) = 1000.
References
[1] J. Makhoul and L. Cosell. "Lpcw: An lpc vocoder with linear predictive spectral warping", Proc IEEE ICASSP, 1976.
Source code in pyvoicebox/v_mel2frq.py
v_frq2bark
¶
V_FRQ2BARK - Convert Hertz to BARK frequency scale.
v_frq2bark
¶
Convert frequencies in Hz to the BARK scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
array_like
|
Frequencies in Hz. |
required |
m
|
str
|
Mode string with option characters: 'h' - use high frequency correction from Traunmuller (1990) 'l' - use low frequency correction from Traunmuller (1990) 'H' - do not apply any high frequency correction 'L' - do not apply any low frequency correction 'z' - use the expressions from Zwicker et al. (1980) 's' - use the expression from Schroeder et al. (1979) 'u' - unipolar version: do not force b to be an odd function |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
b |
ndarray
|
Bark-scale values. |
c |
ndarray
|
Critical bandwidth: d(freq)/d(bark). |
References
[1] H. Traunmuller, "Analytical Expressions for the Tonotopic Sensory Scale", J. Acoust. Soc. Am. 88, 1990, pp. 97-100. [2] E. Zwicker, "Subdivision of the audible frequency range into critical bands", J Acoust Soc Am 33, 1961, p248. [3] M. R. Schroeder, B. S. Atal, and J. L. Hall, 1979. [4] E. Zwicker and E. Terhardt, 1980.
Source code in pyvoicebox/v_frq2bark.py
v_bark2frq
¶
V_BARK2FRQ - Convert the BARK frequency scale to Hertz.
v_bark2frq
¶
Convert BARK-scale values to frequencies in Hz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
b
|
array_like
|
Bark-scale values. |
required |
m
|
str
|
Mode string with option characters: 'h' - use high frequency correction from Traunmuller (1990) 'l' - use low frequency correction from Traunmuller (1990) 'H' - do not apply any high frequency correction 'L' - do not apply any low frequency correction 's' - use the expression from Schroeder et al. (1979) 'u' - unipolar version: do not force result to be an odd function |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
f |
ndarray
|
Frequencies in Hz. |
c |
ndarray
|
Critical bandwidth: d(freq)/d(bark). |
References
[1] H. Traunmuller, "Analytical Expressions for the Tonotopic Sensory Scale", J. Acoust. Soc. Am. 88, 1990, pp. 97-100. [2] E. Zwicker, "Subdivision of the audible frequency range into critical bands", J Acoust Soc Am 33, 1961, p248. [3] M. R. Schroeder, B. S. Atal, and J. L. Hall, 1979.
Source code in pyvoicebox/v_bark2frq.py
v_frq2erb
¶
V_FRQ2ERB - Convert Hertz to ERB frequency scale.
v_frq2erb
¶
Convert frequencies in Hz to the ERB-rate scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frq
|
array_like
|
Frequencies in Hz. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
erb |
ndarray
|
ERB-rate scale values. |
bnd |
ndarray
|
ERB bandwidth in Hz. |
Notes
The ERB scale is measured using the notched-noise method. The Equivalent Rectangular Bandwidth is: df/de = 6.23f^2 + 93.39f + 28.52 (f in kHz)
References
[1] B.C.J. Moore & B.R. Glasberg, "Suggested formula for calculating auditory-filter bandwidth and excitation patterns", J. Acoust. Soc. Am., V74, pp 750-753, 1983.
Source code in pyvoicebox/v_frq2erb.py
v_erb2frq
¶
V_ERB2FRQ - Convert ERB frequency scale to Hertz.
v_erb2frq
¶
Convert ERB-rate scale values to frequencies in Hz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
erb
|
array_like
|
ERB-rate scale values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
frq |
ndarray
|
Frequencies in Hz. |
bnd |
ndarray
|
ERB bandwidth in Hz. |
Notes
ERB values are clipped to 43.032 which corresponds to infinite frequency.
References
[1] B.C.J. Moore & B.R. Glasberg, "Suggested formula for calculating auditory-filter bandwidth and excitation patterns", J. Acoust. Soc. Am., V74, pp 750-753, 1983.
Source code in pyvoicebox/v_erb2frq.py
Musical scales¶
v_frq2cent
¶
V_FRQ2CENT - Convert Hertz to Cents frequency scale.
v_frq2cent
¶
Convert frequencies in Hz to the cents scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frq
|
array_like
|
Frequencies in Hz. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
c |
ndarray
|
Cents scale values. 100 cents = one semitone. 440 Hz = 5700 cents. |
cr |
ndarray
|
Gradient in Hz/cent. |
Notes
c = 1200 * log2(f / (440 * 2^((3/12) - 5)))
References
[1] Ellis, A. "On the Musical Scales of Various Nations", Journal of the Society of Arts, 1885.
Source code in pyvoicebox/v_frq2cent.py
v_cent2frq
¶
V_CENT2FRQ - Convert Cents frequency scale to Hertz.
v_cent2frq
¶
Convert cents scale values to frequencies in Hz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
c
|
array_like
|
Cents scale values. 100 cents = one semitone. 440 Hz = 5700 cents. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
frq |
ndarray
|
Frequencies in Hz. |
cr |
ndarray
|
Gradient in Hz/cent. |
Notes
c = 1200 * log2(f / (440 * 2^((3/12) - 5)))
References
[1] Ellis, A. "On the Musical Scales of Various Nations", Journal of the Society of Arts, 1885.
Source code in pyvoicebox/v_cent2frq.py
v_frq2midi
¶
V_FRQ2MIDI - Convert frequencies to musical note numbers.
v_frq2midi
¶
Convert frequencies in Hz to MIDI note numbers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
array_like
|
Frequencies in Hz. Negative frequencies produce flats instead of sharps in the text representation. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
n |
ndarray
|
MIDI note numbers. Middle C is 60. Note 69 (A above middle C) = 440 Hz. Note numbers are not necessarily integers. |
t |
list of str
|
Text representation of the nearest note. E.g. 'C4 ' for middle C, 'C4#' for C sharp. For negative frequencies, flats are used: 'D4-'. |
Source code in pyvoicebox/v_frq2midi.py
v_midi2frq
¶
V_MIDI2FRQ - Convert musical note numbers to frequencies.
v_midi2frq
¶
Convert MIDI note numbers to frequencies in Hz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
array_like
|
MIDI note numbers. Middle C is 60. Note 69 = 440 Hz. |
required |
s
|
str
|
Scale type: 'e' - equal tempered (default) 'p' - Pythagorean scale 'j' - just intonation |
'e'
|
Returns:
| Name | Type | Description |
|---|---|---|
f |
ndarray
|
Frequencies in Hz. |