# Reverse Engineering Pluck + aesthetic question

Hi,

First :
I would like to get the 1:1 replica of Pluck, by deconstructing its principle step by step. But I didn’t nail it. This is the comparison between the original and my two attempts:

``````(
// original

SynthDef(\KARPLUS0, {
var freq, sig;
freq = 50;
sig = Pluck.ar(GrayNoise.ar, Impulse.kr(0), freq.reciprocal, freq.reciprocal, 22, 0.1);
Out.ar(0, sig * 0.1 !2 )

}).play;)

// attempt 1

(
SynthDef(\KARPLUS1,  { |  amp = 0.005|

var time, ex, freq, delay, filter, local;
freq = 50;
time = freq.reciprocal;
ex = GrayNoise.ar(EnvGen.kr(Env([1.0,1.0,0.0,0.0], [0.04, 0,100])));
local = LocalIn.ar(1);
filter = OnePole.ar(ex+local, 0.1); //apply filter
delay = DelayN.ar(filter, time, time - ControlDur.ir);

LocalOut.ar(delay * 0.999);
Out.ar(0, delay * 0.1 ! 2);

}).play;)

// attempt 2

(
SynthDef(\KARPLUS2, {

var burst, env, sig, delayTime, freq;
freq = 50;
delayTime = freq.reciprocal;
env = EnvGen.kr(Env.perc(0, 0.12));
burst = GrayNoise.ar(env);
sig = CombL.ar(burst, delayTime, delayTime, 12, add: burst );

DetectSilence.ar(sig, doneAction:2);

Out.ar(0, sig * 0.1 !2 )

} ).play;)

``````

Is someone would be able to make the 1:1 just using the basic Ugens ? It could be really helpfull.

Second:
It’s not about a technical issue but more about an aesthetic advice : I feel stuck on the tone question with this Karplus-Strong algo. I would like to know if there would be an oblique strategy to get others varieties of tone (less metallic) still using the basic principle of KS (not using the DWG Ugens…). So far my only way is to change the nature of the noise burst, or to add effects to the signal. But I would really like to know if it’s possible to imagine a “core” version to change the tone of the KS algo.

Thanks a lot

1 Like

I think it’s basically this if you break it down… Look at the documentation for Pluck, under the trig argument.

upon a negative to positive transition, n samples of the excitation signal will be fed into the delay line, where n = delaytime * sample_rate / 2, using a rectangular envelope (no fading).

So what you have is pretty close, you just didn’t account for that in the envelope.

``````(
SynthDef(\KARPLUS1, {
|freq = 50, decay = 22, coef = 0.1|
var sig, exc, trig;

trig = Impulse.kr(0);

//"upon a negative to positive transition, n samples of the excitation signal will be fed into the delay line"
exc = GrayNoise.ar();

//", where n = delaytime * sample_rate / 2 using a rectangular envelope (no fading)"
exc = exc * Trig.kr(Impulse.kr(0), freq.reciprocal * 0.5); //sampledur * samplerate = 1

sig = CombN.ar(exc, freq.reciprocal, freq.reciprocal, decay); //CombN since the frequency is not modulating

sig = OnePole.ar(sig, coef);

Out.ar(0, sig * 0.1 !2 )

}).play;
)
``````

Probably someone has a better answer about metallic tone than I do, but changing the filter coefficient will help some. I think if you cascade delay lines and filters (like in a Dattorro reverb) it might help as well.
You can also add filters (to cut or boost frequencies) or change the input source to get a tone closer to what you’re after. Keep in mind comb filtering by itself is probably going to give you a metallic stringy sound if you’re feeding it a short burst of noise, hence the built in one pole filter.
You might also layer more sounds in after the filtering to color it a certain way.

*edit: I was right, you can cascade the delay line and you can also modulate the delay time very slightly to recude the metallic artifacts. You might also consider using AllPass instead of Comb.

``````(play{
|freq = 261.63, dec = 1.0|
var exc = WhiteNoise.ar() * Trig.ar(Impulse.ar(0), freq.reciprocal * 0.5);
var n = 10;
var sig = exc;
n.do{sig = AllpassL.ar(sig, freq.reciprocal, freq.reciprocal * LFNoise1.kr(20).range(0.999, 1.0), dec)};
sig;
})
``````

Try using excitation signals that aren’t just noise bursts. Here’s what you can get using a sine wave chirp:

EDIT: Also, be aware that LocalIn/LocalOut incur a delay of one block size, which is by default 64 samples.

8 Likes

wow @nathan that is sick yikes

Killer guitar emulation!