ST - S-Transform/Stockwell Transform
- class audioflux.ST(radix2_exp=12, min_index=1, max_index=None, samplate=32000, factor=1.0, norm=1.0)
S-Transform (ST)
- Parameters
- radix2_exp: int
fft_length=2**radix2_exp
- min_index: int
Min bank index.
Available range: [1, max_index)
- max_index: int
Max bank index.
Available range: (min_index, fft_length/2)
- samplate: int
Sampling rate of the incoming audio
- factor: float
Factor value
- norm: float
Norm value
Examples
Read 880Hz audio data
>>> import audioflux as af >>> audio_path = af.utils.sample_path('880') >>> audio_arr, sr = af.read(audio_path) >>> # ST can only input fft_length data >>> # For radix2_exp=12, then fft_length=4096 >>> audio_arr = audio_arr[..., :4096]
Create ST object
>>> min_index, max_index = 1, 1024 # frequency is about 7.8125~8000Hz >>> obj = af.ST(radix2_exp=12, samplate=sr, min_index=min_index, max_index=max_index)
Extract spectrogram
>>> import numpy as np >>> spec_arr = obj.st(audio_arr) >>> spec_arr = np.abs(spec_arr)
Show spectrogram plot
>>> import matplotlib.pyplot as plt >>> from audioflux.display import fill_spec >>> fig, ax = plt.subplots() >>> img = fill_spec(spec_arr, axes=ax, >>> x_coords=obj.x_coords(), >>> y_coords=obj.y_coords(), >>> x_axis='time', y_axis='log', >>> title='ST Spectrogram') >>> fig.colorbar(img, ax=ax)
Methods
Get an array of ST frequency bands of different scales.
set_value
(factor, norm)Set value
st
(data_arr)Get spectrogram data
use_bin_arr
(bin_arr)Use bin arr
x_coords
()Get the X-axis coordinate
y_coords
()Get the Y-axis coordinate
- use_bin_arr(bin_arr)
Use bin arr
- Parameters
- bin_arr: np.ndarray [shape=(n,)]
- set_value(factor, norm)
Set value
- Parameters
- factor: float
Factor value
- norm: float
Norm value
- get_fre_band_arr()
Get an array of ST frequency bands of different scales.
- Returns
- out: np.ndarray [shape=(n_fre,)]
- st(data_arr)
Get spectrogram data
- Parameters
- data_arr: np.ndarray [shape=(…, 2**radix2_exp)]
Input audio data
- Returns
- out: np.ndarray [shape=(…, fre, time), dtype=np.complex]
- y_coords()
Get the Y-axis coordinate
- Returns
- out: np.ndarray
- x_coords()
Get the X-axis coordinate
- Returns
- out: np.ndarray