Class: Diamond::Sequence
- Inherits:
-
Object
- Object
- Diamond::Sequence
- Extended by:
- Forwardable
- Defined in:
- lib/diamond/sequence.rb
Overview
The note event sequence from where the arpeggiator output is derived
Instance Method Summary collapse
-
#add(*note_messages) ⇒ Boolean
Add inputted note_messages.
-
#at(pointer) ⇒ Array<MIDIMessage>
The bucket of messages for the given pointer.
-
#changed? ⇒ Boolean
Has the sequence changed since the last update?.
-
#initialize ⇒ Sequence
constructor
A new instance of Sequence.
-
#mark_changed ⇒ Boolean
Mark the sequence as changed.
-
#pending_note_offs ⇒ Array<MIDIMessage::NoteOff>
All NoteOff messages in the queue.
-
#remove(*note_messages) ⇒ Boolean
Remove input note messages with the same note value.
-
#remove_all ⇒ Boolean
Remove all input note messages.
Constructor Details
#initialize ⇒ Sequence
Returns a new instance of Sequence.
10 11 12 13 14 15 16 |
# File 'lib/diamond/sequence.rb', line 10 def initialize @parameter = nil # realtime @changed = false @input_queue = [] @queue = [] end |
Instance Method Details
#add(*note_messages) ⇒ Boolean
Add inputted note_messages
39 40 41 42 43 44 |
# File 'lib/diamond/sequence.rb', line 39 def add(*) = [].flatten.compact @input_queue.concat() mark_changed true end |
#at(pointer) ⇒ Array<MIDIMessage>
The bucket of messages for the given pointer
21 22 23 24 25 26 27 28 |
# File 'lib/diamond/sequence.rb', line 21 def at(pointer) if changed? && (pointer % @parameter.rate == 0) update end enqueue_next(pointer) = @queue.shift || [] end |
#changed? ⇒ Boolean
Has the sequence changed since the last update?
32 33 34 |
# File 'lib/diamond/sequence.rb', line 32 def changed? @changed end |
#mark_changed ⇒ Boolean
Mark the sequence as changed
78 79 80 |
# File 'lib/diamond/sequence.rb', line 78 def mark_changed @changed = true end |
#pending_note_offs ⇒ Array<MIDIMessage::NoteOff>
All NoteOff messages in the queue
67 68 69 70 71 72 73 74 |
# File 'lib/diamond/sequence.rb', line 67 def pending_note_offs = @queue.map do |bucket| unless bucket.nil? bucket.select { |m| m.class == MIDIMessage::NoteOff } end end .flatten.compact end |
#remove(*note_messages) ⇒ Boolean
Remove input note messages with the same note value
49 50 51 52 53 54 55 |
# File 'lib/diamond/sequence.rb', line 49 def remove(*) = [].flatten deletion_queue = .map(&:note) @input_queue.delete_if { || deletion_queue.include?(.note) } mark_changed true end |
#remove_all ⇒ Boolean
Remove all input note messages
59 60 61 62 63 |
# File 'lib/diamond/sequence.rb', line 59 def remove_all @input_queue.clear mark_changed true end |