Composition

A Composition is the heart of the radiotool.composer. Use it to build an audio file from other audio tracks.

class radiotool.composer.Composition(tracks=None, channels=2, segments=None, dynamics=None)

Create a composition made up of bits of different audio tracks.

__init__(tracks=None, channels=2, segments=None, dynamics=None)

Initialize a composition with optional starting tracks/segments.

Parameters:
Returns:

A new composition

Return type:

Composition

add_dynamic(dyn)

Add a dynamic to the composition

Parameters:dyn (radiotool.composer.Dynamic) – Dynamic to add to composition
add_dynamics(dyns)

Add a list of dynamics to the composition

Parameters:dyns (list of radiotool.composer.Dynamic) – Dynamics to add to composition
add_music_cue(track, comp_cue, song_cue, duration=6.0, padding_before=12.0, padding_after=12.0)

Add a music cue to the composition. This doesn’t do any audio analysis, it just aligns a specified point in the track (presumably music) with a location in the composition. See UnderScore for a visualization of what this is doing to the music track.

Parameters:
  • track (radiotool.composer.Track) – Track to align in the composition
  • comp_cue (float) – Location in composition to align music cue (in seconds)
  • song_cue (float) – Location in the music track to align with the composition cue (in seconds)
  • duration (float) – Duration of music after the song cue before the music starts to fade out (in seconds)
  • padding_before (float) – Duration of music playing softly before the music cue/composition cue (in seconds)
  • padding_after (float) – Duration of music playing softly after the music cue/composition cue (in seconds)
add_segment(segment)

Add a segment to the composition

Parameters:segment (radiotool.composer.Segment) – Segment to add to composition
add_segments(segments)

Add a list of segments to the composition

Parameters:segments (list of radiotool.composer.Segment) – Segments to add to composition
add_track(track)

Add track to the composition

Parameters:track (radiotool.composer.Track) – Track to add to composition
add_tracks(tracks)

Add a list of tracks to the composition

Parameters:tracks (list of radiotool.composer.Track) – Tracks to add to composition
build(track_list=None, adjust_dynamics=False, min_length=None, channels=None)

Create a numpy array from the composition.

Parameters:
  • track_list (list of radiotool.composer.Track) – List of tracks to include in composition generation (None means all tracks will be used)
  • min_length (int) – Minimum length of output array (in frames). Will zero pad extra length.
  • adjust_dynamics (bool.) – Automatically adjust dynamics. Will document later.
cross_fade(seg1, seg2, duration)

Add an equal-power crossfade to the composition between two segments.

Parameters:
duration None

Get duration of composition

export(**kwargs)

Generate audio file from composition.

Parameters:
  • filename (str.) – Output filename (no extension)
  • filetype (str.) – Output file type (only .wav supported for now)
  • samplerate (integer) – Sample rate of output audio
  • channels (integer) – Channels in output audio, if different than originally specified
  • separate_tracks (bool.) – Also generate audio file for each track in composition
  • min_length (int) – Minimum length of output array (in frames). Will zero pad extra length.
  • adjust_dynamics (bool.) – Automatically adjust dynamics (will document later)
extended_fade_in(segment, duration)

Add a fade-in to a segment that extends the beginning of the segment.

Parameters:
Returns:

The fade that has been added to the composition

Return type:

Fade

extended_fade_out(segment, duration)

Add a fade-out to a segment that extends the beginning of the segment.

Parameters:
Returns:

The fade that has been added to the composition

Return type:

Fade

fade_in(segment, duration)

Adds a fade in to a segment in the composition

Parameters:
Returns:

The fade that has been added to the composition

Return type:

Fade

fade_out(segment, duration)

Adds a fade out to a segment in the composition

Parameters:
Returns:

The fade that has been added to the composition

Return type:

Fade

Previous topic

radiotool - tools for constructing and retargeting audio

Next topic

Tracks

This Page

Fork me on GitHub