Compare commits

...

13 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
5 changed files with 48 additions and 51 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.5
julia 1.1

View File

@ -1,5 +1,5 @@
# OSC.jl
# Copyright (c) 2014, Mark McCurry, All rights reserved.
# 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
@ -16,6 +16,7 @@
module OSC
using Printf
import Base: show, getindex
export OscMsg, path
@ -25,14 +26,14 @@ macro incfp(x) quote begin
gensym_
end end end
type OscMsg
struct OscMsg
data::Array{UInt8}
end
path(msg::OscMsg) = stringify(msg.data)
function stringify(data::Array{UInt8})
zeroInd = find(data.== 0)
zeroInd = findall(data.== 0)
if length(zeroInd) == 0
return string(map(Char, data)...)
elseif zeroInd[1] == 0
@ -49,7 +50,7 @@ function names(msg::OscMsg) #::String
return stringify(msg.data[pos+1:end]) #skip comma
end
strip_args(args::AbstractString) = replace(replace(args,"]",""),"[","")
strip_args(args::AbstractString) = replace(replace(args,"]"=>""),"["=>"")
function narguments(msg::OscMsg)
length(strip_args(names(msg)))
@ -228,7 +229,7 @@ function message(address::String,
arguments::String,
args...)
len::Int = vsosc_null(address, arguments, args...)
data::Vector{UInt8} = Array{UInt8}(len)
data::Vector{UInt8} = Array{UInt8}(undef, len)
rtosc_amessage(data,len,address,arguments,args...)
return OscMsg(data)
end
@ -263,7 +264,7 @@ function rtosc_argument(msg::OscMsg, idx::Int)
return t
end
elseif typeChar in "f"
return reinterpret(Float32,msg.data[arg_pos+(3:-1:0)])[1]
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)
@ -273,12 +274,12 @@ function rtosc_argument(msg::OscMsg, idx::Int)
if typeChar == 'r'
return UInt32(i)
elseif typeChar == 'c'
return Char(i)
return Char(i/(2^24))
else
return reinterpret(Int32, i)
end
elseif typeChar in "m"
m = Array{UInt8}(4)
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)]
@ -290,7 +291,7 @@ function rtosc_argument(msg::OscMsg, idx::Int)
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)]
return msg.data[arg_pos.+(0:len-1)]
elseif typeChar in "Ss"
return stringify(msg.data[arg_pos:end])
end
@ -323,14 +324,17 @@ function showField(io::IO, msg::OscMsg, arg_id)
'm' :Midi;
'T' true;
'F' false;
'N' Void]
'I' Inf;
'N' Nothing]
dict = Dict{Char, Any}(zip(Vector{Char}(map[:,1][:]),map[:,2][:]))
dict['I'] = Inf
typeChar::Char = argType(msg, arg_id)
value = msg[arg_id]
if issubtype(typeof(value), Array)
if typeof(value) <: Array
value = value'
end
if(value == nothing)
value = "nothing"
end
@printf(io, " #%2d %c:", arg_id, typeChar)
println(dict[typeChar]," - ", value)
end

View File

@ -15,7 +15,7 @@
#License along with this library.
using Base.Test
using Test
using OSC
test_type = length(ARGS) == 1 ? ARGS[1] : "ALL"
@ -23,11 +23,11 @@ test_type = length(ARGS) == 1 ? ARGS[1] : "ALL"
#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))
@ -57,7 +57,7 @@ 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[1] == i
@ -105,8 +105,8 @@ function test_it_osc_spec()
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->(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)
@ -114,8 +114,8 @@ function test_it_osc_spec()
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->(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)