# Control running synth

``

    control  node (synth_node)

Control a running synth node by passing new parameters to it. A synth node represents a running synth and can be obtained by assigning the return value of a call to play or sample or by specifying a parameter to the do/end block of an FX. You may modify any of the parameters you can set when triggering the synth, sample or FX. See documentation for opt details. If the synth to control is a chord, then control will change all the notes of that chord group at once to a new target set of notes - see example. Also, you may use the on: opt to conditionally trigger the control - see the docs for the `synth` and `sample` fns for more information.

Introduced in v2.0

## Examples

# Example 1
``
    my_node = play 50, release: 5, cutoff: 60
    sleep 1
    control my_node, cutoff: 70
    sleep 1
    control my_node, cutoff: 90
| ``
    # Basic control

    # play note 50 with release of 5 and cutoff of 60. Assign return value to variable my_node
    # Sleep for a second
    # Now modify cutoff from 60 to 70, sound is still playing
    # Sleep for another second
    # Now modify cutoff from 70 to 90, sound is still playing
# Example 2
``
    s = synth :prophet, note: :e1, cutoff: 70, cutoff_slide: 8, release: 8
    control s, cutoff: 130
| ``
    # Combining control with slide opts allows you to create nice transitions.

    # start synth and specify slide time for cutoff opt
    # Change the cutoff value with a control.
    # Cutoff will now slide over 8 beats from 70 to 130
# Example 3
``
    notes = (scale :e3, :minor_pentatonic, num_octaves: 2).shuffle

    s = synth :beep, note: :e3, sustain: 8, note_slide: 0.05
    64.times do
      control s, note: notes.tick
      sleep 0.125
    end
| ``
    # Use a short slide time and many controls to create a sliding melody

    # get a random ordering of a scale

    # Start our synth running with a long sustain and short note slide time

    # Keep quickly changing the note by ticking through notes repeatedly
# Example 4
``
    with_fx :bitcrusher, sample_rate: 1000, sample_rate_slide: 8 do |bc|

      sample :loop_garzul, rate: 1
      control bc, sample_rate: 5000

    end
| ``
    # Controlling FX

    # Start FX but also use the handy || goalposts
    # to grab a handle on the running FX. We can call
    # our handle anything we want. Here we've called it bc

    # We can use our handle bc now just like we used s in the
    # previous example to modify the FX as it runs.
# Example 5
``
    cg = play (chord :e4, :minor), sustain: 2
    sleep 1
    control cg, notes: (chord :c3, :major)
| ``
    # Controlling chords
    # start a chord

    # transition to new chord.
    # Each note in the original chord is mapped onto
    # the equivalent in the new chord.
# Example 6
``
    cg = play (chord :e4, :minor), sustain: 4, note_slide: 3
    sleep 1
    control cg, notes: (chord :c3, :major)
| ``
    # Sliding between chords

    # start a chord

    # slide to new chord.
    # Each note in the original chord is mapped onto
    # the equivalent in the new chord.
# Example 7
``
    cg = play (chord :e3, :m13), sustain: 4, note_slide: 3
    sleep 1
    control cg, notes: (chord :c3, :major)
| ``
    # Sliding from a larger to smaller chord
    # start a chord with 7 notes

    # slide to new chord with fewer notes (3)
    # Each note in the original chord is mapped onto
    # the equivalent in the new chord using ring-like indexing.
    # This means that the 4th note in the original chord will
    # be mapped onto the 1st note in the second chord and so-on.
# Example 8
``
    cg = play (chord :c3, :major), sustain: 4, note_slide: 3
    sleep 1
    control cg, notes: (chord :e3, :m13)
| ``
    # Sliding from a smaller to larger chord
    # start a chord with 3 notes

    # slide to new chord with more notes (7)
    # Each note in the original chord is mapped onto
    # the equivalent in the new chord.
    # This means that the 4th note in the new chord
    # will not sound as there is no 4th note in the
    # original chord.