Module: SonicPiAkaiApcMini::Controller

Defined in:
lib/sonic-pi-akai-apc-mini/controller.rb

Defined Under Namespace

Classes: Error, Model

Constant Summary collapse

Configs =
{
  apc_mini: {
    midi_port: 'apc_mini*',
    grid_rows: 8,
    grid_columns: 8,
    grid_offset: 0,
    fader_count: 9,
    fader_offset: 48,
    fader_light_offset: 16,
    light_off: 0,
    light_green: 1,
    light_red: 3,
    light_yellow: 5
  },
  # TODO: Some assumptions here, check!
  apc_key_25: {
    midi_port: 'apc_key_25*', # TODO: this is just a guess
    grid_rows: 5,
    grid_columns: 8,
    grid_offset: 0,
    fader_count: 8,
    fader_offset: 48,
    fader_light_offset: nil, # no fader lights
    light_off: 0,
    light_green: 1,
    light_red: 3,
    light_yellow: 5
    # TODO: handle keyboard
  }
}.freeze

Class Method Summary collapse

Class Method Details

.modelObject



21
22
23
# File 'lib/sonic-pi-akai-apc-mini/controller.rb', line 21

def model
  @_model || raise(Error, 'model not initialized')
end

.model=(model_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sonic-pi-akai-apc-mini/controller.rb', line 7

def model=(model_name)
  if @_model
    if @_model.name == model_name
      return
    else
      raise Error, 'Changing the model is not supported. Please restart Sonic Pi and initialize with new model name'
    end
  end

  config = Configs.fetch(model_name.to_sym) { raise Error, "model #{model_name} not supported" }

  @_model = Model.new(config.merge(name: model_name))
end