Datasets¶
Dataset wrapper for combining multiple other datasets.
- class libdamp.datasets.combined.CombinedDataset(datasets: list[Dataset] = [], shuffle_items: bool = True)[source]¶
Bases:
DatasetDataset wrapper for combining multiple existing datasets
- class libdamp.datasets.combined.ZipDataset(datasets: list[Dataset] = [], shuffle_items: bool = True)[source]¶
Bases:
DatasetDataset wrapper for retrieving items from multiple datasets simultaneously (like Python zip)
Dataset wrapper for prepared excerpts.
- class libdamp.datasets.excerpts.ExcerptsDataset(path: str, ds_split: str = 'train', return_keys: list = ['signal'])[source]¶
Bases:
DatasetGeneric dataset wrapper for prepared excerpts of data stored as .npy files.
The dataset expects path to be a directory containing one .npy file per quantity of interest, named [key]_[ds_split].npy, where [key] is the name of the quantity (e.g. signal, f0, or any other custom key) and [ds_split] is the dataset split (e.g. train, val, test). Each file must contain an array whose first axis indexes the excerpts, so that all requested files have the same length (i.e. the same number of excerpts) for a given split. For example, for return_keys=[“signal”, “f0”] and ds_split=”train”, path must contain the files:
path/ signal_train.npy # shape (excerpts, ...) f0_train.npy # shape (excerpts, ...)
Every requested key is loaded verbatim from its corresponding file. This means an arbitrary number of precomputed quantities can be made available to the dataset, as long as they follow this naming convention and are stored as one array per split with excerpts along the first axis.
- class libdamp.datasets.excerpts.SignalF0ExcerptsDataset(path: str, num_harm: int = 100, num_frames: int = 128, fs: float = 16000.0, ds_split: str = 'train', return_keys: list = ['f', 'a'])[source]¶
Bases:
ExcerptsDatasetDataset wrapper for prepared excerpts of signal/F0 data stored as .npy files.
This is a specialization of
ExcerptsDatasetfor the common case of audio signals paired with F0 trajectories. In addition to the files required for any plain return_keys (see ExcerptsDataset), it always requires path to contain a signal_[ds_split].npy file, and, if “f0”, “f”, or “a” is among return_keys, also a f0_[ds_split].npy file:path/ signal_train.npy # shape (excerpts, 1, samples) f0_train.npy # shape (excerpts, frames) ...
The two special return keys “f” and “a” are not loaded from disk. Instead, they are derived on the fly from the F0 trajectory (loaded from f0_[ds_split].npy) and the corresponding audio signal (loaded from signal_[ds_split].npy): the frequencies of the first M harmonics of F0 (“f”) and their amplitudes (“a”) are determined via spectral peak picking, i.e. by computing the STFT of the signal and interpolating its magnitude at the harmonic frequencies.
Dataset wrapper for MDB-[stem|melody]-synth (http://synthdatasets.weebly.com/)
- class libdamp.datasets.medleydb.MDBSynthDataset(audio_path: str, annot_path: str, target_fs: float, return_keys: list = [])[source]¶
Bases:
DatasetDataset wrapper for MDB-[stem|melody]-synth (http://synthdatasets.weebly.com/)
Dataset wrapper for NSynth (https://magenta.tensorflow.org/datasets/nsynth)
- class libdamp.datasets.nsynth.NSynthDataset(path: str, target_fs: float, return_keys: list = [])[source]¶
Bases:
DatasetDataset wrapper for NSynth (https://magenta.tensorflow.org/datasets/nsynth)
Dataset wrapper for previously extracted F0/FC/Gain tracks for the PULSE-IT method.
- class libdamp.datasets.pulseit.PulseItDataset(path: str, selection: str = '.*', num_excerpts: int = 1000, frame_len: int = 256, num_frames: int = 256, random_seed: int | None = None)[source]¶
Bases:
DatasetDataset for F0/FC/Gain tracks for the PULSE-IT method.
Collection of synthetic datasets.
This module is part of the libdamp package.
- class libdamp.datasets.synthetic.SyntheticSinusoidsDataset(num_excerpts: int, len_excerpt: int, num_tones: int, num_harm: int, num_frames: int, fs: float, amp_min: float = -30, amp_max: float = 0, noise_min: float = -96, noise_max: float = -10, f0_min: float = 50, f0_max: float = 2000, f0_distr: Literal['log', 'lin'] = 'log', randomize_phase: bool = False, interp_mode: Literal['const', 'center_linear', 'end_linear', 'half_linear', 'const_smooth'] = 'end_linear', random_seed: int | None = None)[source]¶
Bases:
DatasetGenerate sinusoid signals for synthetic training data.