Class: Topaz::ExternalMIDITempo
- Inherits:
-
Object
- Object
- Topaz::ExternalMIDITempo
- Includes:
- TempoSource
- Defined in:
- lib/topaz/external_midi_tempo.rb
Overview
trigger an event based on received midi clock messages
Instance Attribute Summary collapse
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
Instance Method Summary collapse
-
#initialize(actions, input, options = {}) ⇒ ExternalMIDITempo
constructor
A new instance of ExternalMIDITempo.
-
#interval ⇒ Object
return the interval at which the tick event is fired.
-
#interval=(val) ⇒ Object
change the clock interval defaults to click once every 24 ticks or one quarter note which is the MIDI standard.
- #join ⇒ Object
- #start(*a) ⇒ Object
- #stop(*a) ⇒ Object
-
#tempo ⇒ Object
this will return a calculated tempo.
Methods included from TempoSource
#do_midi_clock, #do_tick, #stop?
Constructor Details
#initialize(actions, input, options = {}) ⇒ ExternalMIDITempo
Returns a new instance of ExternalMIDITempo.
11 12 13 14 15 16 17 18 |
# File 'lib/topaz/external_midi_tempo.rb', line 11 def initialize(actions, input, = {}) @actions = actions self.interval = [:interval] || 4 @tempo_calculator = TempoCalculator.new @clock = MIDIEye::Listener.new(input) initialize_clock end |
Instance Attribute Details
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
9 10 11 |
# File 'lib/topaz/external_midi_tempo.rb', line 9 def clock @clock end |
Instance Method Details
#interval ⇒ Object
return the interval at which the tick event is fired
60 61 62 |
# File 'lib/topaz/external_midi_tempo.rb', line 60 def interval 4 * (24 / @per_tick) end |
#interval=(val) ⇒ Object
change the clock interval defaults to click once every 24 ticks or one quarter note which is the MIDI standard. however, if you wish to fire the on_tick event twice as often (or once per 12 clicks), pass 8
1 = whole note
2 = half note
4 = quarter note
6 = dotted quarter
8 = eighth note
16 = sixteenth note
etc
54 55 56 57 |
# File 'lib/topaz/external_midi_tempo.rb', line 54 def interval=(val) per_qn = val / 4 @per_tick = 24 / per_qn end |
#join ⇒ Object
35 36 37 38 |
# File 'lib/topaz/external_midi_tempo.rb', line 35 def join @clock.join self end |
#start(*a) ⇒ Object
25 26 27 28 |
# File 'lib/topaz/external_midi_tempo.rb', line 25 def start(*a) @clock.start(*a) self end |
#stop(*a) ⇒ Object
30 31 32 33 |
# File 'lib/topaz/external_midi_tempo.rb', line 30 def stop(*a) @clock.stop self end |
#tempo ⇒ Object
this will return a calculated tempo
21 22 23 |
# File 'lib/topaz/external_midi_tempo.rb', line 21 def tempo @tempo_calculator.find_tempo end |