beatmachine.beats module

class beatmachine.beats.Beats(sr: int, channels: int, beats: List[numpy.ndarray])

Bases: object

The Beats class is a convenient immutable wrapper for applying effects to songs.

apply(effect: Callable[[Iterable[numpy.ndarray]], Iterable[numpy.ndarray]]) → beatmachine.beats.Beats

Applies a single effect and returns a new Beats object.

Parameters:effect – Effect to apply.
Returns:A new Beats object with the given effect applied.
apply_all(*effects_list) → beatmachine.beats.Beats

Applies a list of effects and returns a new Beats object. This is the best way to apply multiple effects, since it only collects them into a list at the very end.

Parameters:effects_list – Effects to apply in order.
Returns:A new Beats object with the given effects applied.
channels
Returns:Number of audio channels.
static from_song(path_or_fp: Union[str, BinaryIO], beat_loader: Callable[[Union[str, BinaryIO]], Tuple[int, int, Iterable[numpy.ndarray]]] = <function load_beats_by_signal>) → beatmachine.beats.Beats

Loads a song as a Beats object.

Parameters:
  • path_or_fp – Path or file-like object to load from.
  • beat_loader – Callable to load and split the given path/file-like object into beats.
save(fp, out_format=None, extra_ffmpeg_args: List[str] = None)
sr
Returns:Audio sample rate.
to_ndarray() → numpy.ndarray

Consolidates this Beats object into an array with shape (samples, channels).

Returns:An ndarray with shape (samples, channels).