SuperCollider Forum
May 21, 2013, 02:37:55 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: controlling synth  (Read 2726 times)
0 Members and 1 Guest are viewing this topic.
cproud
Newbie
*

Karma: 0
Posts: 3


View Profile
« on: March 31, 2009, 02:13:47 PM »

hi there,
i'm using dictionary for handling my variables and arguments. the question now is how can I change the parameters with Synth using the keys in the dictionaries. Maybe easier explained in an example:
d = Dictionary.new;
d.put("cfreq", 90);
(SynthDef("name", {var instr;
instr = SinOsc.ar(d.at("cfreq"));
Out.ar(0, instr);
}).send(s)
)
y = Synth("name", [d.at("cfreq", 900)])
is obviously wrong, before i had my variables in the dictionary i changed it with the backslash, but i cant seem to work out how it works now,
thanx for any help or hints
Logged
dewdrop_world
AdminGroup
Full Member
*

Karma: 9
Posts: 193



View Profile WWW
« Reply #1 on: April 02, 2009, 09:03:49 PM »

The only way to get new values into a running Synth is using a Control input. Controls are automatically created from arguments of the SynthDef function.

The code you posted looks of the value of d.at("name") once when building the SynthDef. After that, it's hard coded and can't be changed (without rebuilding the SynthDef).

I'd suggest, keep the dictionary on the client side and send the new value as needed using .set --

Code:
d = Dictionary.new;
d.put("cfreq", 90);
(SynthDef("name", { |cfreq = 440|
   var instr;
   instr = SinOsc.ar(freq);
   Out.ar(0, instr);
}).send(s)
)

y = Synth("name", [\cfreq, d.at("cfreq")]);

d["cfreq"] = 900;
y.set("cfreq", d["cfreq"]);

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