MelAxis
- class ketos.audio.utils.axis.MelAxis(num_filters, freq_max, start_bin=0, bins=None, label=None)[source]
Mel-spectrogram axis.
- Args:
- num_filters: int
Number of filters
- freq_max: float
Maximum frequency in Hz
- start_bin: int
Start bin. Default is 0
- bins: int
Number of bins. If not specified, bins=num_filters
- label: str
Descriptive label. Optional
- Attributes:
- bins: int
Total number of bins
- x_min: float
Left edge of first bin
- freq_max: float
Maximum frequency in Hz
- label: str
Descriptive label
- start_bin: int
Minimum bin number
- num_filters: int
Number of filters
- resize_factor: float
Resizing factor.
Methods
bin
(x[, truncate, closed_right])Get bin number corresponding to a given value.
cut
([x_min, x_max, bins])Cut the axis by specifing either a minimum and a maximum value, or by specifying a minimum value and the axis length (as an integer number of bins).
low_edge
(b)Get the lower-edge value of a given bin.
resize
(bins)Resize the axis.
- bin(x, truncate=False, closed_right=False)[source]
Get bin number corresponding to a given value.
By default bins are closed on the left and open on the right, i.e., [a,b). Use the argument closed_right to reverse this.
If the value lies outside the axis range, a negative bin number or a bin number above N-1 will be returned. This behaviour can be changed using the argument ‘truncate’.
- Args:
- x: array-like
Value
- truncate: bool
Return 0 if x is below the lower axis boundary and N-1 if x is above the upper boundary. Default is False.
- closed_right: bool
If False, bin is closed on the left and open on the right. If True, bin is open on the left and closed on the right. Default is False.
- Returns:
- b: array-like
Bin number
- cut(x_min=None, x_max=None, bins=None)[source]
Cut the axis by specifing either a minimum and a maximum value, or by specifying a minimum value and the axis length (as an integer number of bins).
At both ends of the axis, the bins containing the cut values are included.
- Args:
- x_min: float
Position of lower cut. Defaults to the axis’ lower limit.
- x_max: float
Position of upper cut.
- bins: int
Cut length, given as a integer number of bins. When bins is specified, the argument x_max is ignored.
- Returns:
- b_min, b_max: int, int
Lower and upper bin number of the cut