Class: MusaLCEServer::Bitwig::Controllers Private
- Inherits:
-
Object
- Object
- MusaLCEServer::Bitwig::Controllers
- Defined in:
- lib/bitwig/controllers.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Manages Bitwig controller scripts and their MIDI channels.
Controllers in Bitwig represent hardware MIDI devices configured through the MusaLCE controller extension. Each controller has 16 channels that can be named and mapped to tracks.
Instance Attribute Summary collapse
- #tracks ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(midi_devices, clock:, logger:) ⇒ Controllers
constructor
private
Creates a new controllers manager.
-
#register_channels(controller_name:, channels:) ⇒ void
private
Registers channel names for a controller.
-
#register_controller(name:, port_name:, is_clock:) ⇒ void
private
Registers a controller with its port and clock settings.
-
#register_controllers(controllers) ⇒ void
private
Registers or updates the list of available controllers.
-
#update_controller(old_name:, new_name:, port_name:, is_clock:) ⇒ void
private
Updates a controller's name and settings.
Constructor Details
#initialize(midi_devices, clock:, logger:) ⇒ Controllers
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new controllers manager.
18 19 20 21 22 23 24 |
# File 'lib/bitwig/controllers.rb', line 18 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)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/bitwig/controllers.rb', line 28 def tracks @tracks end |
Instance Method Details
#register_channels(controller_name:, channels:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Registers channel names for a controller.
88 89 90 91 92 93 94 95 96 |
# File 'lib/bitwig/controllers.rb', line 88 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:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Registers a controller with its port and clock settings.
58 59 60 61 62 63 |
# File 'lib/bitwig/controllers.rb', line 58 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) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Registers or updates the list of available controllers.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/bitwig/controllers.rb', line 34 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:) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Updates a controller's name and settings.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bitwig/controllers.rb', line 72 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 |