Class: Sequencer::Core
- Inherits:
-
Object
- Object
- Sequencer::Core
- Defined in:
- lib/sequencer/core.rb
Overview
The core sequencer
Instance Attribute Summary collapse
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#loop ⇒ Object
readonly
Returns the value of attribute loop.
-
#pointer ⇒ Object
Returns the value of attribute pointer.
-
#trigger ⇒ Object
readonly
Returns the value of attribute trigger.
Instance Method Summary collapse
-
#exec(sequence) ⇒ Boolean
Execute a single cycle of sequencing (perform and step).
-
#initialize ⇒ Core
constructor
A new instance of Core.
-
#perform(sequence) ⇒ Boolean
Represents performance of a single sequence frame.
-
#reset_pointer ⇒ Fixnum
Set the pointer to the loop start point.
-
#step(sequence) ⇒ Boolean
Step the sequencer and fire Event#step event.
Constructor Details
Instance Attribute Details
#event ⇒ Object (readonly)
Returns the value of attribute event.
6 7 8 |
# File 'lib/sequencer/core.rb', line 6 def event @event end |
#loop ⇒ Object (readonly)
Returns the value of attribute loop.
6 7 8 |
# File 'lib/sequencer/core.rb', line 6 def loop @loop end |
#pointer ⇒ Object
Returns the value of attribute pointer.
7 8 9 |
# File 'lib/sequencer/core.rb', line 7 def pointer @pointer end |
#trigger ⇒ Object (readonly)
Returns the value of attribute trigger.
6 7 8 |
# File 'lib/sequencer/core.rb', line 6 def trigger @trigger end |
Instance Method Details
#exec(sequence) ⇒ Boolean
Execute a single cycle of sequencing (perform and step)
19 20 21 |
# File 'lib/sequencer/core.rb', line 19 def exec(sequence) perform(sequence) && step(sequence) end |
#perform(sequence) ⇒ Boolean
Represents performance of a single sequence frame
Order of events:
-
If Event#next for the current pointer, fire
-
If EventTrigger#stop, fire Event#stop, otherwise:
-
If EventTrigger#reset, fire Event#reset
-
Fire Event#perform with the sequence frame
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/sequencer/core.rb', line 47 def perform(sequence) data = sequence.at(@pointer) @event.do_next(@pointer, data) if @event.next?(@pointer) if @trigger.stop?(@pointer, data) @event.do_stop false else reset_pointer if @trigger.reset?(@pointer, data) @event.do_perform(data) true end end |
#reset_pointer ⇒ Fixnum
Set the pointer to the loop start point
62 63 64 |
# File 'lib/sequencer/core.rb', line 62 def reset_pointer @pointer = @loop.next end |
#step(sequence) ⇒ Boolean
Step the sequencer and fire Event#step event
26 27 28 29 30 31 32 33 34 |
# File 'lib/sequencer/core.rb', line 26 def step(sequence) if reset_pointer?(:length => sequence.length) reset_pointer else @pointer += 1 end @event.do_step true end |