[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] very heavy click problem with this synth/routine
Am 28.12.2013 um 17:51 schrieb sc <mailofdjeho@xxxxxxxxx>:
> Hello, list
>
> I found this synth from old time, (it's not mine, it's from this list, kindly offered by Batuhan Bozkurt) and having fun to play with it.
>
> the only problem is that it's horribly clicky. especially when loading not percussive samples. but also with perc samples which has kinda long decay.
> I tried to track down the source of the problem, but since it's not my synth and also that I'm quite bad at DSP stuff, I just can't figure out...randomly placing Lag or LPF here and there just mess things up, and create even more problems. I don't even know yet if it's my routine or the synth itself which produces click problems.
Hi,
there are no envelopes in this SynthDef, the read index is
jumping which might cause clicks.
If you want to avoid the clicks (some also regard them as idiomatic)
you'd have to implement appropriate envelopes.
The principle is clear: multiply every segment with an envelope,
but implementation is a bit tricky.
Following the original code we see that a repeated segment has a length of
sliceDur / stutter - but in Frames, not in seconds !
So to get the length of this segment you must divide it by SampleRate.ir
We want to be able to control fadeIn and fadeOut times,
just simple attack/sustain/release envelopes.
But we also have to consider the case when segments are shorter
than the sum of both, then decrease fadeIn and fadeOut proportionally.
Here's the crucial part of the code, see what will happen when
length of segment (envTimeStutter) is greater/smaller (fadeInStutter + fadeOutStutter)
envTimeFadeStutterRatio = envTimeStutter / (fadeInStutter + fadeOutStutter);
fadeStutterFactor = min(envTimeFadeStutterRatio, 1);
envStutter = EnvGen.ar(Env([0, 1, 1, 0], [
fadeStutterFactor * fadeInStutter,
max(0, envTimeStutter - fadeInStutter - fadeOutStutter),
fadeStutterFactor * fadeOutStutter
]).circle);
Secondly the whole looping (envTimeAll) should also get an envelope
(gateRatio could be > 1), done in the same way with times fadeInAll and fadeOutAll.
If we give this envelope a usual doneAction 2, we can drop the FreeSelf ugen.
SynthDef(\junglism_mono_env1, {|out = 0, pan = 0, bufnum, div = 16,
slice = 0, gateRatio = 1, stutter = 1, amp = 1, rate = 1,
fadeInStutter = 0.01, fadeOutStutter = 0.01, fadeInAll = 0.01, fadeOutAll = 0.01|
var needle, snd, addFrame, sliceDur, bufDur, envStutter, envAll,
envTimeAll, envTimeStutter, envTimeFadeStutterRatio, fadeStutterFactor,
envTimeFadeAllRatio, fadeAllFactor;
bufDur = BufFrames.ir(bufnum);
sliceDur = bufDur / div;
addFrame = (slice * sliceDur);
envTimeAll = sliceDur / gateRatio / SampleRate.ir;
envTimeStutter = sliceDur / stutter / SampleRate.ir;
envTimeFadeStutterRatio = envTimeStutter / (fadeInStutter + fadeOutStutter);
fadeStutterFactor = min(envTimeFadeStutterRatio, 1);
envStutter = EnvGen.ar(Env([0, 1, 1, 0], [
fadeStutterFactor * fadeInStutter,
max(0, envTimeStutter - fadeInStutter - fadeOutStutter),
fadeStutterFactor * fadeOutStutter
]).circle);
envTimeFadeAllRatio = envTimeStutter / (fadeInAll + fadeOutAll);
fadeAllFactor = min(envTimeFadeAllRatio, 1);
envAll = EnvGen.ar(Env([0, 1, 1, 0], [
fadeAllFactor * fadeInAll,
max(0, envTimeAll - fadeInAll - fadeOutAll),
fadeAllFactor * fadeOutAll
]), doneAction: 2);
needle = Phasor.ar(0, BufRateScale.kr(bufnum) * rate, 0, bufDur);
snd = BufRd.ar(1, bufnum, (needle % (sliceDur / stutter)) + addFrame);
OffsetOut.ar(out, Pan2.ar(snd, pan) * amp * envStutter * envAll);
}).add;
// check effects of args (esp. fadeInStutter / fadeOutStutter) before sequencing with a Routine / Task / Pattern
Synth(\junglism_mono_env1, [\bufnum, b, \slice, 4, \stutter, 3, \div, 10, \fadeInStutter, 0.01, \fadeOutStutter, 0.01])
Synth(\junglism_mono_env1, [\bufnum, b, \slice, 3, \stutter, 5, \div, 8, \fadeInStutter, 0.01, \fadeOutStutter, 0.01])
Synth(\junglism_mono_env1, [\bufnum, b, \slice, 3, \stutter, 5, \div, 8, \fadeInStutter, 0.01, \fadeOutStutter, 0.01, \gateRatio, 2])
And - boringly repeating myself - consider using Pbind instead of a Routine,
you will get much more out of the SynthDef.
Greetings
Daniel
-----------------------------
www.daniel-mayer.at
-----------------------------
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/