Plush

SoundSequenceCollection#

plupy · Type index

Module: plupy · obtained from plupy.data.sound_sequences

plupy.data.sound_sequences: tracker sequences, new or imported from MIDI.

class SoundSequenceCollection(DataCollection)

Inherits DataCollection: its members are documented there.

Usage and examples

Members: new · import_midi

new#

new(name: str, text: str | None=None) -> SoundSequence

A new sequence (120 BPM, one 64-row pattern, one track), optionally filled from text at once.

A tracker sequence: a new one is 120 BPM with one empty 64-row pattern and one track. to_text() returns the whole sequence as text and from_text(text) replaces it (one undo step); new(..., text=…) does both at once. Instruments name the project's Sounds by name; a mistake raises PlupyError naming the line and changes nothing. The format is described in Sounds; props holds sequence.bpm, sequence.rowsPerBeat, sequence.beatsPerBar and sequence.loop:

kick = plupy.data.sounds.import_file("Source/kick.wav")
with plupy.edit("Beat"):
    beat = plupy.data.sound_sequences.new("Beat", text=f'''bpm 100
instruments
00 {kick.name}
tracks
Kick 00 1
pattern
00 C-4
08 C-4
''')
    beat.props["sequence.bpm"] = 110

Generate patterns with loops (one line per row) and shelve the sequence in a library for Scene.PlaySequence("Music/Beat").

import_midi#

import_midi(path: str, *, name: str | None=None, programs: dict[int, DataBlock] | None=None, drums: DataBlock | None=None, soundfont: str | list[str] | None=None, rows_per_beat: int=4, pattern_rows: int=64) -> tuple[SoundSequence, list[str]]

Make a sequence from a .mid file. programs maps General MIDI programs (0-127) to Sounds, drums is the Sound for channel 10 (a keyzone kit); soundfont (an .sf2 path, or a list of two: a main font and a fallback for what it lacks) imports the presets the song uses and fills the other slots. Returns (sequence, report): the report says what came across and which slots need Sounds.

Make a new sequence from a MIDI file, as the Tracker's Import MIDI… does (Tracker). programs maps General MIDI programs (0 to 127) to Sounds and drums is the kit Sound for channel 10; with soundfont (an .sf2 path, or a list of two: a main font and a fallback for what it lacks, often its drums) the presets the song uses are imported and fill the slots the maps leave; other slots stay empty. Each channel's starting volume and pan (controllers 7 and 10) become its track's vol and pan. Returns the sequence and the report: its first line summarises notes, tracks, BPM and patterns; the rest name empty slots, dropped notes and what was not imported. Call it inside plupy.edit:

with plupy.edit("Import song"):
    song, report = plupy.data.sound_sequences.import_midi("Source/song.mid", programs={0: piano, 32: bass}, drums=kit)
print("\n".join(report))

DataBlock · DataCollection · PlupyError · Scene · Sound · SoundSequence · edit

Source#