Trigger specific synth

synth  synth_name (symbol)

Trigger specified synth with given opts. Bypasses current_synth value, yet still honours current_synth_defaults. When using synth, the note is no longer an explicit argument but an opt with the key note:.

If note: opt is nil, :r or :rest, play is ignored and treated as a rest. Also, if the on: opt is specified and returns false, or nil then play is similarly ignored and treated as a rest.

If the synth name is nil behaviour is identical to that of play in that the current_synth will determine the actual synth triggered.

If a block is given, it is assumed to take one arg which will be the controllable synth node and the body of the block is run in an implicit in_thread. This allows for asynchronous control of the synth without interfering with time. For synchronous control capture the result of synth as a variable and use that.

Note that the default opts listed are only a guide to the most common opts across all the synths. Not all synths support all the default opts and each synth typically supports many more opts specific to that synth. For example, the :tb303 synth supports 45 unique opts. For a full list of a synth’s opts see its documentation in the Help system. This can be accessed directly by clicking on the name of the synth and using the shortcut C-i

Introduced in v2.0

Examples

# Example 1

use_synth :beep           
play 60                   
synth :dsaw, note: 60   
                        



# Set current synth to :beep
# Play note 60 with opt defaults
# Bypass current synth and play :dsaw
# with note 60 and opt defaults



# Example 2

synth :fm, note: 60, amp: 0.5



# Play note 60 of the :fm synth with an amplitude of 0.5



# Example 3

use_synth_defaults release: 5
synth :dsaw, note: 50



 
# Play note 50 of the :dsaw synth with a release of 5



# Example 4


synth :dsaw, notes: (chord :e3, :minor)



# You can play chords with the notes: opt:
 



# Example 5


notes = (scale :e3, :minor_pentatonic, num_octaves: 2)
live_loop :rhyth do
  8.times do
    trig = (spread 3, 7).tick(:rhyth)
    synth :tri, on: trig, note: notes.tick, release: 0.1 
                                                         
                                                         
    sleep 0.125
  end
end
live_loop :rhyth2 do
  8.times do
    trig = (spread 3, 7).tick(:rhyth)
    synth :saw, note: notes.tick, release: 0.1 if trig 
                                                       
                                                       
    sleep 0.125
  end
end



# on: vs if
 
 
 
 
# Here, we're calling notes.tick
# every time we attempt to play the synth
# so the notes rise faster than rhyth2
 
 
 
 
 
 
# Here, we're calling notes.tick
# only when the spread says to play
# so the notes rise slower than rhyth
 
 
 



# Example 6


s = synth :beep, note: :e3, release: 4
sleep 1
control s, note: :e5
sleep 0.5
synth :dsaw, note: :e3  



# controlling a synth synchronously
 
 
 
 
# This is triggered after 1.5s from start



# Example 7


synth :beep, note: :e3, release: 4 do |s|
  sleep 1                                              
  control s, note: :e5                                 
end
sleep 0.5
synth :dsaw, note: :e3



# Controlling a synth asynchronously
 
# This block is run in an implicit in_thread
# and therefore is asynchronous
 
 
# This is triggered after 0.5s from start