scamp package

SCAMP: A Suite for Computer-Assisted Music in Python. SCAMP is an computer-assisted composition framework in Python designed to act as a hub, flexibly connecting the composer-programmer to a wide variety of resources for playback and notation.

Modules:

instruments

Module containing user-facing playback classes: Ensemble, ScampInstrument, and NoteHandle/ ChordHandle

note_properties

Module containing the NoteProperties object, which is a dictionary that stores a variety of playback and notation options that affect a given note.

performance

Module containing the PerformanceNote, PerformancePart, and Performance classes, which represent transcriptions of notes played by a group of ScampInstrument objects.

playback_adjustments

Module containing classes for defining adjustments to the playback of note parameters, as well as the PlaybackAdjustmentsDictionary, which defines how particular notations should be played back.

playback_implementations

Module containing the abstract base class PlaybackImplementation, as well as several of its concrete subclasses: SoundfontPlaybackImplementation, MidiPlaybackImplementations, and OSCPlaybackImplementation.

quantization

Module containing classes and functions related to the quantization of performances.

score

Module containing classes that deal with music notation.

session

Module containing the Session class, which is the central hub through which nearly all of SCAMP's functionality flows.

settings

Module containing the main settings classes: PlaybackSettings, QuantizationSettings, and EngravingSettings, as well as TempoSettings and GlissandiSettings, which are part of EngravingSettings.

spanners

Module containing start and stop spanner objects in SCAMP, such as StartHairpin, StopHairpin, StartSlur and StopSlur.

spelling

Module containing the SpellingPolicy class, which describes how pitches should be spelled.

test_run

Simple module with a play() function that can be used to verify that SCAMP is installed successfully.

text

Module containing utilities for representing text in SCAMP, currently containing the StaffText class.

transcriber

Module containing the Transcriber class which records the playback of a group of ScampInstrument objects to create a Performance

utilities

Various and sundry utility functions used by SCAMP.

Public-Facing API (result of import *):

dependency_status()

Return a list of (name, state, detail) tuples describing the status of each optional dependency.

print_dependency_status()

Print which optional features are available in this scamp install.

get_available_midi_input_devices()

Probes the available devices for midi input or output

get_available_midi_output_devices()

Probes the available devices for midi input or output

get_port_number_of_midi_device(device_name, ...)

Get the port number of a given device based on its a fuzzy string match of its name.

print_available_midi_input_devices()

Prints a list of available ports and devices for midi input or output

print_available_midi_output_devices()

Prints a list of available ports and devices for midi input or output

print_soundfont_presets([which_soundfont])

Prints a list of all the presets available in the given soundfont; useful for finding the name of the instrument you want to load.

Clock([name, parent, initial_rate, ...])

Recursively nestable clock.

ClockFamilyOptions([timing_policy, ...])

Fine-tuning options for a clock family, passed to a master Clock on construction.

DurationUnits(*values)

Units with which we measure duration or Moment positioning.

TempoUnits(*values)

The three different, and mutually determined, ways of expressing tempo.

ClockKilledError

Raised inside a forked clock's own thread when its wait is woken by kill(), so the fork wrapper can unwind the user function cleanly.

ClockblocksError

Base class for clockblocks errors.

DeadClockError

Raised when something tries to wait or fork on a clock that's no longer ALIVE (either killed already, or — for fork — still PENDING in its start_delay).

NoActiveClockError

Raised when a context-inferring clock operation (the module-level wait/fork/etc.) is attempted from a thread that has no clock active on it.

NotMasterClockError

Raised by operations that are only valid on the master (top-level) clock — e.g. run_as_server() — when called on a child clock.

SchedulerHeldError

Raised when wait() is called from a thread that is holding the scheduler via hold_scheduler() — most commonly inside a MIDI / OSC / HID callback, which runs under such a hold.

WrongThreadError

Raised when wait() is called from a thread that doesn't own the clock.

MetricPhaseTarget(phase_or_phases[, ...])

Class representing a particular point in a (beat or measure) cycle.

Moment(value[, units, relative])

Represents a point on a clock's timeline.

TempoEnvelope([levels, durations, ...])

A subclass of Envelope that is specifically designed for representing changing tempo curves.

apply_beat_length_function(function[, ...])

Drive the current clock's beat length (in seconds per beat) by following a function of beats/time.

apply_rate_function(function[, ...])

Drive the current clock's rate (in beats per second) by following a function of beats/time.

apply_tempo_envelope(envelope[, truncate, loop])

Append a ready-made TempoEnvelope onto the current clock's tempo curve.

apply_tempo_function(function[, ...])

Drive the current clock's tempo (in beats per minute) by following a function of beats/time.

current_clock()

Get the Clock active on the current thread, or None if none is active.

fork(forked_function[, args, kwargs, name, ...])

Run forked_function on a new child clock of the currently active clock, so it proceeds in parallel while staying coordinated under the same musical time.

get_beat()

Return how many beats have passed on the currently active clock (see beat).

get_beat_length()

Return the current beat length (in seconds per beat) of the currently active clock (see beat_length).

get_rate()

Return the current rate (in beats per second) of the currently active clock (see rate).

get_tempo()

Return the current tempo (in beats per minute) of the currently active clock (see tempo).

get_time()

Return how much time has passed on the currently active clock (see time) — in seconds if it is the master clock, or parent clock beats if it is a forked child clock.

set_beat_length(beat_length)

Immediately set the beat length of the current clock (see beat_length).

set_beat_length_target(beat_length_target, when)

Smoothly change the current clock's beat length to beat_length_target (in seconds per beat), arriving at when.

set_beat_length_targets(beat_length_targets, ...)

Set several beat-length targets at once, building a multi-segment tempo curve on the current clock.

set_rate(rate)

Immediately set the rate of the current clock (see rate).

set_rate_target(rate_target, when[, ...])

Smoothly change the current clock's rate to rate_target (in beats per second), arriving at when.

set_rate_targets(rate_targets, whens[, ...])

Set several rate targets at once, building a multi-segment tempo curve on the current clock.

set_tempo(tempo)

Immediately set the tempo of the current clock (see tempo).

set_tempo_target(tempo_target, when[, ...])

Smoothly change the current clock's tempo to tempo_target (in beats per minute), arriving at when.

set_tempo_targets(tempo_targets, whens[, ...])

Set several tempo targets at once, building a multi-segment tempo curve on the current clock.

stop_tempo_loop_or_function()

Stop following any function or looping envelope previously started on the current clock's tempo (via apply_tempo_function()/apply_rate_function()/apply_beat_length_function() or a looping apply_tempo_envelope()).

terminate_forked_children()

Kill the child clocks of the currently active clock, returning once they have finished unwinding (see terminate_forked_children()).

wait(dt[, units])

Block the clock currently active on this thread for dt beats (or seconds, if units="time"), yielding to the scheduler.

wait_for_children_to_finish()

Block on the currently active clock until its child clocks have finished (see wait_for_children_to_finish()).

wait_for_clock_to_finish(clock)

Block on the currently active clock until clock has finished (see wait_for_clock_to_finish()).

wait_forever()

Block forever on the currently active clock (see wait_forever()) — usually to keep the main script alive while child clocks do the work.

wait_until(when[, units])

Block the clock currently active on this thread until the absolute beat (or time, if units="time") given by when.

Envelope([levels, durations, curve_shapes, ...])

Class representing a piece-wise exponential function.

EnvelopeSegment(start_time, end_time, ...)

A segment of an envelope, with the ability to perform interpolation and integration.

ChordHandle(note_handles, intervals)

This handle, returned by instrument.start_chord, allows us to manipulate a chord that we have started, (i.e. by changing pitch, volume, or another other parameter, or by ending the note).

Ensemble([default_soundfont, ...])

Host for multiple ScampInstrument objects, keeping shared resources, and shared default settings.

NoteHandle(note_id, instrument)

This handle, which is returned by instrument.start_note, allows us to manipulate the note that we have started, (i.e. by changing pitch, volume, or another other parameter, or by ending the note).

ScampInstrument([name, ensemble, ...])

Instrument class that does the playing of the notes.

NoteProperties(*args, **kwargs)

Class that holds information about any and all playback or notational details for a note or chord aside from its pitch, volume and duration.

Performance([parts, tempo_envelope])

Representation of note playback events, usually a transcription of the notes played by an Ensemble.

PerformanceNote(start_beat, length, pitch, ...)

Represents a single note played by a ScampInstrument.

PerformancePart([instrument, name, voices, ...])

Transcription of the notes played by a single ScampInstrument.

NotePlaybackAdjustment([pitch_adjustment, ...])

Represents an adjustment to the pitch, volume and/or length of the playback of a single note

ParamPlaybackAdjustment([multiply, add])

Represents a multiply/add playback adjustment to a single parameter.

MIDIStreamPlaybackImplementation([...])

Playback implementation that sends an outgoing MIDI stream to an external synthesizer / program

OSCPlaybackImplementation(port[, ...])

Playback implementation that sends outgoing OSC messages to an external synthesizer / program

PlaybackImplementation()

Abstract base class for playback implementations, which do the actual work of playback, either by playing sounds or by sending messages to external synthesizers to play sounds.

SoundfontPlaybackImplementation([...])

Playback implementation that does Soundfont playback, via the MIDI protocol.

BeatQuantizationScheme(length, divisors[, ...])

Scheme for making a decision about which divisor to use to quantize a beat

MeasureQuantizationScheme(beat_schemes, ...)

Scheme for quantizing a measure, including beat lengths and which beat divisors to allow.

QuantizationScheme(measure_schemes[, loop])

Scheme for quantizing a PerformancePart or Performance

TimeSignature(numerator, denominator[, ...])

Class representing the time signature of a measure

Measure(voices, time_signature[, ...])

Representation of a single measure within in a Staff

NoteLike(pitch, volume, written_length, ...)

Represents a note, chord, or rest that can be notated without ties

Score([parts, title, composer, tempo_envelope])

Representation of a score in traditional western notation.

Staff(measures[, name])

Representation of a single staff of a western-notated score

StaffGroup(staves[, name, clef_choices])

Representation of a StaffGroup (used for the multiple staves of a single instrument)

Tuplet(tuplet_divisions, normal_divisions, ...)

Representation of a Tuplet object within a single voice of music.

Voice(contents, time_signature)

Representation of a single voice within a single measure of a single staff of music.

Session([tempo, default_soundfont, ...])

A Session combines the functionality of a master Clock, an Ensemble, and a Transcriber.

engraving_settings

Instance of EngravingSettings containing the actual engraving defaults to be consulted

playback_settings

Instance of PlaybackSettings containing the actual playback defaults to be consulted

quantization_settings

Instance of QuantizationSettings containing the actual quantization defaults to be consulted

ChangePedal([label])

Change piano pedal spanner.

StartBracket([label])

Start bracket spanner (e.g. a text bracket with a hook).

StartDashes([label])

Start dashes spanner.

StartHairpin([label])

Start hairpin spanner.

StartPedal([label])

Start piano pedal spanner.

StartPhrasingSlur([label])

Phrasing slurs are an additional type of slur available in LilyPond useful for creating long, overarching slurs that can have smaller, regular slurs inside of them.

StartSlur([label])

Start slur spanner type.

StartTrill([label])

Start trill spanner.

StopBracket([label])

Stop bracket spanner.

StopDashes([label])

Stop dashes spanner.

StopHairpin([label])

Stop hairpin spanner.

StopPedal([label])

Stop piano pedal spanner.

StopPhrasingSlur([label])

Stop spanner for a phrasing slur.

StopSlur([label])

Stop slur spanner type.

StopTrill([label])

Stop trill spanner.

SpellingPolicy([step_alteration_pairs])

Object that translates pitches or pitch classes to the actual spelling used in a score

StaffText(text[, italic, bold, placement])

Represents text that will be attached to the staff at a given note.

Transcriber()

Class responsible for transcribing notes played by instruments into a Performance.