lib/xi/midi/stream.rb in xi-midi-0.1.3 vs lib/xi/midi/stream.rb in xi-midi-0.1.4
- old
+ new
@@ -3,11 +3,11 @@
module Xi::MIDI
class Stream < Xi::Stream
attr_accessor :device, :channel
- def initialize(name, clock, device: 0, channel: 0)
+ def initialize(name, clock, device: 0, channel: 0, **opts)
super
@device = device
@channel = channel
@playing_notes = {}
@@ -73,10 +73,15 @@
def do_state_change
debug "State change: #{changed_state}"
changed_state.each do |p, vs|
- cc_id = cc_parameters[p]
+ cc_id = if p.to_s.start_with?('cc_')
+ p.to_s.split('_')[1].to_i
+ else
+ cc_parameters[p]
+ end
+
Array(vs).each { |v| midi.cc(@device, channel, cc_id, v.to_i) } if cc_id
end
end
# @override