Frequency utilities¶
Provides frequency and fractional octave frequency bands functionalities.
@author: João Vitor Gutkoski Paes
-
ossom.utils.freq.
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
-
ossom.utils.freq.
fractional_octave_frequencies
(nthOct: int = 3, freqRange: Tuple[float] = (20.0, 20000.0), refFreq: float = 1000.0, base: int = 10) → numpy.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
-
ossom.utils.freq.
normalize_frequencies
(freqs: numpy.ndarray, samplingRate: int = 44100) → numpy.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
-
ossom.utils.freq.
freqs_to_center_and_edges
(freqs: numpy.ndarray) → Tuple[numpy.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.