Module: MusaLCEServer

Defined in:
lib/version.rb,
lib/daw.rb,
lib/surface.rb,
lib/live/live.rb,
lib/live/tracks.rb,
lib/live/handler.rb,
lib/midi-devices.rb,
lib/bitwig/bitwig.rb,
lib/bitwig/tracks.rb,
lib/bitwig/handler.rb,
lib/musalce-server.rb,
lib/surface-bridge.rb,
lib/bitwig/controllers.rb

Overview

Musa Live Coding Environment Server.

This module provides the main entry point for the MusaLCE server, which enables live coding with Ableton Live 11+ and Bitwig Studio 5+.

The server provides:

  • OSC communication with DAW controller extensions
  • MIDI device management and routing
  • A REPL (Read-Eval-Print-Loop) for interactive live coding
  • Integration with Musa-DSL sequencer for music composition

Examples:

Starting the server for Bitwig Studio

MusaLCEServer.run('bitwig')

Starting the server for Ableton Live

MusaLCEServer.run('live')

See Also:

Defined Under Namespace

Modules: Bitwig, Live Classes: Control, Daw, Encoder, Handler, MIDIDevice, MIDIDevices, MusaLCE_Context, Surface, SurfaceBridge, Toggle, Trigger

Constant Summary collapse

VERSION =

Current version of the musalce-server gem.

Since:

  • 0.1.0

'0.8.0'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.surfaceObject

Returns the value of attribute surface.



12
13
14
# File 'lib/daw.rb', line 12

def surface
  @surface
end

Class Method Details

.run(daw_name) ⇒ void

This method returns an undefined value.

Starts the MusaLCE server for the specified DAW.

This method initializes the DAW controller, sets up the REPL environment, and starts the main server loop. The server runs until shutdown is called from the REPL.

Examples:

MusaLCEServer.run('bitwig')

Parameters:

  • daw_name (String)

    the DAW to connect to ('bitwig' or 'live')

Raises:

  • (ArgumentError)

    if daw_name is nil or not a supported DAW



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/musalce-server.rb', line 44

def self.run(daw_name)
  raise ArgumentError, 'A daw must be specified. Options: \'bitwig\' or \'live\'' unless daw_name
  raise ArgumentError, "Incompatible DAW '#{daw_name}'. Options: 'bitwig' or 'live'" unless %w[bitwig live].include?(daw_name)

  main_thread = Thread.current

  daw = Daw.daw_controller_for(daw_name.to_sym)

  daw.sequencer.with(main_thread: main_thread, daw: daw, keep_block_context: false) do |main_thread:, daw:|
    @__main_thread = main_thread
    @__daw = daw

    alias __puts puts
    alias __require_relative require_relative

    def puts(...)
      @__repl.puts(...)
    end

    def require_relative(filename, from_server: false)
      if from_server
        require_relative filename
      else
        # @user_pathname is injected from REPL
        require @user_pathname.dirname + filename
      end
    end

    def daw
      @__daw
    end

    def reload
      @__daw.reload
    end

    def shutdown
      @__main_thread.wakeup
    end

    @__repl = Musa::REPL::REPL.new(binding, highlight_exception: false)
  end

  sleep
end