File: karplus32.dsp

package info (click to toggle)
faust 2.79.3%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 397,496 kB
  • sloc: cpp: 278,433; ansic: 116,164; javascript: 18,529; vhdl: 14,052; sh: 13,884; java: 5,900; objc: 3,852; python: 3,222; makefile: 2,655; cs: 1,672; lisp: 1,146; ruby: 954; yacc: 586; xml: 471; lex: 247; awk: 110; tcl: 26
file content (46 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
declare name 		"karplus32";
declare version 	"1.0";
declare author 		"Grame";
declare license 	"BSD";
declare copyright 	"(c)GRAME 2006";

//-----------------------------------------------
// 			karplus-strong
//		with 32 resonators in parallel
//-----------------------------------------------

import("stdfaust.lib"); 

// Excitator
//--------

upfront(x) 	= (x-x') > 0.0;
decay(n,x)	= x - (x>0)/n;
release(n)	= + ~ decay(n);
trigger(n) 	= upfront : release(n) : >(0.0) : +(leak);
leak 		= 1.0/65536.0;

size 		= hslider("excitation (samples)", 128, 2, 512, 1);

// Resonator
//-----------------

dur 		= hslider("duration (samples)", 128, 2, 512, 1);
att 		= hslider("attenuation", 0.1, 0, 1, 0.01);
average(x)	= (x+x')/2;

resonator(d, a) = (+ : de.delay(4096, d-1.5)) ~ (average : *(1.0-a)) ;

// Polyphony
//-----------------

detune 		= hslider("detune", 32, 0, 512, 1);
polyphony 	= hslider("polyphony", 1, 0, 32, 1);
output 		= hslider("output volume", 0.5, 0, 1, 0.1);

process =  vgroup("karplus32",
	 		   	vgroup("noise generator", no.noise * hslider("level", 0.5, 0, 1, 0.1))
				 : vgroup("excitator", *(button("play"): trigger(size)))
				<: vgroup("resonator x32", par(i,32, resonator(dur+i*detune, att) * (polyphony > i)))
				:> *(output),*(output)
			);