Re: Sv: Sv: What is causing the audible clicks when the envelope is retriggered

borisklompus-g/[email protected] Sat, 19 Jun 2021 22:39:20 +0000
Newsgroups gmane.comp.audio.supercollider.user
Message-ID <gC-Sj5g66-l8w5VQ2BXyCOtftAjxdwUEvVus4rzdUGKzfsFbIp0WN65F1Ce90WMV5xiQjLghV7jsBibvBLrffyyhU4VdsiPoXfF_VdBL1fU=@protonmail.com>
In all of the examples of hard sync that I've seen in SC, it's a linear ram=
p oscillator's frequency, modulating the phase of the synced osc, that sets=
 the frequency for the synced osc, which has its freq argument set to 0. I =
don't know what's happening in the lower level code mechanics that enables =
this, but it seems like this is what gives frequency
control to the phase argument.

In your example, the Sweep isn't doing anything audible that I can tell.. I=
 dropped in your original line of code and have been toggling back and fort=
h and no difference.
// sig =3D SinOsc.ar(freqSweep, Sweep.ar(trigger,freqSweep).linlin(freqA,fr=
eqC,0,1));
sig =3D SinOsc.ar(freqSweep, pi/2);

However, I did realize I made a mistake.. Sweep doesn't actually loop aroun=
d like Phasor does, it just keeps rising until the next trigger, so it need=
s a modulo to constrain it and force it to wrap around to stick between 0 a=
nd 1.

I'm going off this thread for reference:=C2=A0https://scsynth.org/t/fake-re=
sonance-aka-windowed-sync/2720/7. See jamshark's comments about phasor in t=
he code he posted.=C2=A0

Phasor actually sounds pretty wrong when I switch to it, but this is soundi=
ng more like a kick:
sig =3D SinOsc.ar(0, (Sweep.ar(trigger, freqSweep) % 1) * 2pi);

And also a very simple way to keep the range of the sweep between 0 and 2pi=
... since it is a value between 0 and 1, just multiply it by 2pi! Haha I al=
so got that from that thread :)

Anyway, still very different than your initial timbre, but it is starting t=
o sound like a kick drum again!

Boris

=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me=
ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90
On Saturday, June 19th, 2021 at 4:12 PM, <[email protected]> wrote:

> Shouldn=E2=80=99t sweep trigger the phase? The freq of SineOsc should sti=
ll be freqSweep and not 0 (?)
>
> (
>
> SynthDef.new(\k1mono, {
>
> | freqA=3D800, freqB=3D50, freqC=3D40, freqDur1=3D0.02, freqDur2=3D0.5, f=
reqC1=3D(-1), freqC2=3D(-1),
>
> atk=3D0.001, rel=3D1, c1=3D1, c2=3D(-12), amp=3D1, pan=3D0, out=3D0, ts=
=3D1 |
>
> var sig, freqSweep, env, trigger=3D \trig.tr(1);
>
> env =3D EnvGen.ar(Env([0, 0, 1, 0], [0, atk, rel], [c1, c1, c2], 2), trig=
ger, timeScale:ts);
>
> freqSweep =3D EnvGen.ar(Env([freqA, freqA, freqB, freqC],[0,freqDur1,freq=
Dur2],[freqC1,freqC1,freqC2], 1),trigger,timeScale: ts);
>
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sig =3D SinO=
sc.ar(freqSweep, Sweep.ar(trigger,freqSweep).linlin(freqA,freqC,0,1));
>
> sig =3D sig * env;
>
> sig =3D Pan2.ar(sig, pan, amp);
>
> Out.ar(out, sig);
>
> }).add;
>
> )
>
> Skickades fr=C3=A5n E-post f=C3=B6r Windows 10
>
> Fr=C3=A5n: [email protected]
>
> Skickat: Saturday, 19 June 2021 21:42
>
> Till: [email protected]
>
> =C3=84mne: Sv: Sv: [sc-users] What is causing the audible clicks when the=
 envelope is retriggered
>
> Thanks very much! I like the sound of the sweep even if there is less att=
ack. I guess I have to experiment some more in order to
>
> Have more control over how sweep behaves in order to get that attack.
>
> Thanks a lot!
>
> Skickades fr=C3=A5n E-post f=C3=B6r Windows 10
>
> Fr=C3=A5n: borisklompus-g/[email protected]
>
> Skickat: Saturday, 19 June 2021 18:48
>
> Till: [email protected]
>
> =C3=84mne: Re: Sv: [sc-users] What is causing the audible clicks when the=
 envelope is retriggered
>
> Yeah that's true, and your original code was technically correct, but bec=
ause you aren't resetting the sine wave at the same time as your envelope, =
you're getting clicks when it's not at a zero crossing.
>
> But for your timbre, what I'm hearing is that you're using the freqA to '=
announce' the attack stage of the kick, more than the actual ramp to 1. And=
 your amplitude envelope is doing transient shaping, but otherwise is effec=
tively at 1.
>
> // triggers 2/sec
>
> (
>
> // if Trig's dur is set to 0.5 it misses retrigger...=C2=A0
>
> { var atk=3D0.001, rel=3D1, c1=3D1, c2=3D(-12);
>
> EnvGen.kr(Env([0, 1, 0], [atk, rel], [c1, c2], 1), Trig.kr(Impulse.kr(2),=
 0.49));
>
> }.plot(2);
>
> )
>
> (
>
> { var atk=3D0.001, rel=3D1, c1=3D1, c2=3D(-12);
>
> EnvGen.kr(Env([0, 1, 0], [atk, rel], [c1, c2], 1), Trig.kr(Impulse.kr(2),=
 0.499));
>
> }.plot(2);
>
> )
>
> (
>
> { var atk=3D0.001, rel=3D1, c1=3D1, c2=3D(-12);
>
> EnvGen.kr(Env([0, 1, 0], [atk, rel], [c1, c2], 1), Trig.kr(Impulse.kr(2),=
 0.5));
>
> }.plot(2);
>
> )
>
> (
>
> { var atk=3D0.001, rel=3D1, c1=3D1, c2=3D(-12);
>
> EnvGen.kr(Env([0, 0, 1, 0], [0, atk, rel], [c1, c1, c2], 2), Trig.kr(Impu=
lse.kr(2), 0.49));
>
> }.plot(2);
>
> )
>
> Hmm, and this changes the timbre completely, but syncing the sine osc wit=
h the trigger does get rid of=C2=A0 the click...
>
> I'm using Sweep to control the phase of the sine wave, which gets reset w=
ith each trigger. I think technically it should have the linlin(0, 1,=C2=
=A0 0, 2pi) message appended to it, since Sweep is 0 to 1 and phase is 0 to=
 2pi, but I tried that and it lost all sense of kick drum to me.
>
> Using range(0, 2pi) is wrong I think, but sounds a bit better to my ears,=
 but I prefer it completely without any scaling.
>
> Again, it's all quite different sounding than yours - sorry - just might =
be interesting as a different point of approach?
>
> (
>
> SynthDef.new(\k1mono, {
>
> | freqA=3D800, freqB=3D50, freqC=3D40, freqDur1=3D0.02, freqDur2=3D0.5, f=
reqC1=3D(-1), freqC2=3D(-1),
>
> atk=3D0.001, rel=3D1, c1=3D1, c2=3D(-12), amp=3D1, pan=3D0, out=3D0, ts=
=3D1 |
>
> var sig, freqSweep, env, trigger=3D \trig.tr(1);
>
> env =3D EnvGen.ar(Env([0, 0, 1, 0], [0, atk, rel], [c1, c1, c2], 2), trig=
ger, timeScale:ts);
>
> freqSweep =3D EnvGen.ar(Env([freqA, freqA, freqB, freqC],[0,freqDur1,freq=
Dur2],[freqC1,freqC1,freqC2], 2),trigger,timeScale: ts);
>
> sig =3D SinOsc.ar(0, Sweep.ar(trigger, freqSweep));
>
> sig =3D sig * env;
>
> sig =3D Pan2.ar(sig, pan, amp);
>
> Out.ar(out, sig);
>
> }).add;
>
> )
>
> =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original =
Message =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90
>
> On Saturday, June 19th, 2021 at 11:10 AM, <[email protected]> wrot=
e:
>
> > Thanks! Yeah changing release node from 2 to 1 makes it better. I=
=E2=80=99ve never really understood what exactly is going on with the relea=
se nodes. I thought I hade to add the extra 0 in Env([0,0,1,0] because it s=
kips the first when retriggered?
> >
> > I made another sequence so it is easier to here which one is better. I =
thing your first suggestion.
> >
> > (
> >
> > SynthDef.new(\k1mono, {
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | freqA=3D800,=
 freqB=3D50, freqC=3D40, freqDur1=3D0.02, freqDur2=3D0.5, freqC1=3D(-1), fr=
eqC2=3D(-1),
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 atk=3D0.001, r=
el=3D1, c1=3D1, c2=3D(-12), amp=3D1, pan=3D0, out=3D0, ts=3D1 |
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 var sig, freqS=
weep, env, trigger=3D \trig.tr(1);
> >
> > env =3D EnvGen.ar(Env([0, 1, 0], [atk, rel], [c1, c2], 1), trigger, tim=
eScale:ts);
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 freqSweep =
=3D EnvGen.ar(Env([freqA, freqA, freqB, freqC],[0,freqDur1,freqDur2],[freqC=
1,freqC1,freqC2]),trigger,timeScale: ts);
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sig =3D SinOsc=
.ar(freqSweep, pi/2);
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sig =3D sig * =
env;
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sig =3D Pan2.a=
r(sig, pan, amp);
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Out.ar(out, si=
g);
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }).add;
> >
> > )
> >
> > env =3D EnvGen.ar(Env([0, 1, 0], [atk, rel], [c1, c2], 1), trigger, tim=
eScale:ts);=C2=A0 // sounds best
> >
> > env =3D EnvGen.ar(Env([0, 0, 1, 0], [atk * 0.1, atk, rel], [c1, c1, c2]=
, 2), trigger, timeScale:ts); 2nd
> >
> > env =3D EnvGen.ar(Env([0, 0, 1, 0], [atk, atk, rel], [c1, c1, c2], 2), =
trigger, timeScale:ts); 3rd
> >
> > (
> >
> > Pmono(\k1mono,
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \freqC,60,
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \freqB,70,
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #[dur,rel,=
freqA], Ptuple([
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Pseq([0.5,0.25,1,0.25,1,2,0.25,0.25],1=
),
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 Pseq([4,0.75,10,2,5,2,2,1],1),
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 Pseq([800,800,700,500,400,500,300,300],1)
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ]*0.5,inf)=
,
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \trig,1,
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \ts, Pseq([0.9,1],inf),
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \amp,0.2
> >
> > ).play
> >
> > )
> >
> > Skickades fr=C3=A5n E-post f=C3=B6r Windows 10
> >
> > Fr=C3=A5n: borisklompus-g/[email protected]
> >
> > Skickat: Saturday, 19 June 2021 15:40
> >
> > Till: [email protected]
> >
> > =C3=84mne: Re: [sc-users] What is causing the audible clicks when the e=
nvelope is retriggered
> >
> > Hello,
> >
> > I believe that the clicks are caused from the combination of the free r=
unning oscillator not being reset with your amplitude envelope, and the 0 s=
econd first stage attack. You're not starting at a zero crossing of the wav=
e.
> >
> > I removed the first stage of you amplitude envelope and the clicks went=
 away:
> >
> > env =3D EnvGen.ar(Env([0, 1, 0], [atk, rel], [c1, c2], 1), trigger, tim=
eScale:ts);
> >
> > I figure you have that extra stage in there for the retriggering to als=
o have an attack stage (though I don't think it's necessary?), so not remov=
ing it, but setting it to be the same as atk also solves this:
> >
> > env =3D EnvGen.ar(Env([0, 0, 1, 0], [atk, atk, rel], [c1, c1, c2], 2), =
trigger, timeScale:ts);
> >
> > I also scaled it further down, there's a click but it's a bit more harm=
onically consistent...
> >
> > env =3D EnvGen.ar(Env([0, 0, 1, 0], [atk * 0.1, atk, rel], [c1, c1, c2]=
, 2), trigger, timeScale:ts);
> >
> > Boris
> >
> > =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Origina=
l Message =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=
=90
> >
> > On Saturday, June 19th, 2021 at 8:56 AM, <[email protected]> wro=
te:
> >
> > > I am trying to create a kick that cuts off when retriggered. The prob=
lem is that there sometimes are audible clicks when doing this.
> > >
> > > Is there away around this?
> > >
> > > //Instrument
> > >
> > > SynthDef.new(\k1mono, {
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | freqA=3D800,=
 freqB=3D50, freqC=3D40, freqDur1=3D0.02, freqDur2=3D0.5, freqC1=3D(-3), fr=
eqC2=3D(-1),
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 atk=3D0.001, r=
el=3D1, c1=3D1, c2=3D(-12), amp=3D1, pan=3D0, out=3D0, ts=3D1 |
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 var sig, freqS=
weep, env, trigger=3D \trig.tr(1);
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 freqSwee=
p =3D EnvGen.ar(Env([freqA,freqA, freqB, freqC],[0,freqDur1,freqDur2],[0,fr=
eqC1,freqC2],2),trigger);
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 env =3D =
EnvGen.ar(Env([0,0,1,0],[0,atk,rel],[c1,c1,c2],2),trigger,timeScale:ts);
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sig =3D SinOsc=
.ar(freqSweep, pi/2);
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sig =3D sig * =
env;
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sig =3D Pan2.a=
r(sig, pan, amp);
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Out.ar(out, si=
g);
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }).add;
> > >
> > > //Sequence
> > >
> > > (
> > >
> > > Pmono(\k1mono,
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \freqA, =
600,
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \freqC,6=
0,
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \freqB,1=
00,
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \rel, Ps=
eq([1,0.5,3,10],inf),
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \dur, Ps=
eq([0.5,0.25]*0.5,inf),
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \trig,1,
> > >
> > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 \amp,0.0=
3
> > >
> > > ).play
> > >
> > > )
> > >
> > > Best,
> > >
> > > Skickades fr=C3=A5n E-post f=C3=B6r Windows 10

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/