Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'add-double' of https://github.com/samaaron/osc-ruby int…

…o samaaron-add-double
  • Loading branch information...
commit 9d43128ed1b0e0aebc935a1990ed0e414b93c8af 2 parents 4675169 + 13d6763
@aberant authored
Showing with 18 additions and 6 deletions.
  1. +11 −4 lib/osc-ruby/osc_packet.rb
  2. +7 −2 lib/osc-ruby/osc_types.rb
View
15 lib/osc-ruby/osc_packet.rb
@@ -47,10 +47,11 @@ def self.decode_simple_message( time, osc_packet )
def initialize( string )
@packet = NetworkPacket.new( string )
- @types = { "i" => lambda{ OSCInt32.new( get_int32 ) },
- "f" => lambda{ OSCFloat32.new( get_float32 ) },
- "s" => lambda{ OSCString.new( get_string ) },
- "b" => lambda{ OSCBlob.new( get_blob )}
+ @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 )}
}
end
@@ -116,6 +117,12 @@ def get_float32
f
end
+ def get_double64
+ f = @packet.getn(8).unpack('G')[0]
+ @packet.skip_padding
+ f
+ end
+
def get_blob
l = @packet.getn(4).unpack('N')[0]
b = @packet.getn(l)
View
9 lib/osc-ruby/osc_types.rb
@@ -8,7 +8,12 @@ def encode() [@val].pack('N').force_encoding("BINARY") end
class OSCFloat32 < OSCArgument
def tag() 'f' end
- def encode() [@val].pack('g').force_encoding("BINARY") end
+ def encode() [@val].pack('g').force_encoding("BINARY") end
+ end
+
+ class OSCDouble64 < OSCArgument
+ def tag() 'd' end
+ def encode() [@val].pack('G').force_encoding("BINARY") end
end
class OSCString < OSCArgument
@@ -20,4 +25,4 @@ class OSCBlob < OSCArgument
def tag() 'b' end
def encode() padding([@val.size].pack('N') + @val).force_encoding("BINARY") end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.