Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Basic Feedback Delay Network SynthDef
name
code content
// Construct a circulant feedback matrix using the given eigenvalues ( // 1 - The eigenvalues of the feedback coefficient matrix d = [ -1, Polar(1, -3pi / 4), Polar(1, -pi / 2), Polar(1, -pi / 6), 1, Polar(1, pi / 6), Polar(1, pi / 2), Polar(1, 3pi / 4) ]; // 2 - Compute the feedback matrix from the given eigenvalues n = d.size; a = (Matrix.newIDFT(n) * Matrix.withFlatArray(n, 1, d)).real.flat / sqrt(n); ) ( s.waitForBoot({ var primePowerDelays = { arg delays; (delays collect: { |delay, i| var prime = i.nthPrime; prime ** ((log(delay) / log(prime)) + 0.5).floor; }).asInteger / s.sampleRate; }; var delayLengths = { arg n, dmin, dmax; var nm1 = n - 1; var d = dmin * ((dmax / dmin) ** ((0..nm1) / nm1)); (d * s.sampleRate).round(1.0).asInteger; }; SynthDef(\sine, { arg out, freq = 440, amp = 0.5, trigFreq = 1; Out.ar(out, Decay.ar(Impulse.ar(trigFreq), 0.2, SinOsc.ar(freq, 0, amp))) }).add; SynthDef(\fdn, { arg in, out, scale = 1.0, coef = 0.5; var a, x, w, fb, delT; fb = LocalIn.ar(n); a = \a.kr(0 ! n); delT = \delT.kr(primePowerDelays.(delayLengths.(n, 0.03, 0.06))); x = In.ar(in); w = a.size collect: { arg i; DelayN.ar(a.rotate(i).inject(x, { |input, coef| coef * fb[i] + input }), 1, (delT[i] * scale - ControlDur.ir).fold(0.0, 1.0)) }; LocalOut.ar(LeakDC.ar(OnePole.ar(w, coef))); Out.ar(out, w.sum.tanh ! 2) }).add; { s.scope(2) }.defer }); ) ( s.makeBundle(nil, { x = Synth(\sine, [\out, 10, \trigFreq, 0.25, \amp, 0.1], 1, \addToHead); y = Synth(\fdn, [\in, 10, \out, 0, \a, a, \scale, 1, \coef, 0.5], 1, \addToTail); }); )
code description
Example of a basic feedback delay network or FDN of order 8. Requires the MathLib quark. Use the scale argument to increase / decrease the delay time and the coef argument to control the decay time. Smaller scale values produce resonating sounds, larger scale values more reverb tail like sounds. Be careful with small scale values in combination with small coef values (hence the tanh). For a theoretical reference see: https://ccrma.stanford.edu/~jos/cfdn/
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change