SuperCollider Forum
May 22, 2013, 08:47:28 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: Synths return values  (Read 2611 times)
0 Members and 1 Guest are viewing this topic.
halalkebabhut
Newbie
*

Karma: 0
Posts: 9


View Profile
« on: August 11, 2008, 08:06:20 AM »

Hi,

I'm trying to find a method and syntax to get my synths to return values for specific parameters that are arguments in the SynthDef.

eg.

(
   SynthDef.new(\SawWave, {arg freq, sig, inBus, amp;
   sig = LFSaw.ar(In.kr(freq),0 ,0.2);
   amp = In.kr(inBus);
   Out.ar(0,[sig, sig]* amp );
   }).send(s);
   );

y = Synth.new(\SawWave,   [\freq, f, \inBus, b]);

How can I get y to return a frequency value without refering to f ?

if I use .get method all I get is the name of the Synth.

Is this possible at all?

Si
Logged
dewdrop_world
AdminGroup
Full Member
*

Karma: 9
Posts: 193



View Profile WWW
« Reply #1 on: August 11, 2008, 04:17:29 PM »

There is an example in the Synth helpfile of how to use mySynth.get().

Quote
   get(index, action)
   getMsg(index)
      
      Query the server for the current value of a Control (argument). index is a control name or index. action is a Function which will be evaluated with the value passed as an argument when the reply is received.
      
Code:
s.boot;
(
SynthDef("help-Synth-get", { arg freq = 440;
Out.ar(0, SinOsc.ar(freq, 0, 0.1));
}).send(s);
)
x = Synth("help-Synth-get");
x.set(\freq, 220 + 440.rand);
x.get(\freq, { arg value; ("freq is now:" + value + "Hz").postln; });
x.free;

Keep in mind that every time you ask for a value from the server, it's asynchronous - aSynth.get does not return the value immediately because the client has to wait for the value to come back in an OSC message from the server.

James
Logged

joshp
AdminGroup
Full Member
*

Karma: 5
Posts: 121



View Profile WWW
« Reply #2 on: August 11, 2008, 08:51:02 PM »

Also - if you use the Ctk quark, you can query these values like so:
Code:
a = CtkSynthDef(\test, {arg freq = 440;
Out.ar(0, SinOsc.ar(freq, 0, 0.1))
});

b = a.new.play;
b.freq; // get the value of the freq arg

b.freq_(550); // set it to a new value

b.freq; // query it again

b.free

Hope that helps.

Josh


Logged
halalkebabhut
Newbie
*

Karma: 0
Posts: 9


View Profile
« Reply #3 on: August 12, 2008, 03:24:29 AM »

Thanks,

thats reduced my code significantly

 Smiley
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!