Class: MusaLCEServer::Bitwig::Controllers Private

Inherits:
Object
  • Object
show all
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.

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Parameters:

  • midi_devices (MIDIDevices)

    the MIDI devices manager

  • clock (Musa::Clock::InputMidiClock)

    the MIDI clock

  • logger (Logger)

    the logger

Since:

  • 0.1.0



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

#tracksObject (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.

Since:

  • 0.1.0



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.

Parameters:

  • controller_name (String)

    the controller name

  • channels (Array<String>)

    channel names (up to 16)

Since:

  • 0.1.0



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.

Parameters:

  • name (String)

    the controller name

  • port_name (String)

    the MIDI port name

  • is_clock (Boolean)

    whether this controller provides MIDI clock

Since:

  • 0.1.0



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.

Parameters:

  • controllers (Array<String>)

    controller names from Bitwig

Since:

  • 0.1.0



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.

Parameters:

  • old_name (String)

    the current controller name

  • new_name (String)

    the new controller name

  • port_name (String)

    the MIDI port name

  • is_clock (Boolean)

    whether this controller provides MIDI clock

Since:

  • 0.1.0



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