[Fwd: Re: [PD] controlling jMax from the Web and from PureData]

Yves Degoyon ydegoyon at free.fr
Thu Feb 13 11:57:46 CET 2003


ahah, it's been years we're making CGI's
that sends controls from web pages to
Pure Data.

( maybe you're not aware of this
as well as you don't know about subpatches
and say : Pure Data can't do this, blah, blah, blah, ... )

besides, i could never set GridFlow to work
and there's not a single help patch included
for pure data.... it's funny for someone who criticize
PD all the time ( yeah, i don't like too much your posts )

bye,

sevy/yves

Mathieu Bouchard wrote:

 >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, at 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
 >
 >
 >_______________________________________________
 >PD-list mailing list
 >PD-list at iem.kug.ac.at
 >http://iem.kug.ac.at/cgi-bin/mailman/listinfo/pd-list
 >
 >







More information about the Pd-list mailing list