ipytone.AMOscillator#

class ipytone.AMOscillator(**kwargs: Any)#

Bases: Oscillator

An amplitude modulated oscillator.

It is implemented with two oscillators, one which modulates the other’s amplitude through a gain node.

Parameters:

harmonicity (float, optional) – Frequency ratio between the carrier and the modulator oscillators. A value of 1 (default) gives both oscillators the same frequency. A value of 2 means a change of an octave. Must be > 0.

__init__(harmonicity=1, **kwargs)#

Public constructor

Methods

chain(*nodes)

Connect the output of this audio node to the other audio nodes in series.

connect(destination[, output_number, ...])

Connect the output of this audio node to the input of another node.

disconnect(destination[, output_number, ...])

Disconnect the ouput of this audio node from a connected node.

dispose()

Dispose and disconnect this audio node (as well as its input/output).

fan(*destinations)

Connect the output of this audio node to the destinations audio nodes in parallel.

schedule_dlink(target[, update_interval, ...])

Link a source attribute of this ipytone widget with a target widget attribute.

schedule_jsdlink(target[, update_interval, ...])

Link a source attribute of this ipytone widget with a target widget attribute.

schedule_observe(handler[, update_interval, ...])

Setup a handler to be called at regular intervals with the updated time / value of this ipytone widget.

schedule_unobserve(handler)

Cancel the scheduled updates of the time / value trait associated with the given handler.

start([time, offset, duration])

Start the audio source.

stop([time])

Stop the audio source.

sync()

Sync the source to the transport.

to_destination()

Convenience method to directly connect the output of this audio node to the main output (speakers) node.

unsync()

Unsync the source to the transport.

Attributes

array

Oscillator waveform

array_length

Oscillator waveform resolution (array length)

base_type

Oscillator wave type without partials.

channel_count

An int trait.

channel_count_mode

An enum whose value must be in a given sequence.

channel_interpretation

An enum whose value must be in a given sequence.

detune

Oscillator detune.

disposed

Returns True if the node was disposed (i.e., disconnected and web audio node freed for garbage collection).

frequency

Oscillator frequency.

harmonicity

Frequency ratio between the carrier and the modulator oscillators.

input

Returns the input node, or None if this node is a source.

log

A trait whose value must be an instance of a specified class.

modulation_type

The type of the modulator oscillator

mute

Mute source

name

A trait for unicode strings.

number_of_inputs

Returns the number of input slots for the input node (0 for source nodes).

number_of_outputs

Returns the number of output slots for the output node (0 for sink nodes).

output

Returns the output node, or None if this node is a sink.

partial_count

Number of harmonics which are used to generate the waveform.

partials

Relative amplitude of each of the harmonics of the oscillator.

phase

Starting position within the oscillator's cycle

sync_array

if True, synchronize waveform

type

Oscillator type

volume

The volume parameter.

array#

Oscillator waveform

array_length#

Oscillator waveform resolution (array length)

property base_type#

Oscillator wave type without partials.

chain(*nodes)#

Connect the output of this audio node to the other audio nodes in series.

connect(destination, output_number=0, input_number=0)#

Connect the output of this audio node to the input of another node.

Parameters:
  • destination (AudioNode or NativeAudioNode or Param or NativeAudioParam) – The destination node.

  • output_number (int) – The channel number of the output of this node (default: 0).

  • input_number (int) – The channel number of the input of the destination node (default: 0).

property detune: Signal#

Oscillator detune.

disconnect(destination, output_number=0, input_number=0)#

Disconnect the ouput of this audio node from a connected node.

Parameters:
  • destination (AudioNode or NativeAudioNode or Param or NativeAudioParam) – The connected destination node.

  • output_number (int) – The channel number of the output of this node (default: 0).

  • input_number (int) – The channel number of the input of the destination node (default: 0).

dispose()#

Dispose and disconnect this audio node (as well as its input/output).

property disposed#

Returns True if the node was disposed (i.e., disconnected and web audio node freed for garbage collection).

fan(*destinations)#

Connect the output of this audio node to the destinations audio nodes in parallel.

property frequency: Signal#

Oscillator frequency.

property harmonicity: Multiply#

Frequency ratio between the carrier and the modulator oscillators.

property input#

Returns the input node, or None if this node is a source.

modulation_type#

The type of the modulator oscillator

mute#

Mute source

property number_of_inputs#

Returns the number of input slots for the input node (0 for source nodes).

property number_of_outputs#

Returns the number of output slots for the output node (0 for sink nodes).

property output#

Returns the output node, or None if this node is a sink.

property partial_count#

Number of harmonics which are used to generate the waveform.

If the value equals zero, the maximum number of partials are used.

property partials#

Relative amplitude of each of the harmonics of the oscillator.

The 1st value is the fundamental frequency, the 2nd value is an octave up, etc.

phase#

Starting position within the oscillator’s cycle

Link a source attribute of this ipytone widget with a target widget attribute.

As the source attribute may have a continuously updated value (e.g., the gain of an audio signal, the current value of a parameter, etc.), The target widget attribute is synchronized at a given, finite resolution.

Parameters:
  • target ((object, str) tuple) – The target widget attribute to link, given as a (widget, attr_name) tuple.

  • update_interval (float or string, optional) – The interval at which the target attribute is updated in the front-end, in seconds (default: 0.04). If transport=True, any interval accepted by schedule_repeat() is also valid here.

  • transport (bool, optional) – if True, the target attribute is synced along the ipytone.Transport timeline, i.e., no update happens until the transport starts and updates stop when the transport stops. If False (default), the target attribute update is done with respect to the active audio context.

  • name (str, optional) – The name of the (source) Tone.js attribute to link. See schedule_observe for more details and for a list of available names.

Returns:

link – A link object that can be used to unlink the widget attributes (using the .unlink() method).

Return type:

ToneDirectionalLink

Link a source attribute of this ipytone widget with a target widget attribute.

The link is created in the front-end and does not rely on a roundtrip to the backend.

As the source attribute may have a continuously updated value (e.g., the gain of an audio signal, the current value of a parameter, etc.), The target widget attribute is synchronized at a given, finite resolution.

Parameters:
  • target ((object, str) tuple) – The target widget attribute to link, given as a (widget, attr_name) tuple.

  • update_interval (float or string, optional) – The interval at which the target attribute is updated in the front-end, in seconds (default: 0.04). If transport=True, any interval accepted by schedule_repeat() is also valid here.

  • transport (bool, optional) – if True, the target attribute is synced along the ipytone.Transport timeline, i.e., no update happens until the transport starts and updates stop when the transport stops. If False (default), the target attribute update is done with respect to the active audio context.

  • name (str, optional) – The name of the (source) Tone.js attribute to link. See schedule_observe for more details and for a list of available names.

Returns:

link – A link object that can be used to unlink the widget attributes (using the .unlink() method).

Return type:

ToneDirectionalLink

schedule_observe(handler, update_interval=1, transport=False, name=None, observe_time=False)#

Setup a handler to be called at regular intervals with the updated time / value of this ipytone widget.

Parameters:
  • handler (callable) – A callable that is called when the trait value is updated at regular intervals. The signature of the callable is similar to the signature expected by ipywidgets.Widget.observe(). Note that the handler will only apply to the trait given by the name argument here.

  • update_interval (float or string, optional) – The interval at which the trait is updated in the front-end, in seconds (default: 1). If transport=True, any interval accepted by schedule_repeat() is also valid here.

  • transport (bool, optional) – if True, the trait update is scheduled along the ipytone.Transport timeline, i.e., the handler is not called until the transport starts and will stop being called when the transport stops. If False (default), the trait update is done with respect to the active audio context.

  • name (str, optional) –

    The name of the Tone.js attribute to observe. Note that it doesn’t necessarily correspond to a trait of this ipytone widget. Instead, it may accept one of the following names (depending the observed ipytone widget, only a few may be supported):

    • ”time”: the current time (either transport time or audio context time).

    • ”value”: the current value of the Tone.js corresponding instance.

    • ”state”: current playback state

    • ”progress”: current progress (of an event or transport loop)

    • ”position”: current transport position in Bars:Beats:Sixteenths

    • ”ticks”: current transport tick position

    • ”seconds”: current transport time in seconds

    The default name also depends on the observed ipytone widget.

  • observe_time (bool, optional) – If True, both the (current audio context or transport) time and trait value are passed to the handler as a (time, trait_value) tuple when the trait value is updated (default: False).

schedule_unobserve(handler)#

Cancel the scheduled updates of the time / value trait associated with the given handler.

start(time=None, offset=None, duration=None)#

Start the audio source.

If it’s already started, this will stop and restart the source.

stop(time=None)#

Stop the audio source.

sync()#

Sync the source to the transport.

All subsequent calls to start and stop are synced to the transport time instead of the audio context time.

sync_array#

if True, synchronize waveform

to_destination()#

Convenience method to directly connect the output of this audio node to the main output (speakers) node.

type#

Oscillator type

unsync()#

Unsync the source to the transport.

property volume: Param#

The volume parameter.