class pumpp.sampler.Sampler(n_samples, duration, *ops, **kwargs)[source]

Generate samples uniformly at random from a pumpp data dict.


>>> # Set up the parameters
>>> sr, n_fft, hop_length = 22050, 512, 2048
>>> # Instantiate some transformers
>>> p_stft = pumpp.feature.STFTMag('stft', sr=sr, n_fft=n_fft,
...                                hop_length=hop_length)
>>> p_beat = pumpp.task.BeatTransformer('beat', sr=sr,
...                                     hop_length=hop_length)
>>> # Apply the transformers to the data
>>> data = pumpp.transform('test.ogg', 'test.jams', p_stft, p_beat)
>>> # We'll sample 10 patches of duration = 32 frames
>>> stream = pumpp.Sampler(10, 32, p_stft, p_beat)
>>> # Apply the streamer to the data dict
>>> for example in stream(data):
...     process(data)


n_samples (int or None) the number of samples to generate. If None, generate indefinitely.
duration (int > 0) the duration (in frames) of each sample
random_state (None, int, or np.random.RandomState) If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.
ops (array of pumpp.feature.FeatureExtractor or pumpp.task.BaseTaskTransformer) The operators to include when sampling data.
__init__(n_samples, duration, *ops, **kwargs)[source]


__init__(n_samples, duration, *ops, **kwargs)
data_duration(data) Compute the valid data duration of a dict
indices(data) Generate patch indices
sample(data, interval) Sample a patch from the data object