class SynthBlocks::Sequencer::SequencerDSL::Song
A
Public Instance Methods
length()
click to toggle source
Returns the length of the song in seconds plus 2 seconds to allow for reverb tails etc.
# File lib/synth_blocks/sequencer/sequencer_dsl.rb, line 169 def length (@latest_time + 2.0).ceil end
pattern(name, at: 0, repeat: 1, length: nil)
click to toggle source
inserts a pattern into the song
- name
-
pattern needs to be defined by
def_pattern
- at
-
Position in bars to insert the pattern to
- repeat
-
number of times the pattern should repeat
- length
-
if you want to only use part of the pattern
# File lib/synth_blocks/sequencer/sequencer_dsl.rb, line 145 def pattern(name, at: 0, repeat: 1, length: nil) p = @patterns[name] pattern_length = length || p.steps start = at.to_f * @per_bar p.sounds.each do |sound, events| repeat.times do |rep| events.each do |event| step, data = event next if step > pattern_length time = start + (rep.to_f * pattern_length.to_f * @per_step.to_f) + step.to_f * @per_step @latest_time = time if time > @latest_time type, *rest = data @events << [sound, [type, time, *rest]] end end end end
play()
click to toggle source
Sends all scheduled events to the instruments
# File lib/synth_blocks/sequencer/sequencer_dsl.rb, line 175 def play @events.each do |event| instrument, data = event instrument.send(*data) end end