Compare commits

...

20 Commits

Author SHA1 Message Date
nixo d18aceff14 Change required julia version 2019-06-30 11:48:53 +02:00
fundamental 3a97943c08 Remove 0.6 Support + Add "using Printf" 2018-09-09 12:42:20 -04:00
fundamental 8a39e8ca9e Fix 1.0 API difference + 0.7 Warning 2018-09-09 12:30:59 -04:00
fundamental b8800b0d05 Fix 0.7 errors/warnings 2018-09-09 12:26:05 -04:00
fundamental 7dc977b222 Remove Printf From REQUIRE 2018-09-02 00:14:35 -04:00
fundamental 58f1fa477b Change using Printf -> Base.Printf 2018-09-02 00:12:27 -04:00
fundamental f302d0dc50 Add More Travis-CI Versions 2018-09-01 19:24:31 -04:00
fundamental 8b5454c40a Fix 1.0 Regressions 2018-09-01 19:23:13 -04:00
standarddeviant e3f6fb350a Adding MD title spaces a prettier README.md 2018-08-30 20:48:03 -04:00
standarddeviant b4a6cc0311 Simple syntax fixes to README.md
* Removed types from global variables and replaced with function calls
* Changed `UdpSocket` to `UDPSocket`
2018-08-30 20:48:03 -04:00
fundamental 12da81bfc6 Remove Julia 0.5 Support 2017-08-14 21:19:19 -04:00
fundamental ad40ea371f Fix Julia-0.7 Issues 2017-08-14 21:16:31 -04:00
Tony Kelman 8c02f9b86f modernize .travis.yml
the PPA is no longer recommended, `language: julia` allows testing against more versions of julia
2017-06-19 16:44:06 -04:00
fundamental c7f98793d0 Update Required Julia Version 2017-06-19 14:15:49 -04:00
fundamental 8fbbf127f4 Fix v0.6 Regression 2017-02-22 13:13:37 -05:00
WooKyoung Noh c7a349625c reformatting code 2017-02-17 22:45:59 +09:00
fundamental 9a607f4312 Fix More 0.4 Bitrot 2015-07-16 11:19:09 -04:00
Spencer Russell 687d7a4fc8 switches to 1-based indexing for argument access 2015-07-16 11:16:41 -04:00
Spencer Russell 50027a0dcb adds path method to OscMsg that return the OSC path 2015-07-16 10:55:32 -04:00
fundamental 67c26b7742 Fix Julia 4.0 Regressions
Negating Int32 via bitfield operations expands the type to Int64
Uint32 is now used with a reinterpret cast

Pretty printing of true/false typeclasses fixed

Fixes Issue #2
2014-09-29 13:39:37 -04:00
5 changed files with 269 additions and 248 deletions

View File

@ -1,14 +1,7 @@
language: cpp
compiler:
- clang
language: julia
julia:
- 0.7
- 1.0
- nightly
notifications:
email: false
before_install:
- sudo add-apt-repository ppa:staticfloat/julia-deps -y
- sudo add-apt-repository ppa:staticfloat/julianightlies -y
- sudo apt-get update -qq -y
- sudo apt-get install libpcre3-dev julia -y
script:
- julia -e 'Pkg.init(); run(`ln -s $(pwd()) $(Pkg.dir())/OSC`); Pkg.resolve()'
- julia -e 'using OSC; @assert isdefined(:OSC); @assert typeof(OSC) === Module'
- julia test/runtests.jl TEST

View File

@ -8,21 +8,21 @@ used in networked control of musical applications.
The code is based on a relatively straightforward translation of
librtosc(https://github.com/fundamental/rtosc)
##Sample Usage
## Sample Usage
```julia
i::Int32 = 42; #integer
f::Float32 = 0.25; #float
s::ASCIIString = "string"; #string
b = s; #blob
h::Int64 = -125; #long integer
t::Uint64 = 22412; #timetag
d::Float64 = 0.125; #double
S::ASCIIString = "Symbol"; #symbol
c::Char = 'J'; #character
r::Int32 = 0x12345678; #RGBA
m::Array{Uint8,1} = [0x12,0x23, #midi
0x34,0x45];
i = Int32( 42 ); #integer
f = Float32( 0.25; ); #float
s = "string" #string
b = s; #blob
h = Int64( -125; ); #long integer
t = UInt64( 22412; ); #timetag
d = Float64( 0.125; ); #double
S = "Symbol" #symbol
c = Char( 'J' ); #character
r = Int32( 0x12345678 ); #RGBA
m = Array{UInt8,1}( [0x12,0x23, #midi
0x34,0x45]);
#true
#false
#nil
@ -57,7 +57,7 @@ OSC Message to /dest
Accessing the fields is done via the [] operator.
##Networked Usage
## Networked Usage
Most of the usage is going to involve sending the OSC messages over UDP to
another program.
@ -66,7 +66,7 @@ In the first one run
```julia
using OSC
sock2 = UdpSocket()
sock2 = UDPSocket()
bind(sock2, ip"127.0.0.1", 7777)
msg2 = OscMsg(recv(sock2))
```
@ -76,18 +76,18 @@ To send the an OSC message, in the second window type.
```julia
using OSC
sock1 = UdpSocket()
sock1 = UDPSocket()
msg1 = OSC.message("/hello world", "sSif", "strings", "symbols", 234,
float32(2.3))
send(sock1, ip"127.0.0.1", 7777, msg1.data)
```
##TODO
## TODO
- Port bundle message support from librtosc
##LICENSE
## LICENSE
OSC.jl is licensed under the LGPLv3 License

View File

@ -1 +1 @@
julia 0.2-
julia 1.1

View File

@ -1,318 +1,341 @@
#OSC.jl
#Copyright (c) 2014, Mark McCurry, All rights reserved.
# OSC.jl
# Copyright (c) 2018, Mark McCurry, All rights reserved.
#
#This library is free software; you can redistribute it and/or
#modify it under the terms of the GNU Lesser General Public
#License as published by the Free Software Foundation; either
#version 3.0 of the License, or (at your option) any later version.
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
#
#This library is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#Lesser General Public License for more details.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
#You should have received a copy of the GNU Lesser General Public
#License along with this library.
# You should have received a copy of the GNU Lesser General Public
# License along with this library.
module OSC
import Base.show
export OscMsg
using Printf
import Base: show, getindex
export OscMsg, path
macro incfp(x) quote begin
local gensym_ = $(esc(x))
$(esc(x)) = $(esc(x))+1
gensym_
end end end
type OscMsg
data::Array{Uint8}
struct OscMsg
data::Array{UInt8}
end
function stringify(data::Array{Uint8})
zeroInd = find(data.== 0)
if(length(zeroInd) == 0)
return string(map(char, data)...)
elseif(zeroInd[1] == 0)
path(msg::OscMsg) = stringify(msg.data)
function stringify(data::Array{UInt8})
zeroInd = findall(data.== 0)
if length(zeroInd) == 0
return string(map(Char, data)...)
elseif zeroInd[1] == 0
return nothing
else
return string(map(char, data[1:zeroInd[1]-1])...)
return string(map(Char, data[1:zeroInd[1]-1])...)
end
end
function names(msg::OscMsg)#::ASCIIString
function names(msg::OscMsg) #::String
pos = 1
while(msg.data[pos += 1] != 0) end #skip pattern
while(msg.data[pos += 1] == 0) end #skip null
return stringify(msg.data[pos+1:end]); #skip comma
return stringify(msg.data[pos+1:end]) #skip comma
end
strip_args(args::ASCIIString) = replace(replace(args,"]",""),"[","")
strip_args(args::AbstractString) = replace(replace(args,"]"=>""),"["=>"")
function narguments(msg::OscMsg)
length(strip_args(names(msg)))
end
has_reserved(typeChar::Char) = typeChar in "isbfhtdSrmc"
nreserved(args::ASCIIString) = sum(map(has_reserved, collect(args)))
nreserved(args::String) = sum(map(has_reserved, collect(args)))
function argType(msg::OscMsg, nargument::Int)#::Char
@assert(nargument < narguments(msg));
return strip_args(names(msg))[nargument+1]
function argType(msg::OscMsg, nargument::Int) #::Char
@assert(nargument > 0 && nargument <= narguments(msg))
return strip_args(names(msg))[nargument]
end
align(pos) = pos+(4-(pos-1)%4)
function arg_off(msg::OscMsg, idx::Int)#::Int
function arg_off(msg::OscMsg, idx::Int) #::Int
if(!has_reserved(argType(msg,idx)))
return 0;
return 0
end
#Iterate to the right position
args::ASCIIString = names(msg);
# Iterate to the right position
args::String = names(msg)
argc::Int = 1
pos::Int = 1
#Get past the Argument String
while(msg.data[pos] != ',') pos += 1 end
# Get past the Argument String
while(msg.data[pos] != UInt8(',')) pos += 1 end
while(msg.data[pos] != 0) pos += 1 end
#Alignment
# Alignment
pos = align(pos)
#ignore any leading '[' or ']'
# ignore any leading '[' or ']'
while(args[argc] in "[]") argc += 1 end
while(idx != 0)
bundle_length::Uint32 = 0;
while(idx != 1)
bundle_length::UInt32 = 0
arg = args[argc]
argc += 1
if(arg in "htd")
pos +=8;
if arg in "htd"
pos +=8
elseif(arg in "mrfci")
pos += 4;
pos += 4
elseif(arg in "Ss")
while(msg.data[pos += 1] != 0) end
pos = align(pos)
elseif(arg == 'b')
bundle_length |= (msg.data[@incfp(pos)] << 24);
bundle_length |= (msg.data[@incfp(pos)] << 16);
bundle_length |= (msg.data[@incfp(pos)] << 8);
bundle_length |= (msg.data[@incfp(pos)]);
bundle_length += 4-bundle_length%4;
pos += bundle_length;
elseif(arg in "[]")#completely ignore array chars
idx += 1;
else #TFI
elseif arg == 'b'
bundle_length |= (msg.data[@incfp(pos)] << 24)
bundle_length |= (msg.data[@incfp(pos)] << 16)
bundle_length |= (msg.data[@incfp(pos)] << 8)
bundle_length |= (msg.data[@incfp(pos)])
bundle_length += 4-bundle_length%4
pos += bundle_length
elseif(arg in "[]") # completely ignore array chars
idx += 1
else # TFI
end
idx -= 1
end
pos;
pos
end
#Calculate the size of the message without writing to a buffer
function vsosc_null(address::ASCIIString,
arguments::ASCIIString,
# Calculate the size of the message without writing to a buffer
function vsosc_null(address::String,
arguments::String,
args...)
pos::Int = length(address)+1
pos::Int = length(address) + 1
pos = align(pos)
pos += 1+length(arguments)
pos = align(pos)
arg_pos = 1;
arg_pos = 1
#Take care of varargs
for(arg = arguments)
if(arg in "htd")
# Take care of varargs
for arg in arguments
if arg in "htd"
arg_pos += 1
pos += 8;
elseif(arg in "mrcfi")
pos += 8
elseif arg in "mrcfi"
arg_pos += 1
pos += 4;
elseif(arg in "sS")
s::ASCIIString = args[@incfp(arg_pos)];
pos += length(s);
pos += 4
elseif arg in "sS"
s::String = args[@incfp(arg_pos)]
pos += length(s)
pos = align(pos)
elseif(arg in "b")
elseif arg in "b"
i::Int32 = sizeof(args[@incfp(arg_pos)])
pos += 4 + i;
pos += 4 + i
pos = align(pos)
end #other args classes are ignored
end # other args classes are ignored
end
return pos-1;
return pos - 1
end
function rtosc_amessage(buffer::Array{Uint8},
function rtosc_amessage(buffer::Array{UInt8},
len::Int,
address::ASCIIString,
arguments::ASCIIString,
address::String,
arguments::String,
args...)
total_len::Int = vsosc_null(address, arguments, args...);
total_len::Int = vsosc_null(address, arguments, args...)
for(i=1:total_len)
for i=1:total_len
buffer[i] = 0
end
#Abort if the message cannot fit
if(total_len>len)
return 0;
# Abort if the message cannot fit
if total_len > len
return 0
end
pos::Int = 1;
pos::Int = 1
#Address
for(C = address) buffer[@incfp(pos)] = C end
for C in address
buffer[@incfp(pos)] = C
end
pos = align(pos)
#Arguments
buffer[@incfp(pos)] = ',';
for(A=arguments) buffer[@incfp(pos)] = A; end
buffer[@incfp(pos)] = UInt8(',')
for A in arguments
buffer[@incfp(pos)] = A
end
pos = align(pos)
arg_pos::Int = 1;
for(arg = arguments)
@assert(arg != 0);
if(arg in "htd")
d::Uint64 = reinterpret(Uint64, args[@incfp(arg_pos)]);
buffer[@incfp(pos)] = ((d>>56) & 0xff);
buffer[@incfp(pos)] = ((d>>48) & 0xff);
buffer[@incfp(pos)] = ((d>>40) & 0xff);
buffer[@incfp(pos)] = ((d>>32) & 0xff);
buffer[@incfp(pos)] = ((d>>24) & 0xff);
buffer[@incfp(pos)] = ((d>>16) & 0xff);
buffer[@incfp(pos)] = ((d>>8) & 0xff);
buffer[@incfp(pos)] = (d & 0xff);
elseif(arg in "rfci")
i::Int32 = reinterpret(Int32, args[@incfp(arg_pos)]);
buffer[@incfp(pos)] = ((i>>24) & 0xff);
buffer[@incfp(pos)] = ((i>>16) & 0xff);
buffer[@incfp(pos)] = ((i>>8) & 0xff);
buffer[@incfp(pos)] = (i & 0xff);
elseif(arg in "m")
m = args[@incfp(arg_pos)];
buffer[@incfp(pos)] = m[1];
buffer[@incfp(pos)] = m[2];
buffer[@incfp(pos)] = m[3];
buffer[@incfp(pos)] = m[4];
elseif(arg in "Ss")
s = args[@incfp(arg_pos)];
for(C = s)
arg_pos::Int = 1
for arg in arguments
@assert(UInt32(arg) != 0)
if arg in "htd"
d::UInt64 = reinterpret(UInt64, args[@incfp(arg_pos)])
buffer[@incfp(pos)] = ((d>>56) & 0xff)
buffer[@incfp(pos)] = ((d>>48) & 0xff)
buffer[@incfp(pos)] = ((d>>40) & 0xff)
buffer[@incfp(pos)] = ((d>>32) & 0xff)
buffer[@incfp(pos)] = ((d>>24) & 0xff)
buffer[@incfp(pos)] = ((d>>16) & 0xff)
buffer[@incfp(pos)] = ((d>>8) & 0xff)
buffer[@incfp(pos)] = (d & 0xff)
elseif arg in "rfci"
i::Int32 = reinterpret(Int32, args[@incfp(arg_pos)])
buffer[@incfp(pos)] = ((i>>24) & 0xff)
buffer[@incfp(pos)] = ((i>>16) & 0xff)
buffer[@incfp(pos)] = ((i>>8) & 0xff)
buffer[@incfp(pos)] = (i & 0xff)
elseif arg in "m"
m = args[@incfp(arg_pos)]
buffer[@incfp(pos)] = m[1]
buffer[@incfp(pos)] = m[2]
buffer[@incfp(pos)] = m[3]
buffer[@incfp(pos)] = m[4]
elseif arg in "Ss"
s = args[@incfp(arg_pos)]
for C in s
buffer[@incfp(pos)] = C
end
pos = align(pos)
elseif(arg == 'b')
b = args[@incfp(arg_pos)];
i = sizeof(b);
buffer[@incfp(pos)] = ((i>>24) & 0xff);
buffer[@incfp(pos)] = ((i>>16) & 0xff);
buffer[@incfp(pos)] = ((i>>8) & 0xff);
buffer[@incfp(pos)] = (i & 0xff);
for(U = b)
buffer[@incfp(pos)] = uint8(U);
elseif arg == 'b'
b = args[@incfp(arg_pos)]
i = sizeof(b)
buffer[@incfp(pos)] = ((i>>24) & 0xff)
buffer[@incfp(pos)] = ((i>>16) & 0xff)
buffer[@incfp(pos)] = ((i>>8) & 0xff)
buffer[@incfp(pos)] = (i & 0xff)
for U in b
buffer[@incfp(pos)] = UInt8(U)
end
pos = align(pos)
end
end
return pos-1;
return pos - 1
end
OscMsg(address, arguments, args...) = message(address, arguments, args...)
function message(address::ASCIIString,
arguments::ASCIIString,
function message(address::String,
arguments::String,
args...)
len::Int = vsosc_null(address, arguments, args...);
data::Vector{Uint8} = Array(Uint8, len);
rtosc_amessage(data,len,address,arguments,args...);
len::Int = vsosc_null(address, arguments, args...)
data::Vector{UInt8} = Array{UInt8}(undef, len)
rtosc_amessage(data,len,address,arguments,args...)
return OscMsg(data)
end
function rtosc_argument(msg::OscMsg, idx::Int)
typeChar::Char = argType(msg, idx);
#trivial case
typeChar::Char = argType(msg, idx)
# trivial case
if(!has_reserved(typeChar))
if(typeChar == 'T')
if typeChar == 'T'
return true
elseif(typeChar == 'F')
return false;
elseif typeChar == 'F'
return false
end
else
arg_pos::Int = arg_off(msg, idx)
if(typeChar in "htd")
t::Uint64 = 0
t |= (uint64(msg.data[@incfp(arg_pos)]) << 56);
t |= (uint64(msg.data[@incfp(arg_pos)]) << 48);
t |= (uint64(msg.data[@incfp(arg_pos)]) << 40);
t |= (uint64(msg.data[@incfp(arg_pos)]) << 32);
t |= (uint64(msg.data[@incfp(arg_pos)]) << 24);
t |= (uint64(msg.data[@incfp(arg_pos)]) << 16);
t |= (uint64(msg.data[@incfp(arg_pos)]) << 8);
t |= (uint64(msg.data[@incfp(arg_pos)]));
if(typeChar == 'h')
return int64(t)
elseif(typeChar == 'd')
return reinterpret(Float64, t);
if typeChar in "htd"
t::UInt64 = 0
t |= (UInt64(msg.data[@incfp(arg_pos)]) << 56)
t |= (UInt64(msg.data[@incfp(arg_pos)]) << 48)
t |= (UInt64(msg.data[@incfp(arg_pos)]) << 40)
t |= (UInt64(msg.data[@incfp(arg_pos)]) << 32)
t |= (UInt64(msg.data[@incfp(arg_pos)]) << 24)
t |= (UInt64(msg.data[@incfp(arg_pos)]) << 16)
t |= (UInt64(msg.data[@incfp(arg_pos)]) << 8)
t |= (UInt64(msg.data[@incfp(arg_pos)]))
if typeChar == 'h'
return reinterpret(Int64, t)
elseif typeChar == 'd'
return reinterpret(Float64, t)
else
return t;
return t
end
elseif(typeChar in "f")
return reinterpret(Float32,msg.data[arg_pos+(3:-1:0)])[1]
elseif(typeChar in "rci")
i::Int32 = 0
i |= (uint32(msg.data[@incfp(arg_pos)]) << 24);
i |= (uint32(msg.data[@incfp(arg_pos)]) << 16);
i |= (uint32(msg.data[@incfp(arg_pos)]) << 8);
i |= (uint32(msg.data[@incfp(arg_pos)]));
if(typeChar == 'r')
return uint32(i)
elseif(typeChar == 'c')
return char(i)
elseif typeChar in "f"
return read(IOBuffer(msg.data[arg_pos.+(3:-1:0)]), Float32)
elseif typeChar in "rci"
i::UInt32 = 0
i |= (UInt32(msg.data[@incfp(arg_pos)]) << 24)
i |= (UInt32(msg.data[@incfp(arg_pos)]) << 16)
i |= (UInt32(msg.data[@incfp(arg_pos)]) << 8)
i |= (UInt32(msg.data[@incfp(arg_pos)]))
if typeChar == 'r'
return UInt32(i)
elseif typeChar == 'c'
return Char(i/(2^24))
else
return i
return reinterpret(Int32, i)
end
elseif(typeChar in "m")
m = Array(Uint8, 4)
elseif typeChar in "m"
m = Array{UInt8}(undef, 4)
m[1] = msg.data[@incfp(arg_pos)]
m[2] = msg.data[@incfp(arg_pos)]
m[3] = msg.data[@incfp(arg_pos)]
m[4] = msg.data[@incfp(arg_pos)]
return m
elseif(typeChar in "b")
elseif typeChar in "b"
len::Int32 = 0
len |= (msg.data[@incfp(arg_pos)] << 24);
len |= (msg.data[@incfp(arg_pos)] << 16);
len |= (msg.data[@incfp(arg_pos)] << 8);
len |= (msg.data[@incfp(arg_pos)]);
return msg.data[arg_pos+(0:len-1)];
elseif(typeChar in "Ss")
return stringify(msg.data[arg_pos:end]);
len |= (msg.data[@incfp(arg_pos)] << 24)
len |= (msg.data[@incfp(arg_pos)] << 16)
len |= (msg.data[@incfp(arg_pos)] << 8)
len |= (msg.data[@incfp(arg_pos)])
return msg.data[arg_pos.+(0:len-1)]
elseif typeChar in "Ss"
return stringify(msg.data[arg_pos:end])
end
end
return nothing;
return nothing
end
getindex(msg::OscMsg, idx::Int) = rtosc_argument(msg, idx)
function show(io::IO, msg::OscMsg)
println(io, "OSC Message to ", stringify(msg.data))
println(io, " Arguments:");
println(io, " Arguments:")
for i=1:narguments(msg)
showField(io, msg,i)
end
end
function showField(io::IO, msg::OscMsg, arg_id)
map = ['i' Int32; 'f' Float32; 's' String; 'b' :Blob; 'h' Int32; 't' Uint64;
'd' Float64; 'S' Symbol; 'c' Char; 'r' :RBG; 'm' :Midi; 'T' true;
'F' false; 'N' Nothing]
dict = Dict{Char, Any}(map[:,1][:],map[:,2][:])
dict['I'] = Inf
typeChar::Char = argType(msg, arg_id-1)
value = msg[arg_id-1]
if(issubtype(typeof(value), Array))
map = Any['i' Int32;
'f' Float32;
's' String;
'b' :Blob;
'h' Int32;
't' UInt64;
'd' Float64;
'S' Symbol;
'c' Char;
'r' :RBG;
'm' :Midi;
'T' true;
'F' false;
'I' Inf;
'N' Nothing]
dict = Dict{Char, Any}(zip(Vector{Char}(map[:,1][:]),map[:,2][:]))
typeChar::Char = argType(msg, arg_id)
value = msg[arg_id]
if typeof(value) <: Array
value = value'
end
@printf(io, " #%2d %c:", arg_id, typeChar);
if(value == nothing)
value = "nothing"
end
@printf(io, " #%2d %c:", arg_id, typeChar)
println(dict[typeChar]," - ", value)
end

View File

@ -15,20 +15,19 @@
#License along with this library.
using Base.Test
require("OSC")
using Test
using OSC
test_type = length(ARGS) == 1 ? ARGS[1] : "ALL"
#buffer = Array(Uint8,1024)
#buffer = Array(UInt8,1024)
#buf_size = rtosc_amessage(buffer, 1024, "/random/address", "sif",
# "string", 0xdeadbeef, float32(12.0))
# "string", 0xdeadbeef, Float32(12.0))
#println()
##println(buffer)
#println(string(map(x->(hex(x,2)), buffer[1:buf_size])...))
#println(string(map(x->(isprint(char(x&0x7f)) ? string(char(x&0x7f)," ") : ". "), buffer[1:buf_size])...))
#println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), buffer[1:buf_size])...))
#println("argument string is=", rtosc_argument_string(buffer))
#
#println("arg 0=", rtosc_argument(buffer, 0))
@ -39,15 +38,15 @@ test_type = length(ARGS) == 1 ? ARGS[1] : "ALL"
function test_it_fat()
i::Int32 = 42; #integer
f::Float32 = 0.25; #float
s::ASCIIString = "string"; #string
s::String = "string"; #string
b = s; #blob
h::Int64 = -125; #long integer
t::Uint64 = 22412; #timetag
t::UInt64 = 22412; #timetag
d::Float64 = 0.125; #double
S::ASCIIString = "Symbol"; #symbol
S::String = "Symbol"; #symbol
c::Char = 'J'; #character
r::Int32 = 0x12345678; #RGBA
m::Array{Uint8,1} = [0x12,0x23, #midi
m::Array{UInt8,1} = [0x12,0x23, #midi
0x34,0x45];
#true
#false
@ -58,29 +57,29 @@ function test_it_fat()
show(msg)
#println(string(map(x->(hex(x,2)), buffer[1:len])...))
#println(string(map(x->(isprint(char(x&0x7f)) ? string(char(x&0x7f)," ") : ". "), buffer[1:len])...))
#println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), buffer[1:len])...))
#println("argument string is=", rtosc_argument_string(buffer))
@test msg[0] == i
@test msg[1] == f
@test msg[2] == s
@test OSC.stringify(msg[3]) == b
@test msg[4] == h
@test msg[5] == t
@test msg[6] == d
@test msg[7] == S
@test msg[8] == c
@test msg[9] == r
@test msg[10] == m
@test OSC.argType(msg,11) == 'T'
@test OSC.argType(msg,12) == 'F'
@test OSC.argType(msg,13) == 'N'
@test OSC.argType(msg,14) == 'I'
@test msg[1] == i
@test msg[2] == f
@test msg[3] == s
@test OSC.stringify(msg[4]) == b
@test msg[5] == h
@test msg[6] == t
@test msg[7] == d
@test msg[8] == S
@test msg[9] == c
@test msg[10] == r
@test msg[11] == m
@test OSC.argType(msg,12) == 'T'
@test OSC.argType(msg,13) == 'F'
@test OSC.argType(msg,14) == 'N'
@test OSC.argType(msg,15) == 'I'
end
function test_it_osc_spec()
println("Starting OSC Spec...")
message_one::Array{Uint8} = [
message_one::Array{UInt8} = [
0x2f, 0x6f, 0x73, 0x63,
0x69, 0x6c, 0x6c, 0x61,
0x74, 0x6f, 0x72, 0x2f,
@ -91,7 +90,7 @@ function test_it_osc_spec()
0x43, 0xdc, 0x00, 0x00,
];
message_two::Array{Uint8} = [
message_two::Array{UInt8} = [
0x2f, 0x66, 0x6f, 0x6f, #4
0x00, 0x00, 0x00, 0x00, #8
0x2c, 0x69, 0x69, 0x73,
@ -104,28 +103,34 @@ function test_it_osc_spec()
0x40, 0xb5, 0xb2, 0x2d, #40
];
osc=OscMsg("/oscillator/4/frequency", "f", float32(440.0))
osc=OscMsg("/oscillator/4/frequency", "f", Float32(440.0))
println(string(map(x->(hex(x,2)), osc.data)...))
println(string(map(x->(hex(x,2)), message_one)...))
println(string(map(x->(isprint(char(x&0x7f)) ? string(char(x&0x7f)," ") : ". "), osc.data)...))
println(string(map(x->(isprint(char(x&0x7f)) ? string(char(x&0x7f)," ") : ". "), message_one)...))
println(string(map(x->(string(x,base=16, pad=2)), osc.data)...))
println(string(map(x->(string(x,base=16, pad=2)), message_one)...))
println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), osc.data)...))
println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), message_one)...))
@test length(osc.data) == length(message_one)
@test osc.data == message_one
show(osc)
osc = OscMsg("/foo", "iisff", int32(1000), int32(-1), "hello", float32(1.234), float32(5.678))
println(string(map(x->(hex(x,2)), osc.data)...))
println(string(map(x->(hex(x,2)), message_two)...))
println(string(map(x->(isprint(char(x&0x7f)) ? string(char(x&0x7f)," ") : ". "), osc.data)...))
println(string(map(x->(isprint(char(x&0x7f)) ? string(char(x&0x7f)," ") : ". "), message_two)...))
osc = OscMsg("/foo", "iisff", Int32(1000), Int32(-1), "hello", Float32(1.234), Float32(5.678))
println(string(map(x->(string(x,base=16, pad=2)), osc.data)...))
println(string(map(x->(string(x,base=16, pad=2)), message_two)...))
println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), osc.data)...))
println(string(map(x->(isprint(Char(x&0x7f)) ? string(Char(x&0x7f)," ") : ". "), message_two)...))
@test length(osc.data) == length(message_two)
@test osc.data == message_two
show(osc)
end
function test_path()
osc = OscMsg("/foo", "f", Float32(1.234))
@test path(osc) == "/foo"
end
if test_type in ["ALL", "TEST", "INSTALL"]
test_it_osc_spec()
test_it_fat()
test_path()
println("Done...")
end