Class: SynthBlocks::Drum::TunedDrum

Inherits:
KickDrum show all
Defined in:
lib/synth_blocks/drum/tuned_drum.rb

Overview

Special case of the kick drum that allows to run it from a note pattern to create percussive sounds

Instance Attribute Summary

Attributes inherited from Core::Sound

#mode

Instance Method Summary collapse

Methods inherited from KickDrum

#duration, #initialize

Methods inherited from Core::Sound

#active_events, #duration, #get, #initialize, #live_params, #release, #set, #start, #stop

Constructor Details

This class inherits a constructor from SynthBlocks::Drum::KickDrum

Instance Method Details

#run(offset) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/synth_blocks/drum/tuned_drum.rb', line 9

def run(offset)
  t = time(offset)
  events = active_events(t)
  if events.empty?
    0.0
  else
    event = events[events.keys.last]
    note = events.keys.last
    base_freq = frequency(note)
    local_started = t - event[:started]
    osc_out = @oscillator.run(base_freq + @pitch_env.run(local_started) * @preset[:pitch_mod].to_f, waveform: :sine)
    osc_out = osc_out * 1.0 * @amp_env.run(local_started)
  end
end