Class: Zgomot::Midi::Dispatcher
Class Attribute Summary collapse
-
.clock ⇒ Object
readonly
Returns the value of attribute clock.
-
.playing ⇒ Object
readonly
Returns the value of attribute playing.
-
.qdispatch ⇒ Object
readonly
Returns the value of attribute qdispatch.
-
.qmutex ⇒ Object
readonly
Returns the value of attribute qmutex.
-
.queue ⇒ Object
readonly
Returns the value of attribute queue.
-
.resolution ⇒ Object
readonly
Returns the value of attribute resolution.
-
.thread ⇒ Object
readonly
Returns the value of attribute thread.
-
.tick ⇒ Object
readonly
Returns the value of attribute tick.
Class Method Summary collapse
Class Attribute Details
.clock ⇒ Object (readonly)
Returns the value of attribute clock.
13 14 15 |
# File 'lib/zgomot/midi/dispatcher.rb', line 13 def clock @clock end |
.playing ⇒ Object (readonly)
Returns the value of attribute playing.
13 14 15 |
# File 'lib/zgomot/midi/dispatcher.rb', line 13 def @playing end |
.qdispatch ⇒ Object (readonly)
Returns the value of attribute qdispatch.
13 14 15 |
# File 'lib/zgomot/midi/dispatcher.rb', line 13 def qdispatch @qdispatch end |
.qmutex ⇒ Object (readonly)
Returns the value of attribute qmutex.
13 14 15 |
# File 'lib/zgomot/midi/dispatcher.rb', line 13 def qmutex @qmutex end |
.queue ⇒ Object (readonly)
Returns the value of attribute queue.
13 14 15 |
# File 'lib/zgomot/midi/dispatcher.rb', line 13 def queue @queue end |
.resolution ⇒ Object (readonly)
Returns the value of attribute resolution.
13 14 15 |
# File 'lib/zgomot/midi/dispatcher.rb', line 13 def resolution @resolution end |
.thread ⇒ Object (readonly)
Returns the value of attribute thread.
13 14 15 |
# File 'lib/zgomot/midi/dispatcher.rb', line 13 def thread @thread end |
.tick ⇒ Object (readonly)
Returns the value of attribute tick.
13 14 15 |
# File 'lib/zgomot/midi/dispatcher.rb', line 13 def tick @tick end |
Class Method Details
.clk ⇒ Object
15 16 17 |
# File 'lib/zgomot/midi/dispatcher.rb', line 15 def clk clock.to_s end |
.dequeue ⇒ Object
35 36 37 38 39 |
# File 'lib/zgomot/midi/dispatcher.rb', line 35 def dequeue qmutex.synchronize do queue.partition{|n| n.note_on.to_f <= clock.current_time.to_f} end end |
.done? ⇒ Boolean
23 24 25 |
# File 'lib/zgomot/midi/dispatcher.rb', line 23 def done? qmutex.synchronize{queue.empty? and .empty?} end |
.enqueue(ch) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/zgomot/midi/dispatcher.rb', line 27 def enqueue(ch) ch.offset = clock.ceil qmutex.synchronize do pattern = ch.pattern.map{|p| p.to_midi}.flatten.compact.select{|n| not n.pitch_class.eql?(:R)} @queue += pattern end end |
.flush ⇒ Object
19 20 21 |
# File 'lib/zgomot/midi/dispatcher.rb', line 19 def flush @queue.clear end |