a monkey patch for osc-ruby 1.1.5
The snippet can be accessed without any authentication.
Authored by
cleemy desu wayo
this is a monkey patch for osc-ruby 1.1.5
no exceptions will be raised for now even when OSC data contains a boolean value
OSCデータが boolean value を含む時でも、とりあえず例外を起こさないようになります
osc_ruby_monkey_patch.rb 1.93 KiB
# a monkey patch for osc-ruby 1.1.5
# by cleemy desu wayo 2025-07-27
#
# this is NOT CC0.
#
# this code comes from the osc-ruby project (MIT License).
#
# see:
# https://github.com/aberant/osc-ruby/blob/a173bccbcd74e223d433bfbd44dd07b7a596a56a/lib/osc-ruby/osc_packet.rb#L46-L56
# https://github.com/aberant/osc-ruby/blob/3b4b589d888396f031b01e6a2289a56db1aa933e/lib/osc-ruby/message.rb#L14-L26
#
# ----
#
# To use this monkey patch with Outvoke, for example, save this file as
# `osc_ruby_monkey_patch.rb` in the current directory and require it in
# `outvoke.conf.rb` with `require "./osc_ruby_monkey_patch.rb"`.
#
# Outvokeでこのモンキーパッチを利用する場合、例えばこのファイルを
# osc_ruby_monkey_patch.rb でカレントディレクトリに保存し、outvoke.conf.rb から
# require "./osc_ruby_monkey_patch.rb" する、といった方法があります。
#
require 'osc-ruby'
require 'osc-ruby/em_server'
module OSC
class OSCPacket
def initialize(string)
@packet = NetworkPacket.new(string)
@types = {
"i" => lambda{OSCInt32.new(get_int32)},
"f" => lambda{ OSCFloat32.new(get_float32)},
"d" => lambda{ OSCDouble64.new(get_double64)},
"s" => lambda{ OSCString.new(get_string)},
"b" => lambda{ OSCBlob.new(get_blob)},
"T" => lambda{true},
"F" => lambda{false}
}
end
end
class Message
def initialize(address, *args)
@address = address
@args = []
args.each do |arg|
case arg
when Integer; @args << OSCInt32.new(arg)
when Float; @args << OSCFloat32.new(arg)
when String; @args << OSCString.new(arg)
when OSCArgument; @args << arg
when TrueClass; obj = Object.new; obj.define_singleton_method(:val) { true } ; @args << obj
when FalseClass; obj = Object.new; obj.define_singleton_method(:val) { false } ; @args << obj
end
end
end
end
end
Please register or sign in to comment