scamp_extensions.playback.multi_preset_instrument.MultiPresetInstrument

class scamp_extensions.playback.multi_preset_instrument.MultiPresetInstrument(session: Session, name: str, default_spelling_policy: Optional[SpellingPolicy] = None, clef_preference: str = 'from_name')[source]

Bases: object

A convenient wrapper for bundling multiple ScampInstrument objects or soundfont presets into a single notated part, and assigning particular notations to these presets.

Parameters:
  • session – the session in which this MultiPresetInstrument operates

  • name – name of this MultiPresetInstrument (e.g. in the score)

  • default_spelling_policy – see ScampInstrument

  • clef_preference – see ScampInstrument

Methods

add_preset(name, instrument_or_soundfont_preset)

Add a new preset with a given instrument and name.

end_all_notes()

Ends all notes currently playing

num_notes_playing()

Returns the number of notes currently playing.

play_chord(pitches, volume, length[, ...])

Play a chord using this MultiPresetInstrument.

play_note(pitch, volume, length[, ...])

Play a note using this MultiPresetInstrument

send_midi_cc(cc_number, value_from_0_to_1)

Send a midi cc message to every ScampInstrument: used by this MultiPresetInstrument.

set_max_pitch_bend(semitones)

Set the max pitch bend for all midi playback implementations on this instrument

start_chord(pitches, volume[, properties, ...])

Start a note using this MultiPresetInstrument.

start_note(pitch, volume[, properties, ...])

Start a note using this MultiPresetInstrument.

Attributes

clef_preference

The clef preference for this instrument.

default_spelling_policy

The default spelling policy for notes played back by this instrument.

name

Name of this MultiPresetInstrument (e.g.

property name

Name of this MultiPresetInstrument (e.g. in the score)

add_preset(name: str, instrument_or_soundfont_preset: Union[ScampInstrument, str, int, Tuple[int, int]], bundled_properties: Optional[Union[str, dict, Sequence, NoteProperty]] = None, bundled_properties_on_switch: Optional[Union[str, dict, Sequence, NoteProperty]] = None, bundled_properties_on_switch_away: Optional[Union[str, dict, Sequence, NoteProperty]] = None, make_default=False)[source]

Add a new preset with a given instrument and name.

Parameters:
  • instrument_or_soundfont_preset – either a ScampInstrument, or a soundfont preset name or number.

  • name – name for this preset used when calling play_note

  • bundled_properties – Any properties that we wish to bundle with every note played by this preset. For example, diamond noteheads for harmonics.

  • bundled_properties_on_switch – Any properties that we wish to bundle with this preset when we switch to it (the last note was a different preset). For example, “pizz.”

  • bundled_properties_on_switch_away – Any properties that we wish to bundle with this preset when we switch to it (the last note was a different preset). For example, “pizz.”

  • make_default – if True, moves this preset to the front of the list so that it becomes the default preset. If this is the first preset defined, it will become the default regardless of the setting of this parameter.

Returns:

self, for chaining purposes

play_note(pitch, volume, length, properties: Optional[Union[str, dict, Sequence, NoteProperty]] = None, preset: Optional[str] = None, blocking: bool = True, clock: Optional[Clock] = None) None[source]

Play a note using this MultiPresetInstrument

Parameters:
play_chord(pitches: Sequence, volume, length, properties: Optional[Union[str, dict, Sequence, NoteProperty]] = None, preset: Optional[str] = None, blocking: bool = True, clock: Optional[Clock] = None) None[source]

Play a chord using this MultiPresetInstrument.

Parameters:
start_note(pitch: float, volume: float, properties: Optional[Union[str, dict, Sequence, NoteProperty]] = None, preset: Optional[str] = None, clock: Optional[Clock] = None, max_volume: float = 1) MultiNoteHandle[source]

Start a note using this MultiPresetInstrument.

Parameters:
Returns:

a MultiNoteHandle with which to later manipulate the note

start_chord(pitches: Sequence[float], volume: float, properties: Optional[Union[str, dict, Sequence, NoteProperty]] = None, preset: Optional[str] = None, clock: Optional[Clock] = None, max_volume: float = 1) MultiNoteHandle[source]

Start a note using this MultiPresetInstrument.

Parameters:
Returns:

a MultiNoteHandle with which to later manipulate the chord

send_midi_cc(cc_number: int, value_from_0_to_1: float) None[source]

Send a midi cc message to every ScampInstrument: used by this MultiPresetInstrument.

Parameters:
  • cc_number – MIDI cc number

  • value_from_0_to_1 – value to send (scaled from 0 to 1)

end_all_notes() None[source]

Ends all notes currently playing

num_notes_playing() int[source]

Returns the number of notes currently playing.

set_max_pitch_bend(semitones: int) None[source]

Set the max pitch bend for all midi playback implementations on this instrument

property clef_preference

The clef preference for this instrument. See ScampInstrument

property default_spelling_policy

The default spelling policy for notes played back by this instrument. See ScampInstrument