A simple framework for OSC communication in the Crystal language.
-
Add the dependency to your
shard.yml:dependencies: osc-cr: github: M1sui/osc-cr
-
Run
shardsorshards instal
See your-project/lib/example/OSC-Example.cr for details.
# 1. Initialize
require "osc-cr"
osc = OSC.new("127.0.0.1", 9000, 9001)
# 2. Receive Event
osc.message(path: "/test/aba") { |event|
puts(event.data) #-> OSC argument - Value
puts(event.data.path) #-> OSC Message - "/test/aba"
puts(event.data.type) #-> Bool | Int32 | Float32 | String | Nil
# Send can be used anywhere after initialization
osc.sendb("/test/aba/respond".true)
}
# 3. Recieve Server Run
osc.run()
# 4. Other Process
osc.sendb("/test/hoge", true) # -> Bool
osc.sendi("/test/fuga", 123) # -> Int
osc.sendf("/test/piyo", 1.23) # -> Float
loop {
osc.sendi("/test/minute", Time.local.minute)
sleep(1.second)
}The order must be in accordance with the numbering.
- InstanceMethod(X: Instance_VRC) - creator and maintainer