Class: Negasonic::LoopedEvent::Pattern

Inherits:
Object
  • Object
show all
Defined in:
lib/negasonic/looped_event/pattern.rb

Constant Summary collapse

TYPES =
{
  random: 'random',
  random_walk: 'randomWalk',
  random_once: 'randomOnce',
  up: 'up',
  down: 'down',
  up_down: 'upDown',
  down_up: 'downUp',
  alternate_up: 'alternateUp',
  alternate_down: 'alternateDown'
}

Instance Method Summary collapse

Constructor Details

#initialize(synth, notes = []) ⇒ Pattern

Returns a new instance of Pattern.



16
17
18
19
# File 'lib/negasonic/looped_event/pattern.rb', line 16

def initialize(synth, notes = [])
  @synth = synth
  @notes = LoopedEvent.to_tone_notes(notes)
end

Instance Method Details

#start(duration, type) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/negasonic/looped_event/pattern.rb', line 21

def start(duration, type)
  raise 'invalid pattern type' unless TYPES.keys.include?(type)

  do_start(duration, TYPES[type]) do |time, note|
    @synth.trigger_attack_release(note, duration, time)
  end
end