Method: SynthBlocks::Drum::SnareDrum#run

Defined in:
lib/synth_blocks/drum/snare_drum.rb

#run(offset) ⇒ Object

run the generator



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/synth_blocks/drum/snare_drum.rb', line 69

def run(offset)
  drum_out = @drum.run(offset)
  # time in seconds
  t = time(offset)
  events = active_events(t)
  if events.empty?
    0.0
  else
    event = events[events.keys.last]
    # lfo_out = (@lfo.run(@preset[:lfo_frequency], waveform: @preset[:lfo_waveform]) + 1) / 8 + 0.5
    noise_out = rand * 2.0 - 1.0
    local_started = t - event[:started]
    noise_out = @filter.run(noise_out, @preset[:flt_frequency] + @flt_env.run(local_started) * @preset[:flt_envmod], @preset[:flt_Q])
    noise_out = 0.3 * noise_out * @amp_env.run(local_started)
    noise_out * @preset[:noise_vol] + drum_out * @preset[:drum_vol]
  end
end