controlling jMax from the Web and from PureData
I created a new class "ruby_udpsend" that is an emulation of jMax's "udpsend". Which means you can send messages from PureData to jMax.
I create an objectbox "ruby_udpsend localhost 2042" in PureData. Then I create an objectbox "udpreceive 2042" in jMax. Then messages i send to ruby_udpsend will be catched by jMax.
If you have GridFlow 0.6.5 or 0.7.0 installed, you may add this functionality to PureData by adding those lines to your ~/.gridflow_startup file :
----------------8<--------cut-here--------8<----------------
class RubyUDPSend < FObject def initialize(host,port) @socket = UDPSocket.new @host,@port = host.to_s,port.to_i end def encode(x) case x when Integer; "\x03" + [x].pack("N") when Float; "\x04" + [x].pack("g") when Symbol, String; "\x01" + x.to_s + "\x02" end end def method_missing(sel,*args) sel=sel.to_s.sub /^_\d_/, "" @socket.send encode(sel) + args.map{|arg| encode(arg) }.join("") + "\x0b", 0, @host, @port end install "ruby_udpsend", 1, 0 end
----------------8<--------cut-here--------8<----------------
Furthermore, the above code can be combined with the following one to produce a CGI script capable of sending messages to jMax...
----------------8<--------cut-here--------8<----------------
#!/opt/bin/ruby
ENV["HOME"]="/" STDERR.reopen "/dev/null", "w" require "cgi" require "gridflow" include GridFlow
puts "Content-type: text/plain", "", "hello world!" message = CGI.new.params['message'][0]
# create the gridflow object s = RubyUDPSend.new "karelia", 2042
# convert values and send in inlet 0 of the gridflow object s.send_in 0, *(message.split(',').map {|atom| if atom =~ /^\d/ then if atom =~ /.|E/i then Float(atom) else Integer(atom) end else atom.intern end })
----------------8<--------cut-here--------8<----------------
Mathieu Bouchard http://artengine.ca/matju
On Wed, 12 Feb 2003, Mathieu Bouchard wrote:
controlling jMax from the Web and from PureData
[...]
class RubyUDPSend < FObject
actually FObject should be written GridFlow::FObject here. good night.
Mathieu Bouchard http://artengine.ca/matju