gamut.features

Corpus

class gamut.features.Corpus(source=None, max_duration=None, leaf_size=15, features=['timbre'], *args, **kwargs)

A Corpus represents a collection of one or more audio sources, from which a Mosaic can be built. Internally, the audio sources are analyzed and decomposed into grains.

Based on the audio features of these grains (e.g., timbre or pitch content), a k-dimensional search tree is built, which helps to optimize the process of finding the best matches for a given audio target.

source: str | list | None = None

Source file(s) from which to build the Corpus. source can be either a str or a list of str, where str is an audio file path or a directory of audio files. Note that, for any directory path, Corpus will recursively look for any .wav, .aif, or .mp3 audio files in folders and subfolders.

max_duration: str | list | None = None

Maximum audio file duration to use in Corpus. Applies to all audio files found in source.

n_mfcc: int = 13

Number of mel frequency cepstral coefficients to use in audio analysis.

hop_length: int = 512

hop size in audio samples.

win_length: int = 1024

window size in audio samples.

n_fft: int = 512

Number of FFT bins

features: Iterable = [‘timbre’]

List of str, specifying audio feature(s) to use for audio source analysis. The options are "timbre" and/or "pitch".

leaf_size: int = 10

Maximum number of data items per leaf in the k-dimensional binary search tree.

summarize()

Prints a summary of the current structure of the object

Mosaic

class gamut.features.Mosaic(target=None, corpus=None, sr=None, beat_unit=None, *args, **kwargs)

A Mosaic represents the blueprint from which an audio mosaic can be synthesized. Given an input audio target file path and a Corpus instance, a virtual representation of an audio mosaic is built, to be later converted to audio with the to_audio() method.

By “blueprint” it’s meant that a Mosaic instance generates and stores the necessary information to synthesize an audio mosaic, but does not automatically generate the audio mosaic.

This allows the user to create different versions, based on the audio parameters passed to the to_audio() method.

target: str | None = None

File path to target audio file.

corpus: Iterable | Corpus = None

Corpus instance to reconstruct target

sr: int | None = None

Sampling rate of output audio file

beat_unit: float | int | None = None

Optional argument to set the grain rate to a beat unit relative to detected tempo (e.g., 1/4, 1/8, 1/16, etc.). Works best when target has a steady and perceptible tempo.

summarize()

Prints a summary of the current structure of the object