scamp.settings.PlaybackSettings¶
-
class
scamp.settings.
PlaybackSettings
(settings_dict: dict = None)[source]¶ Bases:
scamp.settings._ScampSettings
Namespace containing the settings relevant to playback implementation and adjustments.
- Parameters
settings_dict – dictionary from which to set all settings attributes
- Variables
named_soundfonts – Dictionary mapping names of frequently-used soundfonts to their file paths
default_soundfont – Soundfont (by name or path) to default to in playback
default_audio_driver – Name of the audio driver use for soundfont playback by default. If “auto”, we test to see what audio driver will work, and replace this value with that driver.
default_midi_output_device – Name or number of the midi output device to default to
default_max_soundfont_pitch_bend – When playing back with soundfonts, instruments will be immediately set to use this value for the maximum pitch bend. (Makes sense to set this to a large value for maximum flexibility)
default_max_streaming_midi_pitch_bend – When playing back with a midi stream to an external synthesizer/program, instruments will be immediately set to use this value for the maximum pitch bend. (Makes sense probably to leave this at the MIDI default of 2 semitones, in case the receiving device doesn’t listen to messages that reset the pitch bend range.)
soundfont_volume_to_velocity_curve – an
Envelope
defining how volume values get mapped to MIDI velocities in soundfont-based playback. The default maps the range 0-1 to the range 0-127, but with some non-linear shaping towards higher velocity values. This is because, for some reason, soundfont playback is almost inaudible low velocities.streaming_midi_volume_to_velocity_curve – same as
soundfont_volume_to_velocity_curve
, but for streaming MIDI playback. This defaults to a linear mapping from 0-1 to 0-127.osc_message_addresses – Dictionary mapping the different kinds of playback messages to the OSC messages prefixes we will use for them. For instance, if you want start note messages to use “note_on”, set the osc_message_addresses[“start_note”] = “note_on”, and all OSC messages starting a note will come out as [instrument name]/note_on/
adjustments – a
PlaybackAdjustmentsDictionary
defining how playback should be altered in response to different articulations/notations/etc.try_system_fluidsynth_first – if True, always tries system copy of the fluidsynth libraries first before using the one embedded in the scamp package.
resize_parameter_envelopes – one of “never”, “lists”, and “always”. This determines whether or not parameter envelopes are resized to the length of the note. The default value of “lists” does this resizing only when the envelope was created indirectly by passing a list to the parameter.
Methods
Prints out a list of all of the named soundfonts and the paths of the soundfont files to which they point.
register_named_soundfont
(name, soundfont_path)Adds a named soundfont, so that it can be easily referred to in constructing a Session
Same as above, but removes a named soundfont
Inherited Methods
Returns a copy of this object by serializing to and from JSON.
Returns a factory default version of this settings object.
Dump this object as a JSON string.
json_loads
(s)Load this object from a JSON string.
load
()Loads and instance of this settings object from its corresponding JSON file.
load_from_json
(file_path)Load this object from a JSON file with the given path.
Rewrites the JSON file from which settings are loaded, meaning that this reset will persist to the running of scripts in the future.
restore_factory_defaults
([persist])Restores settings back to their “factory defaults” (the defaults when SCAMP was installed).
save_to_json
(file_path)Save this object to a JSON file using the given path.
Attributes
Default playback settings (from when SCAMP was installed)
-
factory_defaults
= {'adjustments': PlaybackAdjustmentsDictionary(articulations={'staccato': NotePlaybackAdjustment(None, None, ParamPlaybackAdjustment(0.5, 0)), 'staccatissimo': NotePlaybackAdjustment(None, None, ParamPlaybackAdjustment(0.3, 0)), 'marcato': NotePlaybackAdjustment(None, ParamPlaybackAdjustment(1.5, 0), None), 'tenuto': NotePlaybackAdjustment(None, None, ParamPlaybackAdjustment(1.2, 0)), 'accent': NotePlaybackAdjustment(None, ParamPlaybackAdjustment(1.2, 0), None)}, noteheads={'normal': None, 'diamond': None, 'harmonic': None, 'harmonic-black': None, 'harmonic-mixed': None, 'triangle': None, 'slash': None, 'cross': None, 'x': None, 'circle-x': None, 'xcircle': None, 'inverted triangle': None, 'square': None, 'arrow down': None, 'arrow up': None, 'circled': None, 'slashed': None, 'back slashed': None, 'cluster': None, 'circle dot': None, 'left triangle': None, 'rectangle': None, 'do': None, 're': None, 'mi': None, 'fa': None, 'fa up': None, 'so': None, 'la': None, 'ti': None, 'none': None, 'filled normal': None, 'filled diamond': None, 'filled harmonic': None, 'filled harmonic-black': None, 'filled harmonic-mixed': None, 'filled triangle': None, 'filled slash': None, 'filled cross': None, 'filled x': None, 'filled circle-x': None, 'filled xcircle': None, 'filled inverted triangle': None, 'filled square': None, 'filled arrow down': None, 'filled arrow up': None, 'filled circled': None, 'filled slashed': None, 'filled back slashed': None, 'filled cluster': None, 'filled circle dot': None, 'filled left triangle': None, 'filled rectangle': None, 'filled do': None, 'filled re': None, 'filled mi': None, 'filled fa': None, 'filled fa up': None, 'filled so': None, 'filled la': None, 'filled ti': None, 'filled none': None, 'open normal': None, 'open diamond': None, 'open harmonic': None, 'open harmonic-black': None, 'open harmonic-mixed': None, 'open triangle': None, 'open slash': None, 'open cross': None, 'open x': None, 'open circle-x': None, 'open xcircle': None, 'open inverted triangle': None, 'open square': None, 'open arrow down': None, 'open arrow up': None, 'open circled': None, 'open slashed': None, 'open back slashed': None, 'open cluster': None, 'open circle dot': None, 'open left triangle': None, 'open rectangle': None, 'open do': None, 'open re': None, 'open mi': None, 'open fa': None, 'open fa up': None, 'open so': None, 'open la': None, 'open ti': None, 'open none': None}, notations={'tremolo': None, 'tremolo1': None, 'tremolo2': None, 'tremolo3': None, 'tremolo4': None, 'tremolo5': None, 'tremolo6': None, 'tremolo7': None, 'tremolo8': None, 'down-bow': None, 'up-bow': None, 'open-string': None, 'harmonic': None, 'stopped': None, 'snap-pizzicato': None, 'arpeggiate': None, 'arpeggiate up': None, 'arpeggiate down': None, 'non-arpeggiate': None, 'fermata': None, 'turn': None, 'mordent': None, 'inverted mordent': None, 'trill mark': None}), 'default_audio_driver': 'auto', 'default_max_soundfont_pitch_bend': 48, 'default_max_streaming_midi_pitch_bend': 2, 'default_midi_output_device': None, 'default_soundfont': 'general_midi', 'named_soundfonts': {'general_midi': 'Merlin.sf2'}, 'osc_message_addresses': {'change_parameter': 'change_parameter', 'change_pitch': 'change_pitch', 'change_volume': 'change_volume', 'end_note': 'end_note', 'start_note': 'start_note'}, 'resize_parameter_envelopes': 'lists', 'soundfont_search_paths': ['%PKG/soundfonts'], 'soundfont_volume_to_velocity_curve': Envelope((0, 40, 127), (0.1, 0.9), (0, 0), 0), 'streaming_midi_volume_to_velocity_curve': Envelope((0, 127), (1,), (0,), 0), 'try_system_fluidsynth_first': False}¶ Default playback settings (from when SCAMP was installed)
-
register_named_soundfont
(name: str, soundfont_path: str) → None[source]¶ Adds a named soundfont, so that it can be easily referred to in constructing a Session
- Parameters
name – the soundfont name
soundfont_path – the absolute path to the soundfont, staring with a slash, or a relative path that gets resolved relative to the soundfonts directory
-
unregister_named_soundfont
(name: str) → None[source]¶ Same as above, but removes a named soundfont
- Parameters
name – the default soundfont name to remove
-
list_named_soundfonts
() → None[source]¶ Prints out a list of all of the named soundfonts and the paths of the soundfont files to which they point.
-
duplicate
() → T¶ Returns a copy of this object by serializing to and from JSON.
-
classmethod
factory_default
()¶ Returns a factory default version of this settings object.
-
json_dumps
() → str¶ Dump this object as a JSON string. This uses a custom encoder that recognizes and appropriately converts any attributes that are object inheriting from SavesToJSON.
-
classmethod
json_loads
(s: str) → T¶ Load this object from a JSON string. This uses a custom decoder that looks for a “_type” key in any object/dictionary being parsed and converts it to the class specified (assuming it a subclass of SavesToJSON).
- Parameters
s – a string representing this object in JSON format
-
classmethod
load
()¶ Loads and instance of this settings object from its corresponding JSON file. If no such file exists, or it is corrupted in some way, then this creates a fresh JSON file there. This doesn’t work with settings that are nested within other settings (like GlissandiSettings), since they do not have corresponding JSON files,
-
classmethod
load_from_json
(file_path: str) → T¶ Load this object from a JSON file with the given path. This uses a custom decoder that looks for a “_type” key in any object/dictionary being parsed and converts it to the class specified (assuming it a subclass of SavesToJSON).
- Parameters
file_path – path for loading the file
-
make_persistent
() → None¶ Rewrites the JSON file from which settings are loaded, meaning that this reset will persist to the running of scripts in the future.
-
restore_factory_defaults
(persist=False) → None¶ Restores settings back to their “factory defaults” (the defaults when SCAMP was installed). Unless the persist argument is set, this is temporary to the running of the current script.
- Parameters
persist – if True, rewrites the JSON file from which defaults are loaded, meaning that this reset will persist to the running of scripts in the future.
-
save_to_json
(file_path: str) → None¶ Save this object to a JSON file using the given path. This uses a custom encoder that recognizes and appropriately converts any attributes that are object inheriting from SavesToJSON.
- Parameters
file_path – path for saving the file