Octave Module
Module for working with octaves.
The following is an example on how to use acoustic_toolbox.octave.Octave.
.. literalinclude:: ../../examples/example_octave.py
Attributes
frequency_of_band
module-attribute
frequency_of_band = exact_center_frequency
Calculate the center frequency for a given band index.
band_of_frequency
module-attribute
band_of_frequency = index_of_frequency
Calculate the band index for a given frequency.
Classes
Octave
Octave(
fraction=1,
interval=None,
fmin=None,
fmax=None,
unique: bool = False,
reference=REFERENCE_FREQUENCY,
)
Class to calculate octave center frequencies.
| ATTRIBUTE | DESCRIPTION |
|---|---|
reference |
Reference center frequency \(f_{c,0}\).
|
fraction |
Fraction of octave.
|
interval |
Interval.
|
fmin |
Minimum frequency of a range.
|
fmax |
Maximum frequency of a range.
|
unique |
Whether or not to calculate the requested values for every value of
|
reference |
Reference frequency.
|
| RAISES | DESCRIPTION |
|---|---|
AttributeError
|
If |
Source code in acoustic_toolbox/octave.py
Attributes
center
property
center: float
Return center frequency \(f_c\).
| RETURNS | DESCRIPTION |
|---|---|
float
|
Center frequency calculated as: $$ f_c = f_{ref} \cdot 2^{n/N} \cdot 10^{\frac{3}{10N}} $$ |
lower
property
lower: float
Lower frequency limits of bands.
| RETURNS | DESCRIPTION |
|---|---|
float
|
Lower frequency calculated as: $$ f_l = f_c \cdot 2^{\frac{-1}{2N}} $$ |
See also lower_frequency.
upper
property
Upper frequency limits of bands.
| RETURNS | DESCRIPTION |
|---|---|
float
|
Upper frequency calculated as: $$ f_u = f_c \cdot 2^{\frac{1}{2N}} $$ |
See Also
Functions
Functions
index_of_frequency
index_of_frequency(
frequency,
fraction=1,
ref=REFERENCE_FREQUENCY,
G=OCTAVE_FREQUENCY_RATIO,
) -> int | ndarray
Calculate the band index for a given frequency.
The index of the center frequency is given by
See equation 6 of the standard.
Note
This equation is not part of the standard.
However, it follows from exact_center_frequency.
| PARAMETER | DESCRIPTION |
|---|---|
frequency
|
Frequencies \(f\)
|
fraction
|
Bandwidth designator \(b\).
DEFAULT:
|
ref
|
Reference frequency.
DEFAULT:
|
G
|
Octave frequency ratio \(G\).
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
int | ndarray
|
Band indices \(x\) |
Source code in acoustic_toolbox/standards/iec_61260_1_2014.py
exact_center_frequency
exact_center_frequency(
frequency=None,
fraction=1,
n=None,
ref=REFERENCE_FREQUENCY,
)
Exact center frequency.
| PARAMETER | DESCRIPTION |
|---|---|
frequency
|
Frequency within the band.
DEFAULT:
|
fraction
|
Band designator.
DEFAULT:
|
n
|
Index of band.
DEFAULT:
|
ref
|
Reference frequency.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
|
Exact center frequency for the given frequency or band index. |
See Also
Source code in acoustic_toolbox/octave.py
nominal_center_frequency
Nominal center frequency.
Note
Contrary to the other functions this function silently assumes 1000 Hz reference frequency.
| PARAMETER | DESCRIPTION |
|---|---|
frequency
|
Frequency within the band.
DEFAULT:
|
fraction
|
Band designator.
DEFAULT:
|
n
|
Index of band.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
|
The nominal center frequency for the given frequency or band index. |
See Also
Source code in acoustic_toolbox/octave.py
lower_frequency
lower_frequency(
frequency=None,
fraction=1,
n=None,
ref=REFERENCE_FREQUENCY,
) -> float | ndarray
Lower band-edge frequency.
| PARAMETER | DESCRIPTION |
|---|---|
frequency
|
Frequency within the band.
DEFAULT:
|
fraction
|
Band designator.
DEFAULT:
|
n
|
Index of band.
DEFAULT:
|
ref
|
Reference frequency.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
float | ndarray
|
Lower band-edge frequency for the given frequency or band index. |
See Also
Source code in acoustic_toolbox/octave.py
upper_frequency
upper_frequency(
frequency=None,
fraction=1,
n=None,
ref=REFERENCE_FREQUENCY,
) -> float | ndarray
Upper band-edge frequency.
| PARAMETER | DESCRIPTION |
|---|---|
frequency
|
Frequency within the band.
DEFAULT:
|
fraction
|
Band designator.
DEFAULT:
|
n
|
Index of band.
DEFAULT:
|
ref
|
Reference frequency.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
float | ndarray
|
Upper band-edge frequency for the given frequency or band index. |
See Also
Source code in acoustic_toolbox/octave.py
:::