Sha256: fc213eea0fde92fc2e505f5c4bd6e85ba36f13c2db5589c2a6aec59085b42e83

Contents?: true

Size: 766 Bytes

Versions: 4

Compression:

Stored size: 766 Bytes

Contents

require 'osc-ruby'

module Xi
  module OSC
    def initialize(name, clock, server: 'localhost', port:, **opts)
      super
      @osc = ::OSC::Client.new(server, port)
    end

    private

    def send_msg(address, *args)
      msg = message(address, *args)
      debug(__method__, msg.address, *msg.to_a)
      send_osc_msg(msg)
    end

    def send_bundle(address, *args, at: Time.now)
      msg = message(address, *args)
      bundle = ::OSC::Bundle.new(at, msg)
      debug(__method__, msg.address, at.to_i, at.usec, *msg.to_a)
      send_osc_msg(bundle)
    end

    def message(address, *args)
      ::OSC::Message.new(address, *args)
    end

    def send_osc_msg(msg)
      @osc.send(msg)
    rescue StandardError => err
      error(err)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xi-lang-0.2.5 lib/xi/osc.rb
xi-lang-0.2.4 lib/xi/osc.rb
xi-lang-0.2.3 lib/xi/osc.rb
xi-lang-0.2.2 lib/xi/osc.rb