Data¶
-
class
untwist.data.
Signal
[source]¶ Time domain signal. Layout is one column per channel.
- samples: ndarray
- Signal data.
- sample_rate: int
- Sample rate in samples / second.
-
num_channels
¶ Number of channels
-
num_frames
¶ Number of frames (samples)
-
class
untwist.data.
Wave
(samples, sample_rate)[source]¶ Audio waveform signal.
- samples: ndarray
- Signal data.
- sample_rate: int
- Sample rate in samples / second.
-
duration
¶
-
play
(stop_func=None)[source]¶ Play the sound with the current audio driver.
- stop_func: function
- Function to execute when the sound ends.
-
classmethod
read
(filename)[source]¶ Read an audio file (only wav is supported).
- filename: string
- Path to the wav file.
-
class
untwist.data.
Spectrogram
[source]¶ Complex audio spectrogram matrix. Rows are frequency bins (0th is the lowest frequency), columns are time bins.
- samples: complex
- Spectrogram data.
- sample_rate: int
- Sample rate in samples / second of the original time domain signal.
- window_size: int
- Window size of the time-frequency transform used to obtain the spectrogram.
- hop_size: int
- Hop size of the time-frequency transform used to obtain the spectrogram.
-
magnitude_plot
(colormap='CMRmap', min_freq=0, max_freq=None, axes=None, label_x=True, label_y=True, title=None, colorbar=True, log_mag=True)[source]¶ Plot the magnitude spectrogram
- colormap: string
- Matplotlib colormap.
- min_freq: float
- minimum frequency in Hz (for labelling the axis).
- max_freq: float
- maximum frequency in Hz (for labelling the axis).
- axes: matplotlib axes object
- Axes object for plotting on existing figure.
- label_x: boolean
- Add labels to x axis.
- label_y: boolean
- Add labels to y axis.
- title: string
- Plot title (overlaid on image).
- colorbar: boolean
- Add a colorbar.
- log_mag: boolean
- Plot log magnitude.
-
num_channels
¶
-
num_frames
¶ Number of spectral frames.
-
class
untwist.data.
BinaryMask
[source]¶ Binary Mask based on a comparison between target and background. If the threshold is 0, the mask is 1 when the target magnitude is larger than the background, and 0 otherwise.
-
class
untwist.data.
RatioMask
[source]¶ Ratio Mask: soft mask based on ratio of target to background magnitude, with optional exponent p.
-
class
untwist.data.
Dataset
(x_width, x_type, y_width=0, y_type=<type 'numpy.int64'>)[source]¶ In-memory Dataset