Class: MusaLCEServer::Live::Handler Private

Inherits:
Handler
  • Object
show all
Defined in:
lib/live/handler.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.

OSC message handler for Ableton Live.

Handles communication with the MusaLCE for Live MIDI Remote Script, processing incoming OSC messages for track registration and routing.

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(osc_server, osc_client, tracks, logger:) ⇒ Handler

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 Live handler.

Parameters:

  • osc_server (OSC::EMServer)

    the OSC server for receiving messages

  • osc_client (OSC::Client)

    the OSC client for sending messages

  • tracks (Tracks)

    the tracks manager

  • logger (Logger)

    the logger

Since:

  • 0.1.0



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/live/handler.rb', line 18

def initialize(osc_server, osc_client, tracks, logger:)
  super()

  @server = osc_server
  @client = osc_client

  @tracks = tracks

  @logger = logger

  @server.add_method '/hello' do |message|
    @logger.info "Received /hello #{message.to_a}!"
    sync
  end

  @server.add_method '/musalce4live/tracks' do |message|
    @tracks.grant_registry_collection(message.to_a.each_slice(10).to_a)
  end

  @server.add_method '/musalce4live/track/name' do |message|
    message.to_a.each_slice(2).to_a.each do |track_data|
      @tracks.grant_registry(track_data[0], track_data[1])
    end
  end

  @server.add_method '/musalce4live/track/midi' do |message|
    message.to_a.each_slice(3).to_a.each do |track_data|
      @tracks.grant_registry(track_data[0], *([nil] * 1), *track_data[1..])
    end
  end

  @server.add_method '/musalce4live/track/audio' do |message|
    message.to_a.each_slice(3).to_a.each do |track_data|
      @tracks.grant_registry(track_data[0], *([nil] * 3), *track_data[1..])
    end
  end

  @server.add_method '/musalce4live/track/routings' do |message|
    message.to_a.each_slice(5).to_a.each do |track_data|
      @tracks.grant_registry(track_data[0], *([nil] * 5), *track_data[1..])
    end
  end
end

Instance Method Details

#syncvoid

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.

Requests track information from Live.

Since:

  • 0.1.0



64
65
66
# File 'lib/live/handler.rb', line 64

def sync
  send_osc '/musalce4live/tracks'
end