Synthesizer Voices¶
- class pico_synth_sandbox.voice.AREnvelope(attack: float = 0.05, release: float = 0.05, amount: float = 1.0)[source]¶
Bases:
objectA simple attack, sustain and release envelope using linear interpolation. Useful for controlling parameters of a
synthio.Noteobject other than amplitude which acceptsynthio.BlockInputvalues.- Parameters:
attack (float) – The amount of time to go from 0.0 to the specified amount in seconds when the envelope is pressed. Must be greater than 0.0s.
release (float) – The amount of time to go from the specified amount back to 0.0 in seconds when the envelope is released. Must be greater than 0.0s.
amount (float) – The level at which to rise or fall to when the envelope is pressed. Value is arbitrary and can be positive or negative, but 0.0 will result in no change.
- get() synthio.BlockInput[source]¶
Get the
synthio.BlockInputobject to be applied to a parameter.- Returns:
envelope block input
- Return type:
synthio.BlockInput
- get_amount() float[source]¶
Get the envelope amount (or sustained value).
- Returns:
envelope amount
- Return type:
float
- get_attack() float[source]¶
Get the rate of attack in seconds.
- Returns:
attack time in seconds
- Return type:
float
- get_blocks() list[synthio.BlockInput][source]¶
Get all blocks used by this object. In order for it to function properly, these blocks must be added to the primary
synthio.Synthesizerobject using synth.blocks.append(…) or to apico_synth_sandbox.synth.Synthobject using synth.append(…).- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_release() float[source]¶
Get the rate of release in seconds.
- Returns:
release time in seconds
- Return type:
float
- get_value() float[source]¶
Get the current value of the envelope.
- Returns:
envelope value
- Return type:
float
- is_pressed() bool[source]¶
Check whether or not the envelope is currently in a “pressed” state.
- Returns:
if the envelope is pressed
- Return type:
bool
- press()[source]¶
Active the envelope by setting it into the “pressed” state. The envelope’s attack phase will start immediately.
- release()[source]¶
Deactivate the envelope by setting it into the “released” state. The envelope’s release phase will start immediately.
- set_amount(value)[source]¶
Update the value at which the envelope will rise (or fall) to. If the envelope is currently in the attack/press state, the targeted value will be updated immediately.
- Parameters:
value (float) – The level at which to rise or fall to when the envelope is pressed. Value is arbitrary and can be positive or negative, but 0.0 will result in no change.
- set_attack(value: float)[source]¶
Change the attack time in seconds. If the envelope is currently in the attack state, it will update the rate immediately.
- Parameters:
value (float) – The amount of time to go from 0.0 to the specified amount in seconds when the envelope is pressed. Must be greater than 0.0s.
- set_release(value)[source]¶
Change the release time in seconds. If the envelope is currently in the release state, it will update the rate immediately.
- Parameters:
value (float) – The amount of time to go from the specified amount back to 0.0 in seconds when the envelope is released. Must be greater than 0.0s.
- class pico_synth_sandbox.voice.LerpBlockInput(rate: float = 0.05, value: float = 0.0)[source]¶
Bases:
objectCreates and manages a
synthio.BlockInputobject to “lerp” (linear interpolation) between an old value and a new value. Useful for note frequency “glide” and custom envelopes.- Parameters:
rate (float) – The speed at which to go between values, in seconds. Must be greater than 0.0s. Defaults to 0.05s.
value (float) – The initial value. Defaults to 0.0.
- get() synthio.BlockInput[source]¶
Get the block input to be used with a
synthio.Noteobject.- Returns:
linear interpolation block input
- Return type:
synthio.BlockInput
- get_blocks() list[synthio.BlockInput][source]¶
Get all blocks used by this object. In order for it to function properly, these blocks must be added to the primary
synthio.Synthesizerobject using synth.blocks.append(…) or to apico_synth_sandbox.synth.Synthobject using synth.append(…).- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_rate() float[source]¶
Get the current rate of change of interpolation. Returns as 1/seconds.
- Returns:
rate of change per second
- Return type:
float
- get_value() float[source]¶
Get the current value of the linear interpolation output.
- Returns:
interpolated value
- Return type:
float
- class pico_synth_sandbox.voice.Voice[source]¶
Bases:
objectA “voice” to be used with a
pico_synth_sandbox.synth.Synthobject. Manages one or multiplesynthio.Noteobjects to be used with the primarysynthio.Synthesizerobject.The standard
pico_synth_sandbox.voice.Voiceclass is not meant to be used directly but instead inherited by one of the provided voice classes or within a custom class. This class helps manage note frequency, velocity, and filter state and provides an interface with apico_synth_sandbox.synth.Synthobject.- get_blocks() list[synthio.BlockInput][source]¶
Get all
synthio.BlockInputobjects attributed to this voice. Needed to register all block inputs within apico_synth_sandbox.synth.Synthobject.- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_notes() list[synthio.Note][source]¶
Get all
synthio.Noteobjects attributed to this voice. Used by thepico_synth_sandbox.synth.Synthto handle press and release states.- Returns:
list of note objects
- Return type:
list[
synthio.Note]
- press(notenum: int, velocity: float = 1.0) bool[source]¶
Update the voice to be “pressed” with a specific MIDI note number and velocity. Returns whether or not a new note is received to avoid unnecessary retriggering. The envelope is updated with the new velocity value regardless. Updating
synthio.Noteobjects should typically occur within the child class after calling this method and checking its return value.- Parameters:
notenum (int) – The MIDI note number representing the note frequency.
velocity (float) – The strength at which the note was received, between 0.0 and 1.0.
- Returns:
if a new note was received
- Return type:
bool
- release() bool[source]¶
Release the voice if a note is currently being played. Updating
synthio.Noteobjects should typically occur within the child class after calling this method and checking its return value.- Returns:
Whether or not a note was currently being played
- Return type:
bool
- set_filter(type: int = 0, frequency: float = 1.0, resonance: float = 0.0, synth=None, update: bool = True)[source]¶
Define all settings of the filter used by the voice.
- Parameters:
type (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
frequency (float) – The frequency of the filter from 0.0 to 1.0. Actual frequency is determined by sample rate of audio output.
resonance (float) – The resonance of the filter from 0.0 to 1.0. Actual resonance range is determined by library defaults (typically 0.7 to 8.0).
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_frequency(value: float, synth=None, update: bool = True)[source]¶
Change the frequency of the filter used by the voice. Value provided is a relative number from 0.0 (low frequency) to 1.0 (high frequency). The actual frequency range allowed by the voice is determined by the sample rate of output.
- Parameters:
value (float) – The frequency of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_resonance(value: float, synth=None, update: bool = True)[source]¶
Change the resonance of the filter used by the voice. Value provided is a relative number from 0.0 to 1.0. The actual resonance range allowed by the voice is determined by library defaults (typically 0.7 to 8.0 to avoid feedback).
- Parameters:
value (float) – The resonance of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_type(value: int, synth=None, update: bool = True)[source]¶
Change the type of filter used by the voice. Use one of the filter type constants provided by
pico_synth_sandbox.synth.Synthsuch aspico_synth_sandbox.synth.Synth.FILTER_LPF.- Parameters:
value (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_level(value: float)[source]¶
Change the overall volume of the voice. This method should be implemented within the child class.
- Parameters:
value (float) – the level of the voice from 0.0 to 1.0
- set_velocity_amount(value: float)[source]¶
Set the amount that this voice will respond to note velocity, from 0.0 to 1.0. A value of 0.0 represents no response to velocity. The voice will be at full level regardless of note velocity. Whereas a value of 1.0 represents full response to velocity.
- Parameters:
value (float) – the amount of velocity response from 0.0 to 1.0
Oscillator Voice¶
- class pico_synth_sandbox.voice.oscillator.Oscillator(root=440.0)[source]¶
Bases:
Voice- get_blocks()[source]¶
Get all
synthio.BlockInputobjects attributed to this voice. Needed to register all block inputs within apico_synth_sandbox.synth.Synthobject.- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_notes()[source]¶
Get all
synthio.Noteobjects attributed to this voice. Used by thepico_synth_sandbox.synth.Synthto handle press and release states.- Returns:
list of note objects
- Return type:
list[
synthio.Note]
- press(notenum, velocity=1.0)[source]¶
Update the voice to be “pressed” with a specific MIDI note number and velocity. Returns whether or not a new note is received to avoid unnecessary retriggering. The envelope is updated with the new velocity value regardless. Updating
synthio.Noteobjects should typically occur within the child class after calling this method and checking its return value.- Parameters:
notenum (int) – The MIDI note number representing the note frequency.
velocity (float) – The strength at which the note was received, between 0.0 and 1.0.
- Returns:
if a new note was received
- Return type:
bool
- release()[source]¶
Release the voice if a note is currently being played. Updating
synthio.Noteobjects should typically occur within the child class after calling this method and checking its return value.- Returns:
Whether or not a note was currently being played
- Return type:
bool
- set_filter(type=0, frequency=1.0, resonance=0.0, envelope_attack_time=0.0, envelope_release_time=0.0, envelope_amount=0.0, lfo_rate=1.0, lfo_depth=0.0, synth=None, update=True)[source]¶
Define all settings of the filter used by the voice.
- Parameters:
type (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
frequency (float) – The frequency of the filter from 0.0 to 1.0. Actual frequency is determined by sample rate of audio output.
resonance (float) – The resonance of the filter from 0.0 to 1.0. Actual resonance range is determined by library defaults (typically 0.7 to 8.0).
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_frequency(value: float, synth=None, update: bool = True)¶
Change the frequency of the filter used by the voice. Value provided is a relative number from 0.0 (low frequency) to 1.0 (high frequency). The actual frequency range allowed by the voice is determined by the sample rate of output.
- Parameters:
value (float) – The frequency of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_resonance(value: float, synth=None, update: bool = True)¶
Change the resonance of the filter used by the voice. Value provided is a relative number from 0.0 to 1.0. The actual resonance range allowed by the voice is determined by library defaults (typically 0.7 to 8.0 to avoid feedback).
- Parameters:
value (float) – The resonance of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_type(value: int, synth=None, update: bool = True)¶
Change the type of filter used by the voice. Use one of the filter type constants provided by
pico_synth_sandbox.synth.Synthsuch aspico_synth_sandbox.synth.Synth.FILTER_LPF.- Parameters:
value (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_level(value)[source]¶
Change the overall volume of the voice. This method should be implemented within the child class.
- Parameters:
value (float) – the level of the voice from 0.0 to 1.0
- set_velocity_amount(value: float)¶
Set the amount that this voice will respond to note velocity, from 0.0 to 1.0. A value of 0.0 represents no response to velocity. The voice will be at full level regardless of note velocity. Whereas a value of 1.0 represents full response to velocity.
- Parameters:
value (float) – the amount of velocity response from 0.0 to 1.0
- async update(synth)¶
Update all time-based voice logic controlled outside of synthio such as filter modulation.
- Parameters:
synth (
pico_synth_sandbox.synth.Synth) – Thepico_synth_sandbox.synth.Synthobject managing the voice. Used to obtain sample rate and calculate filters.
Analog Drum Voices¶
- class pico_synth_sandbox.voice.drum.ClosedHat[source]¶
Bases:
HatA single-shot “analog” drum voice representing a closed hi-hat cymbal using noise waveforms.
- get_blocks() list[synthio.BlockInput]¶
Get all
synthio.BlockInputobjects attributed to this voice. Needed to register all block inputs within apico_synth_sandbox.synth.Synthobject.- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_notes() list[synthio.Note]¶
Get all
synthio.Noteobjects attributed to this voice. Used by thepico_synth_sandbox.synth.Synthto handle press and release states.- Returns:
list of note objects
- Return type:
list[
synthio.Note]
- press(notenum: int, velocity: float = 1.0) bool¶
Update the voice to be “pressed” with a specific MIDI note number and velocity. Returns whether or not a new note is received. The envelope is updated with the new velocity value regardless.
- Parameters:
notenum (int) – The MIDI note number representing the note frequency.
velocity (float) – The strength at which the note was received, between 0.0 and 1.0.
- Returns:
if a new note was received
- Return type:
bool
- release() bool¶
Release the voice if a note is currently being played.
pico_synth_sandbox.voice.drum.Drumobjects typically don’t implement this operation because of their “single-shot” nature and will always return False.- Returns:
Whether or not a note was currently being played
- Return type:
bool
- set_envelope_attack_level(value: float, update: bool = True)¶
Change the level of attack in the voice amplitude envelope.
- Parameters:
value (float) – The level of amplitude that the voice will reach when completing the attack cycle of the envelope. Value should be between 0.0 and 1.0.
update (bool) – Whether or not to immediately update note envelopes after updating the attack level.
- set_filter(type: int = 0, frequency: float = 1.0, resonance: float = 0.0, synth=None, update: bool = True)¶
Define all settings of the filter used by the voice.
- Parameters:
type (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
frequency (float) – The frequency of the filter from 0.0 to 1.0. Actual frequency is determined by sample rate of audio output.
resonance (float) – The resonance of the filter from 0.0 to 1.0. Actual resonance range is determined by library defaults (typically 0.7 to 8.0).
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_frequency(value: float, synth=None, update: bool = True)¶
Change the frequency of the filter used by the voice. Value provided is a relative number from 0.0 (low frequency) to 1.0 (high frequency). The actual frequency range allowed by the voice is determined by the sample rate of output.
- Parameters:
value (float) – The frequency of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_resonance(value: float, synth=None, update: bool = True)¶
Change the resonance of the filter used by the voice. Value provided is a relative number from 0.0 to 1.0. The actual resonance range allowed by the voice is determined by library defaults (typically 0.7 to 8.0 to avoid feedback).
- Parameters:
value (float) – The resonance of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_type(value: int, synth=None, update: bool = True)¶
Change the type of filter used by the voice. Use one of the filter type constants provided by
pico_synth_sandbox.synth.Synthsuch aspico_synth_sandbox.synth.Synth.FILTER_LPF.- Parameters:
value (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_frequencies(values: list[float])¶
Set the base frequencies of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of the frequencies corresponding to each
synthio.Noteobject in hertz. Voice doesn’t respond to the note frequency when pressed and instead uses these constant frequencies.
- set_level(value: float)¶
Change the overall volume of the voice.
- Parameters:
value (float) – the level of the voice from 0.0 to 1.0
- set_time(value: float = 0.5)¶
Change the decay time of the hi-hat using a relative value and the predefined minimum and maximum times.
- Parameters:
value (float) – The amount of decay time relatively from 0.0 to 1.0. Defaults to 0.5.
- set_times(values: list[float])¶
Set the decay times of the amplitude envelopes of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of decay times corresponding to each
synthio.Noteobjects’ amplitude envelope in seconds.
- set_velocity_amount(value: float)¶
Set the amount that this voice will respond to note velocity, from 0.0 to 1.0. A value of 0.0 represents no response to velocity. The voice will be at full level regardless of note velocity. Whereas a value of 1.0 represents full response to velocity.
- Parameters:
value (float) – the amount of velocity response from 0.0 to 1.0
- set_waveforms(values: list)¶
Set the waveforms of each
synthio.Noteobject of this voice.- Parameters:
values (list) – A list of waveforms corresponding to each
synthio.Noteobject as numpy.int16 arrays. Can be generated using the functions within the synthio.waveform namespace.
- async update(synth)¶
Update all time-based voice logic controlled outside of synthio such as filter modulation.
- Parameters:
synth (
pico_synth_sandbox.synth.Synth) – Thepico_synth_sandbox.synth.Synthobject managing the voice. Used to obtain sample rate and calculate filters.
- class pico_synth_sandbox.voice.drum.Drum(count: int = 3, filter_type: int = 0, filter_frequency: int = 20000, frequencies: list[float] = [], times: list[float] = [], waveforms: list = [])[source]¶
Bases:
VoiceBase single-shot “analog” drum voice used by other classes within the pico_synth_sandbox.voice.drum namespace. Handles envelope times, tuning, waveforms, etc. for multiple
synthio.Noteobjects.- Parameters:
count (int) – The number of
synthio.Noteobjects to generate. Defaults to 3.filter_type (int) – The type of filter to use as designated by the options within
pico_synth_sandbox.synth.Synth. Defaults to pico_synth_sandbox.synth.Synth.FILTER_LPF (0).filter_frequency (int) – The exact frequency of the filter of all
synthio.Noteobjects in hertz. Defaults to 20KHz.frequencies (list[float]) – A list of the frequencies corresponding to each
synthio.Noteobject in hertz. Voice doesn’t respond to the note frequency when pressed and instead uses these constant frequencies. Defaults to 440.0hz if not provided.times (list[float]) – A list of decay times corresponding to each
synthio.Noteobjects’ amplitude envelope in seconds. Defaults to 1.0s for all notes if not provided.waveforms (list) – A list of waveforms corresponding to each
synthio.Noteobject as numpy.int16 arrays. Can be generated using the functions within the synthio.waveform namespace. Defaults to a square waveform for each note.
- get_blocks() list[synthio.BlockInput][source]¶
Get all
synthio.BlockInputobjects attributed to this voice. Needed to register all block inputs within apico_synth_sandbox.synth.Synthobject.- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_notes() list[synthio.Note][source]¶
Get all
synthio.Noteobjects attributed to this voice. Used by thepico_synth_sandbox.synth.Synthto handle press and release states.- Returns:
list of note objects
- Return type:
list[
synthio.Note]
- press(notenum: int, velocity: float = 1.0) bool[source]¶
Update the voice to be “pressed” with a specific MIDI note number and velocity. Returns whether or not a new note is received. The envelope is updated with the new velocity value regardless.
- Parameters:
notenum (int) – The MIDI note number representing the note frequency.
velocity (float) – The strength at which the note was received, between 0.0 and 1.0.
- Returns:
if a new note was received
- Return type:
bool
- release() bool[source]¶
Release the voice if a note is currently being played.
pico_synth_sandbox.voice.drum.Drumobjects typically don’t implement this operation because of their “single-shot” nature and will always return False.- Returns:
Whether or not a note was currently being played
- Return type:
bool
- set_envelope_attack_level(value: float, update: bool = True)[source]¶
Change the level of attack in the voice amplitude envelope.
- Parameters:
value (float) – The level of amplitude that the voice will reach when completing the attack cycle of the envelope. Value should be between 0.0 and 1.0.
update (bool) – Whether or not to immediately update note envelopes after updating the attack level.
- set_filter(type: int = 0, frequency: float = 1.0, resonance: float = 0.0, synth=None, update: bool = True)¶
Define all settings of the filter used by the voice.
- Parameters:
type (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
frequency (float) – The frequency of the filter from 0.0 to 1.0. Actual frequency is determined by sample rate of audio output.
resonance (float) – The resonance of the filter from 0.0 to 1.0. Actual resonance range is determined by library defaults (typically 0.7 to 8.0).
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_frequency(value: float, synth=None, update: bool = True)¶
Change the frequency of the filter used by the voice. Value provided is a relative number from 0.0 (low frequency) to 1.0 (high frequency). The actual frequency range allowed by the voice is determined by the sample rate of output.
- Parameters:
value (float) – The frequency of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_resonance(value: float, synth=None, update: bool = True)¶
Change the resonance of the filter used by the voice. Value provided is a relative number from 0.0 to 1.0. The actual resonance range allowed by the voice is determined by library defaults (typically 0.7 to 8.0 to avoid feedback).
- Parameters:
value (float) – The resonance of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_type(value: int, synth=None, update: bool = True)¶
Change the type of filter used by the voice. Use one of the filter type constants provided by
pico_synth_sandbox.synth.Synthsuch aspico_synth_sandbox.synth.Synth.FILTER_LPF.- Parameters:
value (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_frequencies(values: list[float])[source]¶
Set the base frequencies of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of the frequencies corresponding to each
synthio.Noteobject in hertz. Voice doesn’t respond to the note frequency when pressed and instead uses these constant frequencies.
- set_level(value: float)[source]¶
Change the overall volume of the voice.
- Parameters:
value (float) – the level of the voice from 0.0 to 1.0
- set_times(values: list[float])[source]¶
Set the decay times of the amplitude envelopes of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of decay times corresponding to each
synthio.Noteobjects’ amplitude envelope in seconds.
- set_velocity_amount(value: float)¶
Set the amount that this voice will respond to note velocity, from 0.0 to 1.0. A value of 0.0 represents no response to velocity. The voice will be at full level regardless of note velocity. Whereas a value of 1.0 represents full response to velocity.
- Parameters:
value (float) – the amount of velocity response from 0.0 to 1.0
- set_waveforms(values: list)[source]¶
Set the waveforms of each
synthio.Noteobject of this voice.- Parameters:
values (list) – A list of waveforms corresponding to each
synthio.Noteobject as numpy.int16 arrays. Can be generated using the functions within the synthio.waveform namespace.
- async update(synth)¶
Update all time-based voice logic controlled outside of synthio such as filter modulation.
- Parameters:
synth (
pico_synth_sandbox.synth.Synth) – Thepico_synth_sandbox.synth.Synthobject managing the voice. Used to obtain sample rate and calculate filters.
- class pico_synth_sandbox.voice.drum.Hat(min_time: float, max_time: float)[source]¶
Bases:
DrumThe base class to create hi-hat drum sounds with variable timing.
- Parameters:
min_time (float) – The minimum decay time in seconds. Must be greater than 0.0s.
max_time (float) – The maximum decay time in seconds. Must be greater than min_time.
- get_blocks() list[synthio.BlockInput]¶
Get all
synthio.BlockInputobjects attributed to this voice. Needed to register all block inputs within apico_synth_sandbox.synth.Synthobject.- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_notes() list[synthio.Note]¶
Get all
synthio.Noteobjects attributed to this voice. Used by thepico_synth_sandbox.synth.Synthto handle press and release states.- Returns:
list of note objects
- Return type:
list[
synthio.Note]
- press(notenum: int, velocity: float = 1.0) bool¶
Update the voice to be “pressed” with a specific MIDI note number and velocity. Returns whether or not a new note is received. The envelope is updated with the new velocity value regardless.
- Parameters:
notenum (int) – The MIDI note number representing the note frequency.
velocity (float) – The strength at which the note was received, between 0.0 and 1.0.
- Returns:
if a new note was received
- Return type:
bool
- release() bool¶
Release the voice if a note is currently being played.
pico_synth_sandbox.voice.drum.Drumobjects typically don’t implement this operation because of their “single-shot” nature and will always return False.- Returns:
Whether or not a note was currently being played
- Return type:
bool
- set_envelope_attack_level(value: float, update: bool = True)¶
Change the level of attack in the voice amplitude envelope.
- Parameters:
value (float) – The level of amplitude that the voice will reach when completing the attack cycle of the envelope. Value should be between 0.0 and 1.0.
update (bool) – Whether or not to immediately update note envelopes after updating the attack level.
- set_filter(type: int = 0, frequency: float = 1.0, resonance: float = 0.0, synth=None, update: bool = True)¶
Define all settings of the filter used by the voice.
- Parameters:
type (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
frequency (float) – The frequency of the filter from 0.0 to 1.0. Actual frequency is determined by sample rate of audio output.
resonance (float) – The resonance of the filter from 0.0 to 1.0. Actual resonance range is determined by library defaults (typically 0.7 to 8.0).
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_frequency(value: float, synth=None, update: bool = True)¶
Change the frequency of the filter used by the voice. Value provided is a relative number from 0.0 (low frequency) to 1.0 (high frequency). The actual frequency range allowed by the voice is determined by the sample rate of output.
- Parameters:
value (float) – The frequency of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_resonance(value: float, synth=None, update: bool = True)¶
Change the resonance of the filter used by the voice. Value provided is a relative number from 0.0 to 1.0. The actual resonance range allowed by the voice is determined by library defaults (typically 0.7 to 8.0 to avoid feedback).
- Parameters:
value (float) – The resonance of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_type(value: int, synth=None, update: bool = True)¶
Change the type of filter used by the voice. Use one of the filter type constants provided by
pico_synth_sandbox.synth.Synthsuch aspico_synth_sandbox.synth.Synth.FILTER_LPF.- Parameters:
value (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_frequencies(values: list[float])¶
Set the base frequencies of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of the frequencies corresponding to each
synthio.Noteobject in hertz. Voice doesn’t respond to the note frequency when pressed and instead uses these constant frequencies.
- set_level(value: float)¶
Change the overall volume of the voice.
- Parameters:
value (float) – the level of the voice from 0.0 to 1.0
- set_time(value: float = 0.5)[source]¶
Change the decay time of the hi-hat using a relative value and the predefined minimum and maximum times.
- Parameters:
value (float) – The amount of decay time relatively from 0.0 to 1.0. Defaults to 0.5.
- set_times(values: list[float])¶
Set the decay times of the amplitude envelopes of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of decay times corresponding to each
synthio.Noteobjects’ amplitude envelope in seconds.
- set_velocity_amount(value: float)¶
Set the amount that this voice will respond to note velocity, from 0.0 to 1.0. A value of 0.0 represents no response to velocity. The voice will be at full level regardless of note velocity. Whereas a value of 1.0 represents full response to velocity.
- Parameters:
value (float) – the amount of velocity response from 0.0 to 1.0
- set_waveforms(values: list)¶
Set the waveforms of each
synthio.Noteobject of this voice.- Parameters:
values (list) – A list of waveforms corresponding to each
synthio.Noteobject as numpy.int16 arrays. Can be generated using the functions within the synthio.waveform namespace.
- async update(synth)¶
Update all time-based voice logic controlled outside of synthio such as filter modulation.
- Parameters:
synth (
pico_synth_sandbox.synth.Synth) – Thepico_synth_sandbox.synth.Synthobject managing the voice. Used to obtain sample rate and calculate filters.
- class pico_synth_sandbox.voice.drum.Kick[source]¶
Bases:
DrumA single-shot “analog” drum voice representing a low frequency sine-wave kick drum.
- get_blocks() list[synthio.BlockInput]¶
Get all
synthio.BlockInputobjects attributed to this voice. Needed to register all block inputs within apico_synth_sandbox.synth.Synthobject.- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_notes() list[synthio.Note]¶
Get all
synthio.Noteobjects attributed to this voice. Used by thepico_synth_sandbox.synth.Synthto handle press and release states.- Returns:
list of note objects
- Return type:
list[
synthio.Note]
- press(notenum: int, velocity: float = 1.0) bool¶
Update the voice to be “pressed” with a specific MIDI note number and velocity. Returns whether or not a new note is received. The envelope is updated with the new velocity value regardless.
- Parameters:
notenum (int) – The MIDI note number representing the note frequency.
velocity (float) – The strength at which the note was received, between 0.0 and 1.0.
- Returns:
if a new note was received
- Return type:
bool
- release() bool¶
Release the voice if a note is currently being played.
pico_synth_sandbox.voice.drum.Drumobjects typically don’t implement this operation because of their “single-shot” nature and will always return False.- Returns:
Whether or not a note was currently being played
- Return type:
bool
- set_envelope_attack_level(value: float, update: bool = True)¶
Change the level of attack in the voice amplitude envelope.
- Parameters:
value (float) – The level of amplitude that the voice will reach when completing the attack cycle of the envelope. Value should be between 0.0 and 1.0.
update (bool) – Whether or not to immediately update note envelopes after updating the attack level.
- set_filter(type: int = 0, frequency: float = 1.0, resonance: float = 0.0, synth=None, update: bool = True)¶
Define all settings of the filter used by the voice.
- Parameters:
type (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
frequency (float) – The frequency of the filter from 0.0 to 1.0. Actual frequency is determined by sample rate of audio output.
resonance (float) – The resonance of the filter from 0.0 to 1.0. Actual resonance range is determined by library defaults (typically 0.7 to 8.0).
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_frequency(value: float, synth=None, update: bool = True)¶
Change the frequency of the filter used by the voice. Value provided is a relative number from 0.0 (low frequency) to 1.0 (high frequency). The actual frequency range allowed by the voice is determined by the sample rate of output.
- Parameters:
value (float) – The frequency of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_resonance(value: float, synth=None, update: bool = True)¶
Change the resonance of the filter used by the voice. Value provided is a relative number from 0.0 to 1.0. The actual resonance range allowed by the voice is determined by library defaults (typically 0.7 to 8.0 to avoid feedback).
- Parameters:
value (float) – The resonance of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_type(value: int, synth=None, update: bool = True)¶
Change the type of filter used by the voice. Use one of the filter type constants provided by
pico_synth_sandbox.synth.Synthsuch aspico_synth_sandbox.synth.Synth.FILTER_LPF.- Parameters:
value (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_frequencies(values: list[float])¶
Set the base frequencies of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of the frequencies corresponding to each
synthio.Noteobject in hertz. Voice doesn’t respond to the note frequency when pressed and instead uses these constant frequencies.
- set_level(value: float)¶
Change the overall volume of the voice.
- Parameters:
value (float) – the level of the voice from 0.0 to 1.0
- set_times(values: list[float])¶
Set the decay times of the amplitude envelopes of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of decay times corresponding to each
synthio.Noteobjects’ amplitude envelope in seconds.
- set_velocity_amount(value: float)¶
Set the amount that this voice will respond to note velocity, from 0.0 to 1.0. A value of 0.0 represents no response to velocity. The voice will be at full level regardless of note velocity. Whereas a value of 1.0 represents full response to velocity.
- Parameters:
value (float) – the amount of velocity response from 0.0 to 1.0
- set_waveforms(values: list)¶
Set the waveforms of each
synthio.Noteobject of this voice.- Parameters:
values (list) – A list of waveforms corresponding to each
synthio.Noteobject as numpy.int16 arrays. Can be generated using the functions within the synthio.waveform namespace.
- async update(synth)¶
Update all time-based voice logic controlled outside of synthio such as filter modulation.
- Parameters:
synth (
pico_synth_sandbox.synth.Synth) – Thepico_synth_sandbox.synth.Synthobject managing the voice. Used to obtain sample rate and calculate filters.
- class pico_synth_sandbox.voice.drum.OpenHat[source]¶
Bases:
HatA single-shot “analog” drum voice representing an open hi-hat cymbal using noise waveforms.
- get_blocks() list[synthio.BlockInput]¶
Get all
synthio.BlockInputobjects attributed to this voice. Needed to register all block inputs within apico_synth_sandbox.synth.Synthobject.- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_notes() list[synthio.Note]¶
Get all
synthio.Noteobjects attributed to this voice. Used by thepico_synth_sandbox.synth.Synthto handle press and release states.- Returns:
list of note objects
- Return type:
list[
synthio.Note]
- press(notenum: int, velocity: float = 1.0) bool¶
Update the voice to be “pressed” with a specific MIDI note number and velocity. Returns whether or not a new note is received. The envelope is updated with the new velocity value regardless.
- Parameters:
notenum (int) – The MIDI note number representing the note frequency.
velocity (float) – The strength at which the note was received, between 0.0 and 1.0.
- Returns:
if a new note was received
- Return type:
bool
- release() bool¶
Release the voice if a note is currently being played.
pico_synth_sandbox.voice.drum.Drumobjects typically don’t implement this operation because of their “single-shot” nature and will always return False.- Returns:
Whether or not a note was currently being played
- Return type:
bool
- set_envelope_attack_level(value: float, update: bool = True)¶
Change the level of attack in the voice amplitude envelope.
- Parameters:
value (float) – The level of amplitude that the voice will reach when completing the attack cycle of the envelope. Value should be between 0.0 and 1.0.
update (bool) – Whether or not to immediately update note envelopes after updating the attack level.
- set_filter(type: int = 0, frequency: float = 1.0, resonance: float = 0.0, synth=None, update: bool = True)¶
Define all settings of the filter used by the voice.
- Parameters:
type (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
frequency (float) – The frequency of the filter from 0.0 to 1.0. Actual frequency is determined by sample rate of audio output.
resonance (float) – The resonance of the filter from 0.0 to 1.0. Actual resonance range is determined by library defaults (typically 0.7 to 8.0).
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_frequency(value: float, synth=None, update: bool = True)¶
Change the frequency of the filter used by the voice. Value provided is a relative number from 0.0 (low frequency) to 1.0 (high frequency). The actual frequency range allowed by the voice is determined by the sample rate of output.
- Parameters:
value (float) – The frequency of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_resonance(value: float, synth=None, update: bool = True)¶
Change the resonance of the filter used by the voice. Value provided is a relative number from 0.0 to 1.0. The actual resonance range allowed by the voice is determined by library defaults (typically 0.7 to 8.0 to avoid feedback).
- Parameters:
value (float) – The resonance of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_type(value: int, synth=None, update: bool = True)¶
Change the type of filter used by the voice. Use one of the filter type constants provided by
pico_synth_sandbox.synth.Synthsuch aspico_synth_sandbox.synth.Synth.FILTER_LPF.- Parameters:
value (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_frequencies(values: list[float])¶
Set the base frequencies of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of the frequencies corresponding to each
synthio.Noteobject in hertz. Voice doesn’t respond to the note frequency when pressed and instead uses these constant frequencies.
- set_level(value: float)¶
Change the overall volume of the voice.
- Parameters:
value (float) – the level of the voice from 0.0 to 1.0
- set_time(value: float = 0.5)¶
Change the decay time of the hi-hat using a relative value and the predefined minimum and maximum times.
- Parameters:
value (float) – The amount of decay time relatively from 0.0 to 1.0. Defaults to 0.5.
- set_times(values: list[float])¶
Set the decay times of the amplitude envelopes of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of decay times corresponding to each
synthio.Noteobjects’ amplitude envelope in seconds.
- set_velocity_amount(value: float)¶
Set the amount that this voice will respond to note velocity, from 0.0 to 1.0. A value of 0.0 represents no response to velocity. The voice will be at full level regardless of note velocity. Whereas a value of 1.0 represents full response to velocity.
- Parameters:
value (float) – the amount of velocity response from 0.0 to 1.0
- set_waveforms(values: list)¶
Set the waveforms of each
synthio.Noteobject of this voice.- Parameters:
values (list) – A list of waveforms corresponding to each
synthio.Noteobject as numpy.int16 arrays. Can be generated using the functions within the synthio.waveform namespace.
- async update(synth)¶
Update all time-based voice logic controlled outside of synthio such as filter modulation.
- Parameters:
synth (
pico_synth_sandbox.synth.Synth) – Thepico_synth_sandbox.synth.Synthobject managing the voice. Used to obtain sample rate and calculate filters.
- class pico_synth_sandbox.voice.drum.Snare[source]¶
Bases:
DrumA single-shot “analog” drum voice representing a snare drum using sine and noise waveforms.
- get_blocks() list[synthio.BlockInput]¶
Get all
synthio.BlockInputobjects attributed to this voice. Needed to register all block inputs within apico_synth_sandbox.synth.Synthobject.- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_notes() list[synthio.Note]¶
Get all
synthio.Noteobjects attributed to this voice. Used by thepico_synth_sandbox.synth.Synthto handle press and release states.- Returns:
list of note objects
- Return type:
list[
synthio.Note]
- press(notenum: int, velocity: float = 1.0) bool¶
Update the voice to be “pressed” with a specific MIDI note number and velocity. Returns whether or not a new note is received. The envelope is updated with the new velocity value regardless.
- Parameters:
notenum (int) – The MIDI note number representing the note frequency.
velocity (float) – The strength at which the note was received, between 0.0 and 1.0.
- Returns:
if a new note was received
- Return type:
bool
- release() bool¶
Release the voice if a note is currently being played.
pico_synth_sandbox.voice.drum.Drumobjects typically don’t implement this operation because of their “single-shot” nature and will always return False.- Returns:
Whether or not a note was currently being played
- Return type:
bool
- set_envelope_attack_level(value: float, update: bool = True)¶
Change the level of attack in the voice amplitude envelope.
- Parameters:
value (float) – The level of amplitude that the voice will reach when completing the attack cycle of the envelope. Value should be between 0.0 and 1.0.
update (bool) – Whether or not to immediately update note envelopes after updating the attack level.
- set_filter(type: int = 0, frequency: float = 1.0, resonance: float = 0.0, synth=None, update: bool = True)¶
Define all settings of the filter used by the voice.
- Parameters:
type (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
frequency (float) – The frequency of the filter from 0.0 to 1.0. Actual frequency is determined by sample rate of audio output.
resonance (float) – The resonance of the filter from 0.0 to 1.0. Actual resonance range is determined by library defaults (typically 0.7 to 8.0).
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_frequency(value: float, synth=None, update: bool = True)¶
Change the frequency of the filter used by the voice. Value provided is a relative number from 0.0 (low frequency) to 1.0 (high frequency). The actual frequency range allowed by the voice is determined by the sample rate of output.
- Parameters:
value (float) – The frequency of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_resonance(value: float, synth=None, update: bool = True)¶
Change the resonance of the filter used by the voice. Value provided is a relative number from 0.0 to 1.0. The actual resonance range allowed by the voice is determined by library defaults (typically 0.7 to 8.0 to avoid feedback).
- Parameters:
value (float) – The resonance of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_type(value: int, synth=None, update: bool = True)¶
Change the type of filter used by the voice. Use one of the filter type constants provided by
pico_synth_sandbox.synth.Synthsuch aspico_synth_sandbox.synth.Synth.FILTER_LPF.- Parameters:
value (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_frequencies(values: list[float])¶
Set the base frequencies of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of the frequencies corresponding to each
synthio.Noteobject in hertz. Voice doesn’t respond to the note frequency when pressed and instead uses these constant frequencies.
- set_level(value: float)¶
Change the overall volume of the voice.
- Parameters:
value (float) – the level of the voice from 0.0 to 1.0
- set_times(values: list[float])¶
Set the decay times of the amplitude envelopes of the
synthio.Noteobjects of this voice.- Parameters:
values (list[float]) – A list of decay times corresponding to each
synthio.Noteobjects’ amplitude envelope in seconds.
- set_velocity_amount(value: float)¶
Set the amount that this voice will respond to note velocity, from 0.0 to 1.0. A value of 0.0 represents no response to velocity. The voice will be at full level regardless of note velocity. Whereas a value of 1.0 represents full response to velocity.
- Parameters:
value (float) – the amount of velocity response from 0.0 to 1.0
- set_waveforms(values: list)¶
Set the waveforms of each
synthio.Noteobject of this voice.- Parameters:
values (list) – A list of waveforms corresponding to each
synthio.Noteobject as numpy.int16 arrays. Can be generated using the functions within the synthio.waveform namespace.
- async update(synth)¶
Update all time-based voice logic controlled outside of synthio such as filter modulation.
- Parameters:
synth (
pico_synth_sandbox.synth.Synth) – Thepico_synth_sandbox.synth.Synthobject managing the voice. Used to obtain sample rate and calculate filters.
Sampler Voice¶
- class pico_synth_sandbox.voice.sample.Sample(loop: bool = True, filepath: str = '')[source]¶
Bases:
OscillatorCreate a synthesizer voice from a provided audio sample. Handles pitch, looping points, and wav file loading and inherits all properties and functionality of the
pico_synth_sandbox.voice.oscillator.Oscillator.- Parameters:
loop (bool) – Whether or not to continuously loop the sample or play it once when the voice is pressed. Defaults to true.
filepath (str) – The absolute path to the compatible audio file (.wav). Leave empty to initialize the voice without a specified sample. Defaults to empty.
- get_blocks()¶
Get all
synthio.BlockInputobjects attributed to this voice. Needed to register all block inputs within apico_synth_sandbox.synth.Synthobject.- Returns:
list of blocks
- Return type:
list[
synthio.BlockInput]
- get_duration() float[source]¶
Calculates the length of the audio sample given the current state (includes note bend properties). Used for determining when to release a note during single-shot sample playback.
- Returns:
The length of the sample playback in seconds.
- Return type:
float
- get_notes()¶
Get all
synthio.Noteobjects attributed to this voice. Used by thepico_synth_sandbox.synth.Synthto handle press and release states.- Returns:
list of note objects
- Return type:
list[
synthio.Note]
- load(data, sample_rate: int, root: float = None)[source]¶
Load waveform data from a sample and calculate root frequency, tuning, duration, and other necessary properties.
- Parameters:
data (
ulab.numpy.ndarray) – A ulab.numpy.int16 array to be used as the audio sample data.sample_rate (int) – The recorded audio sample rate of the incoming sample data.
root (float) – The predesignated root frequency (in hertz) of the recorded audio sample. Used to match pitch frequencies with pressed notes. If left as None, the root frequency will be automatically calculated using the included Fast-Fourier Transform tool, pico_synth_sandbox.fftfreq. Defaults to None.
- load_from_file(filepath: str, max_samples: int = 4096)[source]¶
Load waveform data from an audio .wav file within the virtual file system. The audio sample rate and root frequency will be automatically calculated by the file properties and FFT algorithm.
- Parameters:
filepath (str) – The absolute path to the .wav file.
max_samples (int) – The maximum limit of which to load audio samples from the audio file. Used to avoid memory overflow with large audio files. Defaults to 4096 samples.
- press(notenum: int, velocity: float) bool[source]¶
Update the voice to be “pressed” with a specific MIDI note number and velocity. Returns whether or not a new note is received to avoid unnecessary retriggering. The envelope is updated with the new velocity value regardless. Updating
synthio.Noteobjects should typically occur within the child class after calling this method and checking its return value.- Parameters:
notenum (int) – The MIDI note number representing the note frequency.
velocity (float) – The strength at which the note was received, between 0.0 and 1.0.
- Returns:
if a new note was received
- Return type:
bool
- release()¶
Release the voice if a note is currently being played. Updating
synthio.Noteobjects should typically occur within the child class after calling this method and checking its return value.- Returns:
Whether or not a note was currently being played
- Return type:
bool
- set_filter(type=0, frequency=1.0, resonance=0.0, envelope_attack_time=0.0, envelope_release_time=0.0, envelope_amount=0.0, lfo_rate=1.0, lfo_depth=0.0, synth=None, update=True)¶
Define all settings of the filter used by the voice.
- Parameters:
type (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
frequency (float) – The frequency of the filter from 0.0 to 1.0. Actual frequency is determined by sample rate of audio output.
resonance (float) – The resonance of the filter from 0.0 to 1.0. Actual resonance range is determined by library defaults (typically 0.7 to 8.0).
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_frequency(value: float, synth=None, update: bool = True)¶
Change the frequency of the filter used by the voice. Value provided is a relative number from 0.0 (low frequency) to 1.0 (high frequency). The actual frequency range allowed by the voice is determined by the sample rate of output.
- Parameters:
value (float) – The frequency of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_resonance(value: float, synth=None, update: bool = True)¶
Change the resonance of the filter used by the voice. Value provided is a relative number from 0.0 to 1.0. The actual resonance range allowed by the voice is determined by library defaults (typically 0.7 to 8.0 to avoid feedback).
- Parameters:
value (float) – The resonance of the filter from 0.0 to 1.0.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_filter_type(value: int, synth=None, update: bool = True)¶
Change the type of filter used by the voice. Use one of the filter type constants provided by
pico_synth_sandbox.synth.Synthsuch aspico_synth_sandbox.synth.Synth.FILTER_LPF.- Parameters:
value (int) – The type of filter (LPF=0, HPF=1, BPF=2). An invalid type will default to a band pass filter.
synth (
pico_synth_sandbox.synth.Synth) – The governingpico_synth_sandbox.synth.Synthobject. Must be provided in order to immediately update the filter.update (bool) – Whether or not to immediately update the voice’s filter. Defaults to True.
- set_level(value)¶
Change the overall volume of the voice. This method should be implemented within the child class.
- Parameters:
value (float) – the level of the voice from 0.0 to 1.0
- set_loop(start: float = 0.0, end: float = 1.0)[source]¶
Set the looping parameters of the sample data. Both start and end parameters are relative to the beginning and end of sample data (0.0 - 1.0). Loop points must be at least greater than 2 samples of each other to properly adjust sample tuning.
- Parameters:
start (float) – The starting loop point relative to the sample data length. Must be less than end. Defaults to 0.0.
end (float) – The ending loop point relative to the sample data length. Must be greater than start. Defaults to 1.0.
- set_velocity_amount(value: float)¶
Set the amount that this voice will respond to note velocity, from 0.0 to 1.0. A value of 0.0 represents no response to velocity. The voice will be at full level regardless of note velocity. Whereas a value of 1.0 represents full response to velocity.
- Parameters:
value (float) – the amount of velocity response from 0.0 to 1.0