├── 3 OP Simple FM Example.dsp ├── Filter Series n FX Example.dsp ├── Filter-Tremolo-Example.dsp ├── ITDpan.dsp ├── Looper With Effects Example.dsp ├── Phasor Triangle.dsp ├── Polyphonic Breath Control Example.dsp ├── Polyphonic Synthesizer.dsp ├── README.md ├── Shred It Strum Example.dsp └── UI Group Example.dsp /3 OP Simple FM Example.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | 3 | gain = hslider("[4]gain[style:knob]",1,0,1,0.01); 4 | gate = button("[5]gate"); 5 | freq = hslider("freq",440,50,2000,0.01); 6 | 7 | dxOscA = os.osc(freq)*envelope 8 | with{ 9 | envelope = hgroup("[0]Envelope",en.adsr(attack,decay,sustain,release,gate)) 10 | with{ 11 | attack = hslider("[0]Attack[style:knob]",50,1,1000,1)*0.001; 12 | decay = hslider("[1]Decay[style:knob]",50,1,1000,1)*0.001; 13 | sustain = hslider("[2]Sustain[style:knob]",0.8,0.01,1,1); 14 | release = hslider("[3]Release[style:knob]",50,1,1000,1)*0.001; 15 | }; 16 | }; 17 | 18 | dxOscB = os.osc(freq+dxOscA*mod2)*envelope2 19 | with{ 20 | mod2 = hslider("[2]Mod2[style:knob]",50,1,2000,1); 21 | envelope2 = hgroup("[1]Envelope2",en.adsr(attack,decay,sustain,release,gate)) 22 | with{ 23 | attack = hslider("[0]Attack[style:knob]",50,1,1000,1)*0.001; 24 | decay = hslider("[1]Decay[style:knob]",50,1,1000,1)*0.001; 25 | sustain = hslider("[2]Sustain[style:knob]",0.8,0.01,1,1); 26 | release = hslider("[3]Release[style:knob]",50,1,1000,1)*0.001; 27 | }; 28 | }; 29 | 30 | dxOscC = os.osc(freq+dxOscB*mod3)*envelope3 31 | with{ 32 | mod3 = hslider("[5]Mod3[style:knob]",50,1,2000,1); 33 | envelope3 = hgroup("[4]Envelope3",en.adsr(attack,decay,sustain,release,gate)*0.3*gain) 34 | with{ 35 | attack = hslider("[0]Attack[style:knob]",50,1,1000,1)*0.001; 36 | decay = hslider("[1]Decay[style:knob]",50,1,1000,1)*0.001; 37 | sustain = hslider("[2]Sustain[style:knob]",0.8,0.01,1,1); 38 | release = hslider("[3]Release[style:knob]",50,1,1000,1)*0.001; 39 | }; 40 | }; 41 | 42 | myEq = hgroup("[6]Peak Eq",fi.peak_eq(boost,peak,bw)) 43 | with{ 44 | boost = hslider("[0]Boost[style:knob]",0,-20,20,0.1); 45 | peak = hslider("[1]Peak[style:knob]",50,50,1000,1); 46 | bw = hslider("[2]Q[style:knob]",100,10,1000,1); 47 | }; 48 | 49 | process = dxOscC : myEq <: dm.zita_light; -------------------------------------------------------------------------------- /Filter Series n FX Example.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | waveGenerator = hgroup("[0]Wave Generator",no.noise,os.triangle(freq),os.square(freq),os.sawtooth(freq) : ba.selectn(4,wave)) 3 | with{ 4 | wave = nentry("[0]Waveform",3,0,3,1); 5 | freq = hslider("[1]freq",440,50,2000,0.01); 6 | }; 7 | 8 | peakFilters = hgroup("[1]Peak EQ Filters",seq(i,2,myFilters(i))) 9 | with{ 10 | myFilters(i) = fi.peak_eq(boost,peakFreq,bw) 11 | with{ 12 | boost = hslider("[0]Boost%i[style:knob]",0,-20,20,0.1); 13 | peak = hslider("[1]Peak%i[style:knob]",50,50,10000,0.1); 14 | bw = hslider("[2]Q%i[style:knob]",100,10,1000,1); 15 | peakRate = hslider("[3]LFO Freq%i",10,0.1,20,0.01); 16 | peakMod = hslider("[4]LFO Mod%i",0,0,10000,1); 17 | peakFreq = os.osc(peakRate)*peakMod + peak: max(30); 18 | }; 19 | }; 20 | 21 | subtractive = waveGenerator : peakFilters : hgroup("[2]Main Filter",fi.resonlp(resFreq,q,1)) 22 | with{ 23 | ctFreq = hslider("[0]Cutoff Frequency[style:knob]",2000,50,10000,0.1) : si.smoo; 24 | q = hslider("[1]Q[style:knob]",5,1,30,0.1); 25 | lfoFreq = hslider("[2]Rate[style:knob]",10,0.1,20,0.01); 26 | lfoDepth = hslider("[3]Depth[style:knob]",0,0,10000,1); 27 | resFreq = os.osc(lfoFreq)*lfoDepth + ctFreq : max(30); 28 | }; 29 | envelope = hgroup("[2]Envelope",en.adsr(attack,decay,sustain,release,gate)*tremolo*0.3) 30 | with{ 31 | attack = hslider("[0]Attack[style:knob]",50,1,1000,1)*0.001; 32 | decay = hslider("[1]Decay[style:knob]",50,1,1000,1)*0.001; 33 | sustain = hslider("[2]Sustain[style:knob]",0.8,0.01,1,1); 34 | release = hslider("[3]Release[style:knob]",50,1,1000,1)*0.001; 35 | gain = hslider("[4]gain[style:knob]",1,0,1,0.01); 36 | gate = button("[5]gate"); 37 | tremlfoFreq = hslider("[6]Tremolo Rate[style:knob]",10,0.1,20,0.01); 38 | tremlfoDepth = hslider("[7]Tremolo Depth[style:knob]",0,0,1,0.01); 39 | tremolo = (os.osc(tremlfoFreq)*tremlfoDepth) + gain; 40 | }; 41 | 42 | process = vgroup("Subtractive Synthesizer",subtractive*envelope); 43 | effect = dm.phaser2_demo : dm.freeverb_demo; -------------------------------------------------------------------------------- /Filter-Tremolo-Example.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | waveGenerator = hgroup("[0]Wave Generator",no.noise,os.triangle(freq),os.square(freq),os.sawtooth(freq) : ba.selectn(4,wave)) 3 | with{ 4 | wave = nentry("[0]Waveform",3,0,3,1); 5 | freq = hslider("[1]freq",440,50,2000,0.01); 6 | }; 7 | subtractive = waveGenerator : hgroup("[1]Filter",fi.resonbp(resFreq,q,1)) 8 | with{ 9 | ctFreq = hslider("[0]Cutoff Frequency[style:knob]",2000,50,10000,0.1) : si.smoo; 10 | q = hslider("[1]Q[style:knob]",5,1,30,0.1); 11 | lfoFreq = hslider("[2]Rate[style:knob]",10,0.1,20,0.01); 12 | lfoDepth = hslider("[3]Depth[style:knob]",0,0,10000,1); 13 | resFreq = os.osc(lfoFreq)*lfoDepth + ctFreq : max(30); 14 | }; 15 | envelope = hgroup("[2]Envelope",en.adsr(attack,decay,sustain,release,gate)*tremolo*0.3) 16 | with{ 17 | attack = hslider("[0]Attack[style:knob]",50,1,1000,1)*0.001; 18 | decay = hslider("[1]Decay[style:knob]",50,1,1000,1)*0.001; 19 | sustain = hslider("[2]Sustain[style:knob]",0.8,0.01,1,1); 20 | release = hslider("[3]Release[style:knob]",50,1,1000,1)*0.001; 21 | gain = hslider("[4]gain[style:knob]",1,0,1,0.01); 22 | gate = button("[5]gate"); 23 | tremlfoFreq = hslider("[6]Tremolo Rate[style:knob]",10,0.1,20,0.01); 24 | tremlfoDepth = hslider("[7]Tremolo Depth[style:knob]",0,0,1,0.01); 25 | tremolo = (os.osc(tremlfoFreq)*tremlfoDepth) + gain; 26 | }; 27 | 28 | process = vgroup("Subtractive Synthesizer",subtractive*envelope); -------------------------------------------------------------------------------- /ITDpan.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | 3 | // ITD: the Interaural Time Difference in samples, assuming that: 4 | // - the distance between the two ears is: 0.2 m 5 | // - the speed of the sound is: 340 m/s 6 | // - the sampling rate is: ma.SR 7 | ITD = (0.2/340)*ma.SR; 8 | 9 | // itdpan(p): ITD based panoramic 10 | // The parameter p indicates the position of the source: 11 | // 0.0 (full left): 0 on the left channel, full ITD delay on the right channel 12 | // 0.5 (center): half ITD delay on both channels 13 | // 1.0 (full right): full ITD delay on the left channel and 0 delay on the right channel 14 | itdpan(p) = _ <: @(p*ITD), @(ITD*(1-p)); 15 | process = ba.pulsen(1,10000) * checkbox("play") : pm.djembe(60,0.3,0.5,1) : itdpan(hslider("pan", 0.5, 0, 1, 0.01)); -------------------------------------------------------------------------------- /Looper With Effects Example.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | looper(detune) = rwtable(tablesize,0.0,recIndex,_,readIndex) 3 | with{ 4 | record = button("Record") : int; 5 | readSpeed = hslider("Read Speed",1,0.001,10,0.01); 6 | tablesize = 48000; 7 | recIndex = +(1)~*(record) : %(tablesize); 8 | readIndex = readSpeed*(detune+1)/float(ma.SR) : (+ : ma.decimal) ~ _ : *(float(tablesize)) : int; 9 | }; 10 | polyLooper = vgroup("[0]Looper",_ <: par(i,nVoices,looper(detune*i)) :> _,_) 11 | with{ 12 | nVoices = 10; 13 | detune = hslider("Detune",0.01,0,1,0.01); 14 | }; 15 | myFlanger = hgroup("[1]Flanger",pf.flanger_mono(50,flangerOffset,flangerDepth,flangerFb,0)) 16 | with{ 17 | flangerDepth = hslider("[0]Depth[style:knob]",1,0,2,0.1) : si.smoo; 18 | flangerOffset = hslider("[1]Offset[style:knob]",10,10,100,1); 19 | flangerFb = hslider("[2]Feedback[style:knob]",0,0,0.95,0.01); 20 | }; 21 | myEcho = hgroup("[2]Delay",ef.echo(2,delayTime,delayFb)) 22 | with{ 23 | delayTime = hslider("[0]Time[style:knob]",0.3,0,2,0.01); 24 | delayFb = hslider("[1]Feedback[style:knob]",0.5,0,1,0.01); 25 | }; 26 | 27 | process = polyLooper:> myFlanger : myEcho; 28 | 29 | -------------------------------------------------------------------------------- /Phasor Triangle.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | phase(f) = f/ma.SR : (+,1:fmod) ~ _; 3 | triangle(f) = (((phase(f)-0.5) : abs)*4)-1; 4 | test(f) = os.triangle(f); 5 | process = triangle(hslider("freq", 440, 40, 8000, 1)); -------------------------------------------------------------------------------- /Polyphonic Breath Control Example.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | 3 | declare interface "SmartKeyboard{ 4 | 'Number of Keyboards':'2', 5 | 'Max Keyboard Polyphony':'12', 6 | 'Keyboard 0 - Number of Keys':'4', 7 | 'Keyboard 1 - Number of Keys':'4', 8 | 'Keyboard 0 - Lowest Key':'60', 9 | 'Keyboard 1 - Lowest Key':'67', 10 | 'Keyboard 0 - Scale':'2', 11 | 'Keyboard 1 - Scale':'2', 12 | 'Rounding Mode':'0' 13 | }"; 14 | 15 | freq = hslider("freq",440,50,1000,0.01); 16 | gain = hslider("gain",0.5,0,1,0.01); 17 | gate = button("gate") : en.adsr(0.01,0.01,0.9,0.1); 18 | breathControl = an.amp_follower_ar(0.1,0.1); 19 | timbre(f) = os.sawtooth(f); 20 | process = (gain*gate*timbre(freq)*0.5),breathControl : * <: _,_; 21 | effect = dm.zita_light; -------------------------------------------------------------------------------- /Polyphonic Synthesizer.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | freq = hslider("freq",440,50,1000,0.01); 3 | gain = hslider("gain",0.5,0,1,0.01); 4 | gate = button("gate") : en.adsr(0.01,0.01,0.9,0.1); 5 | timbre(f) = os.sawtooth(f)*0.5 + os.osc(f*2)*0.25 + os.osc(f*3)*0.125; 6 | process = gain*gate*timbre(freq)*0.5 <: _,_; 7 | effect = dm.zita_light; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Faust-Course-Examples 2 | 3 | Coursework examples from the course"Real Time Audio Signal Processing In Faust" 4 | https://www.kadenze.com/courses/real-time-audio-signal-processing-in-faust 5 | -------------------------------------------------------------------------------- /Shred It Strum Example.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | string(f) = hgroup("String[0]",+~(de.fdelay4(maxDelLength,delLength-1) : dispersionFilter : *(damping))) 3 | with{ 4 | freq = f; 5 | damping = hslider("[1]Damp[style:knob]",0.99,0,1,0.01); 6 | maxDelLength = 1024; 7 | dispersionFilter = _ <: _,_' :> /(2); 8 | delLength = ma.SR/freq; 9 | }; 10 | pluck = hgroup("[1]Pluck",gate : ba.impulsify*gain) 11 | with{ 12 | gain = hslider("[0]Gain[style:knob]",1,0,1,0.01); 13 | }; 14 | 15 | freqSlider = hslider("Freq",110,50,1000,1); 16 | // nStrings = hslider("Strings",6,1,12,1); 17 | nStrings = 6; 18 | 19 | strum = hgroup("[3]",hslider("[0]Strum",0,0,nStrings-1,1) <: par(i,nStrings,(_==i : ba.impulsify : string((i+1)*freqSlider*interval))) :> _) 20 | with{ 21 | interval = hslider("[0]Interval[style:knob]",0.5,0,1,0.01); 22 | }; 23 | myEcho = hgroup("[4]Delay",ef.echo(2,delayTime,delayFb)) 24 | with{ 25 | delayTime = hslider("[0]Time[style:knob]",0.3,0,2,0.01); 26 | delayFb = hslider("[1]Feedback[style:knob]",0.5,0,1,0.01); 27 | }; 28 | myReverb = hgroup("[5]Reverb", dm.zita_light); 29 | process = vgroup("Karplus Strong",strum : myEcho <: myReverb); 30 | -------------------------------------------------------------------------------- /UI Group Example.dsp: -------------------------------------------------------------------------------- 1 | import("stdfaust.lib"); 2 | eqGroup = vgroup("[0]EQ",bas,mid,tre) 3 | with{ 4 | bas = vslider("[0]Bass[style:knob]", -6, -70, 12, 0.1); 5 | mid = vslider("[1]Mid[style:knob]", -6, -70, 12, 0.1); 6 | tre = vslider("[2]Treble[style:knob]", -6, -70, 12, 0.1); 7 | }; 8 | volGroup = hgroup("[1]",lvl,mtr) 9 | with{ 10 | lvl = vslider("[0]Gain", -24, -70, 12, 0.1); 11 | mtr = vbargraph("[1]Level[scale:log]", -70, 12); 12 | }; 13 | process = hgroup("Voice",eqGroup,volGroup); --------------------------------------------------------------------------------