OK!
I have my processes generating sound, and in the interest of keeping this thread going, i have a few more questions.
Too long ; Didn't read version:
It's simple enough to parse arguments in line - e.g. check to see if argument one is valid, argument two, etc. and act appropriately. However, this is akin to doing a $1, $2, $3 ... $n in a shell script. Perfectly valid, but it's not terribly flexible or extensible. How can I do a "getops" type argument parsing in an OscResponder?
Long version:
example sc code:
(
f = OSCresponder(nil, '/ding', { |t, r, msg, addr|
"Entering into OscResponder f".postln;
addr.postln; // posts the address and port from where the message came
msg.postln; // posts the entire message - channel and variables
msg[1].postln; // posts the first argument or 'nil'
msg[2].postln; // posts the second argument or 'nil'
msg[3].postln; // posts the third argument or 'nil'
if (msg[3] != nil) { "Msg 3 is not empty!".postln; };
if (msg[3] == nil) { "Msg 3 is empty!".postln; };
}).add;
)
perl script:
my $client = Net::OpenSoundControl::Client->new( Host => "127.0.0.1", Port => 57120) or die "Could not start client: $@\n"; // cheers nescivi for specifying the port! :)
.... (boring stuff)
$client->send(["/ding","s","Hello world!","s","Hello Moon!","s","Hello Venus!"]);
$client->send(["/ding","s","Hello world!","s","Hello Moon!"]);
..... (more boring stuff)
exit 0;
returns:
a NetAddr(127.0.0.1, 33021)
[ /ding, Hello world!, Hello Moon!, Hello Venus! ]
Hello world!
Hello Moon!
Hello Venus!
Msg 3 is not empty!
Entering into OscResponder f
a NetAddr(127.0.0.1, 33367)
[ /ding, Hello world!, Hello Moon! ]
Hello world!
Hello Moon!
nil
Msg 3 is empty!
This is cool! Makes me happy that SuperCollider is responding to my commands.
I even managed to get it to change the pitch of a sinewave based on the messages sent from perl.
Love it!
So now I'm thinking to myself - I know that I want to say Hi to the World, to the moon and to sometimes Venus, so can I define an osc responder that allows me to send a message to "/hello/world" with value 1 and have it print "Hello World!" ?
Of course I can, I can just define " f = OSCresponder(nil, '/hello/world' .... " but then what about /hello/moon and /hello/venus ? I would have to build a seperate osc responder for those, and that doesn't seem to make much sense! Or, maybe it does, but it would sure hurt my fingers typing that much!
I would think that you could do something like 'getopts' (to use more perl parlance) to have some message like this:
[ "/ding", [ "/world", "1" ], [ "/venus", "1" ]]
that would go to the OscResponder /ding, then look at "/world" in ding, check the variable and print out the appropriate value.
looks intially like a bit more work, but let's say we have a sinOsc that has its volume and pitch defined in the result of an osc responder - wouldn't something like
["/super_osc",["/pitch","440"],["/volume","1"]
make a bit more syntatic sense than ["/superosc",440,1] ?
Still looking through the documentation, for an answer, but any help would be appreciated!
You are a saint!
I now have my two processes communicating, so now i'm up to the painful part of actually getting them to make some sort of sound. :)
Thanks very much.
nescivi wrote:
Hiho,
On Tuesday 04 March 2008 22:57:37 mr.proxxxy wrote:
> Whaaaaaaat?
>
> 1) /anything is defined, but I'm recieving an error message saying it's
> undefined.
> 2) /status is definitely defined, but i'm recieving neither an OK nor a
> Reject. Huh?
> 3) /statoos is not defined, so I'm recieving an error message saying it's
> undefined, as expected.
>
> I know that "/anything" is defined locally ... do I have to do something to
> make this location able to be called from an outside process ?
>
> Am I missing some crucial bit of information?
You have defined the OSCresponders in sclang, which listens normally at port
57120 (check with NetAddr.langPort for the actual port).
However you send the messages from perl to scsynth, which listens at port
57110, and understands only the messages defined in the Server Command
Reference.
It seems what you want to do, is sending messages to sclang, which then
converts them to usable messages for scsynth, so you should change the port
to which you are sending from perl.
sincerely,
Marije
_______________________________________________
sc-users mailing list
sc-users@create.ucsb.edu
http://lists.create.ucsb.edu/mailman/listinfo/sc-users