Class: MusaLCEServer::Bitwig::Handler Private

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

Handles communication with the MusaLCE for Bitwig controller extension, processing incoming OSC messages for controller and channel registration, and sending transport commands.

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(osc_server, osc_client, controllers, sequencer, 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 Bitwig handler.

Parameters:

  • osc_server (OSC::EMServer)

    the OSC server for receiving messages

  • osc_client (OSC::Client)

    the OSC client for sending messages

  • controllers (Controllers)

    the controllers manager

  • sequencer (Musa::Sequencer::Sequencer)

    the sequencer instance

  • logger (Logger)

    the logger

Since:

  • 0.1.0



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
# File 'lib/bitwig/handler.rb', line 20

def initialize(osc_server, osc_client, controllers, sequencer, logger:)
  super()

  @server = osc_server
  @client = osc_client

  @controllers = controllers
  @sequencer = sequencer

  @logger = logger

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

  @server.add_method '/musalce4bitwig/controllers' do |message|
    @logger.info("Received /musalce4bitwig/controllers #{message.to_a}")
    @controllers.register_controllers(message.to_a)
  end

  @server.add_method '/musalce4bitwig/controller' do |message|
    @logger.info("Received /musalce4bitwig/controller #{message.to_a}")
    a = message.to_a
    @controllers.register_controller(name: a[0], port_name: a[1], is_clock: a[2] == 1)
  end

  @server.add_method '/musalce4bitwig/controller/update' do |message|
    @logger.info("Received /musalce4bitwig/controller/update #{message.to_a}")
    a = message.to_a
    @controllers.update_controller(old_name: a[0], new_name: a[1], port_name: a[2], is_clock: a[3] == 1)
  end

  @server.add_method '/musalce4bitwig/channels' do |message|
    @logger.info("Received /musalce4bitwig/channels #{message.to_a}")
    a = message.to_a
    @controllers.register_channels(controller_name: a[0], channels: a[1..])
  end
end

Instance Method Details

#continuevoid

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.

Sends continue command to Bitwig.

Since:

  • 0.1.0



84
85
86
87
# File 'lib/bitwig/handler.rb', line 84

def continue
  @logger.info 'Asking continue'
  send_osc '/musalce4bitwig/continue'
end

#goto(position) ⇒ 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.

Moves playhead to specified position.

Parameters:

  • position (Numeric)

    the bar number (1-based)

Since:

  • 0.1.0



93
94
95
96
# File 'lib/bitwig/handler.rb', line 93

def goto(position)
  @logger.info "Asking goto #{position}"
  send_osc '/musalce4bitwig/goto', OSC::OSCDouble64.new(((position - 1) * @sequencer.beats_per_bar).to_f)
end

#panic!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.

Sends panic to all tracks.

Since:

  • 0.1.0



107
108
109
# File 'lib/bitwig/handler.rb', line 107

def panic!
  @controllers.tracks.each(:panic!)
end

#playvoid

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.

Sends play command to Bitwig.

Since:

  • 0.1.0



70
71
72
73
# File 'lib/bitwig/handler.rb', line 70

def play
  @logger.info 'Asking play'
  send_osc '/musalce4bitwig/play'
end

#recordvoid

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.

Sends record command to Bitwig.

Since:

  • 0.1.0



100
101
102
103
# File 'lib/bitwig/handler.rb', line 100

def record
  @logger.info 'Asking record'
  send_osc '/musalce4bitwig/record'
end

#stopvoid

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.

Sends stop command to Bitwig.

Since:

  • 0.1.0



77
78
79
80
# File 'lib/bitwig/handler.rb', line 77

def stop
  @logger.info 'Asking stop'
  send_osc '/musalce4bitwig/stop'
end

#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 synchronization of controllers and channels from Bitwig.

Since:

  • 0.1.0



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

def sync
  @logger.info 'Asking sync'
  send_osc '/musalce4bitwig/sync'
end