Class: Bitwig::Controllers
- Inherits:
-
Object
- Object
- Bitwig::Controllers
- Defined in:
- lib/bitwig/controllers.rb
Instance Attribute Summary collapse
-
#tracks ⇒ Object
readonly
Returns the value of attribute tracks.
Instance Method Summary collapse
-
#initialize(midi_devices, clock:, logger:) ⇒ Controllers
constructor
A new instance of Controllers.
- #register_channels(controller_name:, channels:) ⇒ Object
- #register_controller(name:, port_name:, is_clock:) ⇒ Object
- #register_controllers(controllers) ⇒ Object
- #update_controller(old_name:, new_name:, port_name:, is_clock:) ⇒ Object
Constructor Details
#initialize(midi_devices, clock:, logger:) ⇒ Controllers
Returns a new instance of Controllers.
5 6 7 8 9 10 11 |
# File 'lib/bitwig/controllers.rb', line 5 def initialize(midi_devices, clock:, logger:) @midi_devices = midi_devices @clock = clock @logger = logger @controllers = {} @tracks = Tracks.new(logger: logger) end |
Instance Attribute Details
#tracks ⇒ Object (readonly)
Returns the value of attribute tracks.
13 14 15 |
# File 'lib/bitwig/controllers.rb', line 13 def tracks @tracks end |
Instance Method Details
#register_channels(controller_name:, channels:) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/bitwig/controllers.rb', line 51 def register_channels(controller_name:, channels:) controller = @controllers[controller_name] @logger.info "Channels for controller #{controller_name} named #{channels}" channels.each.with_index do |name, i| controller.channels[i].name = name end end |
#register_controller(name:, port_name:, is_clock:) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/bitwig/controllers.rb', line 33 def register_controller(name:, port_name:, is_clock:) controller = @controllers[name] controller.port_name = port_name controller.is_clock = is_clock @logger.info "Controller #{name} defined with port_name #{port_name} clock #{is_clock}" end |
#register_controllers(controllers) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bitwig/controllers.rb', line 15 def register_controllers(controllers) to_delete = @controllers.keys - controllers controllers.each do |controller_name| if @controllers.key?(controller_name) @logger.info "Controller #{controller_name} already exists" else @logger.info "Added controller #{controller_name}" @controllers[controller_name] = Controller.new(controller_name, @midi_devices, @clock, @tracks, logger: @logger) end end to_delete.each do |controller_name| @controllers.delete(controller_name) @logger.info "Deleted controller #{controller_name}" end end |
#update_controller(old_name:, new_name:, port_name:, is_clock:) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bitwig/controllers.rb', line 40 def update_controller(old_name:, new_name:, port_name:, is_clock:) controller = @controllers.delete(old_name) @controllers[new_name] = controller controller.name = new_name controller.port_name = port_name controller.is_clock = is_clock @logger.info "Controller #{old_name} updated as #{new_name} with port_name #{port_name} clock #{is_clock}" end |