diff --git a/app/server/ruby/lib/sonicpi/osc/osc.rb b/app/server/ruby/lib/sonicpi/osc/osc.rb index de275c349a..b3414e92f4 100644 --- a/app/server/ruby/lib/sonicpi/osc/osc.rb +++ b/app/server/ruby/lib/sonicpi/osc/osc.rb @@ -14,6 +14,6 @@ require_relative 'udp_client' require_relative 'udp_server' require_relative 'websocket_server' -require_relative 'blob' +require_relative 'osc_types' require_relative 'oscencode' require_relative 'oscdecode' diff --git a/app/server/ruby/lib/sonicpi/osc/blob.rb b/app/server/ruby/lib/sonicpi/osc/osc_types.rb similarity index 77% rename from app/server/ruby/lib/sonicpi/osc/blob.rb rename to app/server/ruby/lib/sonicpi/osc/osc_types.rb index 7c0ccd9c17..fda3151a62 100644 --- a/app/server/ruby/lib/sonicpi/osc/blob.rb +++ b/app/server/ruby/lib/sonicpi/osc/osc_types.rb @@ -22,6 +22,7 @@ def initialize(data) # add padding @binary = b + ("\000" * ((4 - (b.size % 4)) % 4)) + end def to_s @@ -33,5 +34,21 @@ def inspect end end + + class Int64 + attr_reader :binary + def initialize(val) + @val = val + @binary = [val].pack('q>') + end + + def to_i + @val.to_i + end + + def inspect + @val.inspect + end + end end end diff --git a/app/server/ruby/lib/sonicpi/osc/oscencode.rb b/app/server/ruby/lib/sonicpi/osc/oscencode.rb index 8f6ba6f45e..4c1b0fc125 100644 --- a/app/server/ruby/lib/sonicpi/osc/oscencode.rb +++ b/app/server/ruby/lib/sonicpi/osc/oscencode.rb @@ -27,6 +27,7 @@ def initialize(use_cache = false, cache_size=1000) @literal_low_g = 'g'.freeze @literal_low_s = 's'.freeze @literal_low_b = 'b'.freeze + @literal_low_h = 'h'.freeze @literal_empty_str = ''.freeze @literal_str_encode_regexp = /\000.*\z/ @literal_str_pad = "\000".freeze @@ -99,6 +100,9 @@ def encode_single_message(address, args=[]) when SonicPi::OSC::Blob tags << @literal_low_b args_encoded << arg.binary + when SonicPi::OSC::Int64 + tags << @literal_low_h + args_encoded << arg.binary else raise "Unknown arg type to encode: #{arg.inspect}" end