SuperCollider Forum
May 20, 2013, 02:03:40 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: The SuperCollider forum is currently experiencing a rash of spambot registrations. New user requests may not be approved quickly as a result -- and if your email address looks like spam, it might not be approved at all. We are working to improve the security of the registration process, and to provide alternate means to contact the administrators to get a new account. Thanks for your patience.
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: OSCResponder node help  (Read 3907 times)
0 Members and 1 Guest are viewing this topic.
jrs
Newbie
*

Karma: 0
Posts: 1


View Profile
« on: June 18, 2008, 10:41:12 PM »

Hi All,

I'm pretty new to sc so please forgive me if im missing something obvious here but shouldnt the OSC responder below set the synth freq

// Dump OSC messages so we can see whats happening
s.sendMsg("/dumpOSC", 0);
s.sendMsg("/dumpOSC", 1);

(
SynthDef("simpSinOsc", { arg freq=800, phase=0, mul=1, add=0;
   var osc;
   osc = SinOsc.ar(freq, 0, mul, add); // 800 Hz sine oscillator
   Out.ar([0,1], osc);                 // send output to audio bus zero.
}).writeDefFile;                        // write the def to disk in the default directory synthdefs/

s.sendSynthDef("simpSinOsc");
)


// Some messages to test the synth is working
s.sendMsg("/s_new", "simpSinOsc", 3000, 0, 0.5, "freq", 447); // create synth
s.sendMsg("/n_set", 3000, "freq", -400);
s.sendMsg("/n_free", 3000);  // kill synth


// Setup an osc responder (im using an LFO object combined with an OSC send object in quartz composer to trigger it)
(
var osc1_nodeID = 3000;
a = OSCresponder(nil, '/objX',  { |t, r, msg| s.sendMsg("/n_set", osc1_nodeID, "freq",  round(600 + (msg[1] * 100)) ); msg[1].postln }).add;
s.sendMsg("/s_new", "simpSinOsc", osc1_nodeID, 0, 1); // create synth
)

// When this gets setup we can hear the 800hz sine tone - but as soon as the OSCresponder sets the freq there is no sound - we can test
// this using the below messages - the first two should silence the synth and the second works as expected - if you watch the server
// window you can see the messages are the same so why do they work differently?

n = NetAddr("127.0.0.1", 57120);
n.sendMsg("/objX", 1.3);
s.sendMsg("/n_set", 3000, "freq", 590);


//-------------------------------
// Some code to remove everything
(
var osc1_nodeID = 3000;

s.sendMsg("/n_free", osc1_nodeID);  // kill synth

a.remove;
b.remove;
)


Logged
joshp
AdminGroup
Full Member
*

Karma: 5
Posts: 121



View Profile WWW
« Reply #1 on: June 18, 2008, 10:55:49 PM »

Just sent this to sc-users... but I'll add it here as well for documenttion:

Hmm... not sure why, but changing to an OSCresponderNode takes care of the problem:

// Setup an osc responder (im using an LFO object combined with an OSC send object in quartz composer to trigger it but simulate this below)
(
var osc1_nodeID = 3000;
a = OSCresponderNode(nil, '/objX', { |t, r, msg|
   s.sendMsg("/n_set", osc1_nodeID, "freq",  round(600 + (msg[1] * 100)) ); msg[1].postln
   }).add;
s.sendMsg("/s_new", "simpSinOsc", osc1_nodeID, 0, 1); // create synth
)

I suggest using OSCresponderNode anyways (since you can then have multiple instances of the class). OR- give the NetAddr and that seems to work:

n = NetAddr("127.0.0.1", 57120);
(
var osc1_nodeID = 3000;
a = OSCresponder(n, '/objX', { |t, r, msg|
   s.sendMsg("/n_set", osc1_nodeID, "freq",  round(600 + (msg[1] * 100)) ); msg[1].postln
   }).add;
s.sendMsg("/s_new", "simpSinOsc", osc1_nodeID, 0, 1); // create synth
)

Why the other doesn't work though is a little mystery (and my tired brain can't look at the moment). Hopefully, one of the two solutions above works until I or someone else can figure it out.

best,

Josh
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!