aberant / osc-ruby Goto Github PK
View Code? Open in Web Editor NEWOpen Sound Control Library for Ruby
License: MIT License
Open Sound Control Library for Ruby
License: MIT License
Hi, not sure if you're still maintaining this package. I wanted to try using this in a Rails project, but ended up with some errors in other packages because of the time method overrides. The return values from seconds
, minutes
, etc. are different than those from the same methods in ActiveSupport.
Is there a way to disable the class extension by any chance since all of those methods are already provided by Rails?
Thank you
def run
EM::run { EM::open_datagram_socket "localhost", @PORT, Connection }
end
the above code caused me problems when trying to get TouchOSC on an iPad to comunicate with my Mac (Snow Leopard 10.6.3, ruby 1.8.7). A local client/server would work but nothing from the iPad was being received. iPad to other osc compatible apps does work.
changing the EMServer class to accept an address parameter (below) and then passing in my local ip (i.e. 192.168.1.100) got it all working but is not really ideal when using DHCP.
class EMServer
def initialize( address = "localhost", port = 3333 )
@port = port
@address = address
setup_dispatcher
@tuples = []
end
def run
EM::run { EM::open_datagram_socket @address, @port, Connection }
end
Thanks
I have the following application scheme:
There is a OSC UDP server that has some properties. I connect to it and can subscribe to property changes by sending to "/xremote" periodically. The server will then send me updates on properties to the port I sent the subscription message from. So I need to receive from the same socket as I use for sending.
I use the following workaround:
@client = OSC::Client.new('10.1.2.3', 1234)
@server = OSC::EMServer.new(99999)
socket = @client.instance_variable_get(:@so)
def @server.run(s)
EM.error_handler{ |e|
Thread.main.raise e
}
EM.run do
EM::attach s, OSC::Connection
end
end
It would be nice to have the possibility without a hack.
Hey, just a gentle request to push out an update to this gem. I was trying to use the new ip_address info in the message, and wasted a bit of time trying to figure out why it was throwing an exception... only to find that those bits were missing from the rubygems version of the gem. :P
I've pulled it from github for the time being, so it's low priority.
Thanks!
Greetings and thanks for this lib. Please check the following line for a typo.
https://github.com/aberant/osc-ruby/blob/master/lib/osc-ruby/server.rb#L61
mesg
should be message
/Users/guest/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/osc-ruby-1.1.4/lib/osc-ruby/server.rb:61:in `block in dispatch_message': undefined local variable or method `mesg' for #<OSC::Server:0x00007f9aa113a0e0> (NameError)
Did you mean? message
The server still seems to work in my test app after the exception, but obviously something isn't going according to plan. See my code below. This only happens when the sleep is there, which I don't need, but I thought you'd want to know. Cheers.
EventMachine.run do
server = Server.new $PORT
puts "OSC server started on port #{$PORT}"
server.add_method /.*/ do |message| # this will match any address
p "/.*/: #{message.ip_address}:#{message.ip_port} -- #{message.address} -- #{message.to_a} }"
end
server.add_method %r{foo/.*} do |message| # this will match any /foo node
p "%r{foo/.*}: #{message.ip_address}:#{message.ip_port} -- #{message.address} -- #{message.to_a} }"
end
server.add_method "/foo/bar" do |message| # this will just match /foo/bar address
p "'/foo/bar': #{message.ip_address}:#{message.ip_port} -- #{message.address} -- #{message.to_a} }"
end
server.add_method "/exit" do |message| # this will just match /exit address
exit
end
Thread.new do
server.run
end
sleep 1
# hit Control + C to stop
Signal.trap("INT") { server.stop }
Signal.trap("TERM") { server.stop }
client = Client.new 'localhost', 8001
client.send( OSC::Message.new( "/greeting" , "hullo!" ))
client.send Message.new('/foo/bar', 1, 1.2, 'a string')
client.send Message.new('/foo/bar/zar', 1, 1.2, 'a string')
# client.send Bundle.new(Time.now + 2, Message.new('/exit'))
end
Hi,
I'm doing some work with the osc-ruby library and it's been great so far, but I've run into a problem. Basically, I'd like to route part of a namespace and pass on what follows (similarly to how osc-route operates in Max/MSP). For example, if I'm monitoring the following namespace:
"/example/test/"
and I send the message:
"/example/test/my/namespace 5.0"
I'd like osc-ruby to pass on "/my/namespace 5.0"
Is there a simple way to do this?
Thanks,
Graham.
I have a script which sends osc messages to a server repeatedly, if i run it on jruby or using ruby-osc instead it functions but when i run it with standard ruby and osc-ruby (2.0.0 and 1.9.2 tested) it will give the following error after a few minutes. the socket information is the same each time and works for a while.
`connect': getaddrinfo: nodename nor servname provided, or not known (SocketError)
I've attached the send method for reference.
Can anyone shed any light?
def msg_send(message, channel, argu)
@client = Client.new("localhost", 10002)
@client.send Message.new("#{message}#{channel}", argu)
# puts "#{message}#{channel}", argu
end
It seems like osc-ruby is silently rescuing exception inside the message handlers.
If I raise an arbitrary exception inside a block passed to add_method the exception is silently handled somewhere. My most base example was to take the example code and add raise my own exception:
require 'rubygems'
require 'osc-ruby'
require 'osc-ruby/em_server'
@server = OSC::EMServer.new( 3333 )
@client = OSC::Client.new( 'localhost', 3333 )
@server.add_method '/greeting' do | message |
puts "#{message.ip_address}:#{message.ip_port} -- #{message.address} -- #{message.to_a}"
raise Exception.new "This is an exception"
end
Thread.new do
@server.run
end
@client.send( OSC::Message.new( "/greeting" , "hullo!" ))
sleep( 3 )```
And I get nothing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.