What is a <FX>.ctl reference for using synths within FX?

I ran across a very cool gist by @xavierriley to emulate the wobble sound of dubstep synths. In the wob function I saw something that I have a question about:

# WOBBLE BASS 
define :wob do
  use_synth :dsaw
  lowcut = note(:E1) # ~ 40Hz
  highcut = note(:G8) # ~ 3000Hz
  
  note = [40, 41, 28, 28, 28, 27, 25, 35].choose
  
  duration = 2.0
  bpm_scale = (60 / current_bpm).to_f
  distort = 0.2
  
  # scale the note length based on current tempo
  slide_duration = duration * bpm_scale
  
  # Distortion helps give crunch
  with_fx :distortion, distort: distort do
  
    # rlpf means "Resonant low pass filter"
    with_fx :rlpf, cutoff: lowcut, cutoff_slide: slide_duration do |c|
      play note, attack: 0, sustain: duration, release: 0
 
      # 6/4 rhythms
      wobble_time = [1, 6, 6, 2, 1, 2, 4, 8, 3, 3, 16].choose
      c.ctl cutoff_slide: ((duration / wobble_time.to_f) / 2.0)
 
      # Playing with the cutoff gives us the wobble!
      # low cutoff    -> high cutoff        -> low cutoff
      # few harmonics -> loads of harmonics -> few harmonics
      # wwwwwww -> oooooooo -> wwwwwwww
      # 
      # N.B.
      # * The note is always the same length *
      # * the wobble time just specifies how many * 
      # * 'wow's we fit in that space *
      wobble_time.times do
        c.ctl cutoff: highcut
        sleep ((duration / wobble_time.to_f) / 2.0)
        c.ctl cutoff: lowcut 
        sleep ((duration / wobble_time.to_f) / 2.0)
      end
    end
  end
end

In the code above, there is a handle |c| for the :rlpf FX. This is then used to do things like c.ctl <more synth args>. Is this a way to reference the :dsaw synth within the :rlpf FX?

I imagine the need for this is because in this case we want to be able to dynamically adjust cutoff_slide and cutoff. Am I right about that? Is there a simpler way to do the same thing such as assigning a my_synth = synth :dsaw then doing the same thing like my_synth cutoff: highcut for example?

Yup this works

my_synth = synth :dsaw,note: :e3,release: 10,cutoff: 30
control my_synth, cutoff: 120,cutoff_slide: 5 #preferred sonic pi notation
sleep 5
my_synth.ctl cutoff: 30,cutoff_slide: 5 #though this works too

.ctl works although not documented in Sonic Pi. control ptr, is preferred and documented

1 Like