Use studio fx

with_fx

[fx_name (symbol)]

This applies the named effect (FX) to everything within a given do/end block. Effects may take extra parameters to modify their behaviour. See FX help for parameter details. For advanced control, it is also possible to modify the parameters of an effect within the body of the block. If you define the block with a single argument, the argument becomes a reference to the current effect and can be used to control its parameters (see examples).

Introduced in v2.0.0

Example 0 


# Basic usage
with_fx :distortion do
  play 50
  sleep 1
  sample :loop_amen
end


 
 
 # Use the distortion effect with default parameters
 # => plays note 50 with distortion
 
 # => plays the loop_amen sample with distortion too
 



Example 1 


# Specify effect parameters
with_fx :level, amp: 0.3 do
  play 50
  sleep 1
  sample :loop_amen
end


 
 
 # Use the level effect with the amp parameter set to 0.3
 
 
 
 



Example 2 


# Controlling the effect parameters within the block
with_fx :reverb, mix: 0.1 do |fx|
 
 

  play 60
  sleep 2

  control fx, mix: 0.5
  play 60
  sleep 2

  control fx, mix: 1
  play 60
  sleep 2
end


 
 
 
 # here we set the reverb level quite low to start with (0.1)
 # and we can change it later by using the 'fx' reference we've set up
 
 # plays note 50 with a little bit of reverb
 
 
 # change the parameters of the effect to add more reverb
 # again note 60 but with more reverb
 
 
 # change the parameters of the effect to add more reverb
 # plays note 60 with loads of reverb