Class: MicroMIDI::State
- Inherits:
-
Object
- Object
- MicroMIDI::State
- Defined in:
- lib/micromidi/state.rb
Constant Summary
- Default =
{ :channel => 0, :octave => 2, :velocity => 100 }
Instance Attribute Summary (collapse)
-
- (Object) auto_output
Returns the value of attribute auto_output.
-
- (Object) channel
Returns the value of attribute channel.
-
- (Object) inputs
readonly
Returns the value of attribute inputs.
-
- (Object) last_command
readonly
Returns the value of attribute last_command.
-
- (Object) last_note
Returns the value of attribute last_note.
-
- (Object) listeners
readonly
Returns the value of attribute listeners.
-
- (Object) octave
Returns the value of attribute octave.
-
- (Object) output_cache
readonly
Returns the value of attribute output_cache.
-
- (Object) outputs
readonly
Returns the value of attribute outputs.
-
- (Object) start_time
readonly
Returns the value of attribute start_time.
-
- (Object) super_sticky
Returns the value of attribute super_sticky.
-
- (Object) thru_listeners
readonly
Returns the value of attribute thru_listeners.
-
- (Object) velocity
Returns the value of attribute velocity.
Instance Method Summary (collapse)
-
- (State) initialize(ins, outs, options = {})
constructor
A new instance of State.
- - (Object) message_properties(opts, *props)
- - (Object) record(m, a, b, outp)
- - (Object) toggle_auto_output
- - (Object) toggle_super_sticky
Constructor Details
- (State) initialize(ins, outs, options = {})
A new instance of State
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/micromidi/state.rb', line 28 def initialize(ins, outs, = {}) @auto_output = true @last_command = nil @last_note = nil @listeners = [] @thru_listeners = [] @output_cache = [] @start_time = Time.now.to_f @super_sticky = false @channel = [:channel] || Default[:channel] @velocity = [:velocity] || Default[:velocity] @octave = [:octave] || Default[:octave] @inputs = ins @outputs = outs end |
Instance Attribute Details
- (Object) auto_output
Returns the value of attribute auto_output
13 14 15 |
# File 'lib/micromidi/state.rb', line 13 def auto_output @auto_output end |
- (Object) channel
Returns the value of attribute channel
13 14 15 |
# File 'lib/micromidi/state.rb', line 13 def channel @channel end |
- (Object) inputs (readonly)
Returns the value of attribute inputs
20 21 22 |
# File 'lib/micromidi/state.rb', line 20 def inputs @inputs end |
- (Object) last_command (readonly)
Returns the value of attribute last_command
20 21 22 |
# File 'lib/micromidi/state.rb', line 20 def last_command @last_command end |
- (Object) last_note
Returns the value of attribute last_note
13 14 15 |
# File 'lib/micromidi/state.rb', line 13 def last_note @last_note end |
- (Object) listeners (readonly)
Returns the value of attribute listeners
20 21 22 |
# File 'lib/micromidi/state.rb', line 20 def listeners @listeners end |
- (Object) octave
Returns the value of attribute octave
13 14 15 |
# File 'lib/micromidi/state.rb', line 13 def octave @octave end |
- (Object) output_cache (readonly)
Returns the value of attribute output_cache
20 21 22 |
# File 'lib/micromidi/state.rb', line 20 def output_cache @output_cache end |
- (Object) outputs (readonly)
Returns the value of attribute outputs
20 21 22 |
# File 'lib/micromidi/state.rb', line 20 def outputs @outputs end |
- (Object) start_time (readonly)
Returns the value of attribute start_time
20 21 22 |
# File 'lib/micromidi/state.rb', line 20 def start_time @start_time end |
- (Object) super_sticky
Returns the value of attribute super_sticky
13 14 15 |
# File 'lib/micromidi/state.rb', line 13 def super_sticky @super_sticky end |
- (Object) thru_listeners (readonly)
Returns the value of attribute thru_listeners
20 21 22 |
# File 'lib/micromidi/state.rb', line 20 def thru_listeners @thru_listeners end |
- (Object) velocity
Returns the value of attribute velocity
13 14 15 |
# File 'lib/micromidi/state.rb', line 13 def velocity @velocity end |
Instance Method Details
- (Object) message_properties(opts, *props)
60 61 62 63 64 65 66 67 68 |
# File 'lib/micromidi/state.rb', line 60 def (opts, *props) output = {} props.each do |prop| output[prop] = opts[prop] self.send("#{prop.to_s}=", output[prop]) if !output[prop].nil? && (self.send(prop).nil? || @super_sticky) output[prop] ||= self.send(prop.to_s) end output end |
- (Object) record(m, a, b, outp)
46 47 48 49 50 |
# File 'lib/micromidi/state.rb', line 46 def record(m, a, b, outp) ts = now @output_cache << { :message => outp, :timestamp => ts } @last_command = { :method => m, :args => a, :block => b, :timestamp => ts } end |
- (Object) toggle_auto_output
56 57 58 |
# File 'lib/micromidi/state.rb', line 56 def toggle_auto_output @auto_output = !@auto_output end |
- (Object) toggle_super_sticky
52 53 54 |
# File 'lib/micromidi/state.rb', line 52 def toggle_super_sticky @super_sticky = !@super_sticky end |