Frequency utilities¶
This utility provides frequency and fractional octave frequency bands functionalities.
For syntax purposes you should start with:
>>> from pytta import utils as utils
Available functions:
>>> utils.freq_to_band(freq, nthOct, ref, base)
>>> utils.fractional_octave_frequencies(nthOct = 3, freqRange = (20., 20000.), refFreq = 1000., base = 10)
>>> utils.normalize_frequencies(freqs, samplingRate = 44100)
>>> utils.freqs_to_center_and_edges(freqs)
>>> utils.filter_values(freq, values, nthOct = 3)
For further information, check the docstrings for each function mentioned above.
- Authors:
João Vitor G. Paes joao.paes@eac.ufsm.br and Caroline Gaudeoso caroline.gaudeoso@eac.ufsm.br Rinaldi Petrolli rinaldi.petrolli@eac.ufsm.br
- pytta.utils.freq_to_band(freq: float, nthOct: int, ref: float, base: int) int [source]¶
Band number from frequency value.
- Parameters:
freq (float) – The frequency value.
nthOct (int) – How many bands per octave.
ref (float) – Frequency of reference, or band number 0.
base (int) – Either 10 or 2.
- Raises:
ValueError – If base is not 10 nor 2 raises value error.
- Returns:
The band number from center.
- Return type:
int
- pytta.utils.fractional_octave_frequencies(nthOct: int = 3, freqRange: Tuple[float] = (20.0, 20000.0), refFreq: float = 1000.0, base: int = 10) ndarray [source]¶
Lower, center and upper frequency values of all bands within range.
- Parameters:
nthOct (int, optional) – bands of octave/nthOct. The default is 3.
freqRange (Tuple[float], optional) – frequency range. These frequencies are inside the lower and higher band, respectively. The default is (20., 20000.).
refFreq (float, optional) – Center frequency of center band. The default is 1000..
base (int, optional) – Either 10 or 2. The default is 10.
- Returns:
freqs – Array with shape (N, 3).
- Return type:
numpy.ndarray
- pytta.utils.normalize_frequencies(freqs: ndarray, samplingRate: int = 44100) ndarray [source]¶
Normalize frequencies for any sampling rate.
- Parameters:
freqs (np.ndarray) – DESCRIPTION.
samplingRate (int, optional) – DESCRIPTION. The default is 44100.
- Returns:
DESCRIPTION.
- Return type:
TYPE
- pytta.utils.freqs_to_center_and_edges(freqs: ndarray) Tuple[ndarray] [source]¶
Separate the array returned from fractional_octave_frequencies.
The returned arrays corresponde to the center and edge frequencies of the fractional octave bands
- Parameters:
freqs (np.ndarray) – Array returned from fractional_octave_frequencies.
- Returns:
center (np.ndarray) – Center frequencies of the bands.
edges (np.ndarray) – Edge frequencies (lower and upper) of the bands.