SuperCollider Forum
May 19, 2013, 03:28:26 PM *
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: glitching when using multiple control busses  (Read 2429 times)
0 Members and 1 Guest are viewing this topic.
halalkebabhut
Newbie
*

Karma: 0
Posts: 9


View Profile
« on: August 30, 2008, 02:52:31 AM »

Hi,

I seem to get a lot of problems when using control busses in combination with synth defs and envelopes. The below example 1 works fine, but when I attempt more complicated proceedures eg. controling several parameters simultaneously and using tasks to sequence them, SC behaves a little unpredictably, producing various different glitches. The second example produces small percussive pops at when the width paramater reaches its extremity. I have a feeling that it could be an issue with timing inaccuracy and the various envelopes overlapping.  What can I do about this. I've tried adding latency but it doesn't seem to work.

S

example 1.

(

a = Bus.control; //width variable is assigned here

   (
   SynthDef.new(\Saw, {
   arg sig,amp = 1;
   sig = Pan2.ar(VarSaw.ar(50,0,In.kr(a),0.2),0);
   sig = sig * amp;
   Out.ar(0, sig);
   }
   ).send(s);
   );

//Single Sweep
   (
   SynthDef.new(\WidSweep, {
   arg sig;
   sig = EnvGen.kr(Env.new([0.02,0.5,0.98],[3,1],[4,1]),1,1,0,1,2);
   Out.kr(a, sig);
   }
   ).send(s);
   );
   
//Looping Synth
   (
   SynthDef.new(\WidReg, {
   arg sig, times = 8;
   sig = EnvGen.kr(Env.new([0.98,0.02,0.98, 0.02],[0.5,0.5,0.5],'linear',2,0),Trig1.kr(1,times),1,0,1,2);
   Out.kr(a, sig);
   }
   ).send(s);
   );



)




w = {Synth.new(\Saw)}.play;
x = {Synth.before(w,\WidReg)}.play;


example 2.

(
t = Task({

var delta, dur, wid, wids, widIndex = [0,\WidSweep, \WidReg ];

w = {Synth.new(\Saw)}.play;

dur = Pseq(  [3, 4,  8.5,]).asStream;
wids = Pseq( [0, 1,   2, ]).asStream;

while {
         delta = dur.next;
         delta.notNil

      }{
      wid = wids.next;
      x = if(wid > 0,{Synth.before(w,widIndex[wid])},{0});
      delta.yield;
      };

}).play;
)
Logged
dewdrop_world
AdminGroup
Full Member
*

Karma: 9
Posts: 193



View Profile WWW
« Reply #1 on: September 02, 2008, 08:27:12 PM »

Quote
w = {Synth.new(\Saw)}.play;

Oh... don't do this. Playing a function expects that the function will return a group of unit generators, not a Synth object. Take out the braces and the .play and it will be simpler.

You're right, this could have something to do with timing. The server timing help file explains the issues involved. I'd say, take a look at that and see if it helps. If not, we can look at other things.

James
Logged

halalkebabhut
Newbie
*

Karma: 0
Posts: 9


View Profile
« Reply #2 on: September 08, 2008, 04:48:03 PM »

Thanks,

The problem is a little clearer now ... when I use doneAction 2 on an envelope it needs roughly 0.2 seconds to release. If I try and use another envelope on the same control bus before that then I get a glitch - I assume because the envelopes are overlapping. I looked at the server timing help file and attempted to add latency to my synths again but it still made no difference at all. I'm not sure I'm applying the latency correctly though - see below. Am I missing something here ?

S

 (
t = Task({

var delta, dur, wid, wids, widIndex = [0,\WidSweep, \WidReg ];

w = Synth.new(\Saw).play;

dur = Pseq(  [3, 4,  8.5,]).asStream;
wids = Pseq( [0, 1,   2, ]).asStream;

while {
         delta = dur.next;
         delta.notNil

      }{
      wid = wids.next;
      x = if(wid > 0,{
                            s.makeBundle(0.25,Synth.before(w,widIndex[wid]))},
                          {0});
      delta.yield;
      };

}).play;
)
Logged
dewdrop_world
AdminGroup
Full Member
*

Karma: 9
Posts: 193



View Profile WWW
« Reply #3 on: September 09, 2008, 12:04:46 PM »

The tricky thing with Out is that it's additive. The fact that your envelopes start and end with nonzero values means that every time you start one of these control synths, the value on the bus is going to jump by the envelope's starting value (and again, in reverse, by the ending value when the synth stops).

This is easy to demonstrate if you have the ddwCommon quark installed. (Note, this won't work unless you have the quark.)

Code:
g = GenericGlobalControl(\test, nil, 0);

g.gui;

g.watch;

// slider jumps to 0.1
a = g.play({ var x = SinOsc.kr; (x-x) + 0.1 });

// slider jumps to 0.6 -- is that what you expected?
b = g.play({ var x = SinOsc.kr; (x-x) + 0.5 });

a.free;
b.free;
g.free;

I'm not clear what you're after. Do you want the later control synth to override the previous one? Or should they be added together?

One thought is to crossfade the new envelope in using XOut, e.g.

Code:
(
SynthDef.new(\WidSweep, {
var sig, xfenv;
sig = EnvGen.kr(Env.new([0.02,0.5,0.98],[3,1],[4,1]),1,1,0,1);
xfenv = Linen.kr( (your gate here), attackTime: 0.05, susLevel: 1, releaseTime: 0.05, doneAction: 2);
XOut.kr(a, xfenv, sig);
}).send(s);
)

... so that, on top of the control value envelope, there's another envelope to control how much influence the control envelope will have (0 = no influence, 1 = overwrites the old bus value completely). I think the xf envelope is the one that should have doneAction: 2 and the control envelope doneAction: 0.

If you want to blend the control values, use 0.5 for susLevel.

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