Faust Examples

This page contains an overview of the examples folder of the Faust distribution. Examples are organized by category and should all be executable in the online editor by clicking on the “Try it Yourself” button.

ambisonics

fourSourcesToOcto

declare name "fourSourcesToOcto"; declare version "1.0"; declare author "CICM"; declare license "BSD"; declare copyright "(c)CICM 2013"; import("stdfaust.lib"); r1 = hslider("Radius1", 1.0, 0, 5, 0.001) : si.smooth(ba.tau2pole(0.02)); a1 = hslider("Angle1", 0, ma.PI*(-2), ma.PI*2, 0.001) : si.smooth(ba.tau2pole(0.02)); r2 = hslider("Radius2", 1.0, 0, 5, 0.001) : si.smooth(ba.tau2pole(0.02)); a2 = hslider("Angle2", 0, ma.PI*(-2), ma.PI*2, 0.001) : si.smooth(ba.tau2pole(0.02)); r3 = hslider("Radius3", 1.0, 0, 5, 0.001) : si.smooth(ba.tau2pole(0.02)); a3 = hslider("Angle3", 0, ma.PI*(-2), ma.PI*2, 0.001) : si.smooth(ba.tau2pole(0.02)); r4 = hslider("Radius4", 1.0, 0, 5, 0.001) : si.smooth(ba.tau2pole(0.02)); a4 = hslider("Angle4", 0, ma.PI*(-2), ma.PI*2, 0.001) : si.smooth(ba.tau2pole(0.02)); process(sig1, sig2, sig3, sig4) = ho.map(3, sig1, r1, a1), ho.map(3, sig2, r2, a2), ho.map(3, sig3, r3, a3), ho.map(3, sig4, r4, a4) :> ho.optimInPhase(3) : ho.decoder(3, 8); Try it Yourself >>

oneSourceToStereo

declare name "oneSourceToStereo"; declare version "1.0"; declare author "CICM"; declare license "BSD"; declare copyright "(c)CICM 2013"; import("stdfaust.lib"); r1 = hslider("Radius", 1.0, 0, 5, 0.001) : si.smooth(ba.tau2pole(0.02)); a1 = hslider("Angle", 0, ma.PI*(-2), ma.PI*2, 0.001) : si.smooth(ba.tau2pole(0.02)); process(sig) = ho.map(7, sig, r1, a1) : ho.optimInPhase(7) : ho.decoderStereo(7); Try it Yourself >>

analysis

dbmeter

declare name "dbmeter"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //------------------------------------------------- // A dB Vumeter //------------------------------------------------- import("stdfaust.lib"); vmeter(x) = attach(x, envelop(x) : vbargraph("[unit:dB]", -70, 10)); hmeter(x) = attach(x, envelop(x) : hbargraph("[unit:dB]", -70, 10)); envelop = abs : max(ba.db2linear(-70)) : ba.linear2db : min(10) : max ~ -(80.0/ma.SR); null(x) = attach(0,x); process = hgroup("8 channels dB meter", par(i,8, vgroup("%i", vmeter : null))); Try it Yourself >>

FFT

// Radix 2 FFT, decimation in time, real and imag parts interleaved declare name "FFT"; // Faust Fourier Transform :-) declare author "JOS"; declare license "STK-4.3"; import("stdfaust.lib"); N=32; // FFT size (power of 2) // Number of frequency bins (including dc and SR/2) is N/2+1 No2 = N>>1; signal = amp * cosine with { cosine = select2(k==0, select2(k==No2, 2.0*os.oscrc(f(k)), // 2x since negative-frequencies not displayed 1-1':+~*(-1) // Alternating sequence: 1, -1, 1, -1 ), 1.0); // make sure phase is zero (freq jumps around) f(k) = float(k) * ma.SR / float(N); // only test FFT bin frequencies k = hslider("[2] FFT Bin Number",N/4,0,No2,0.001) : int <: _,dpy : attach; dpy = hbargraph("[3] Measured FFT Bin Number",0,No2); amp = hslider("[4] Amplitude",0.1,0,1,0.001); }; process = signal : dm.fft_spectral_level_demo(N) <: _,_; Try it Yourself >>

spectralLevel

declare name "spectralLevel"; declare version "0.0"; declare author "JOS, revised by RM"; declare description "Demonstrates mth_octave_spectral_level in a standalone GUI."; import("stdfaust.lib"); process = dm.spectral_level_demo; Try it Yourself >>

spectralTiltLab

// example exercising filters.lib's spectral_tilt_demo declare name "spectralTiltLab"; import("stdfaust.lib"); N = 10; // Number of pole-zero pairs to use process = sig(dm.sawtooth_demo) : stg(ba.bypass1(bp,dm.spectral_tilt_demo(N))) <: sag(dm.spectral_level_demo) with { bp = stg(checkbox("[0] Bypass Spectral Tilt")); stg(x) = vgroup( "[1] Spectral Tilt Filter [tooltip: See Faust's filters.lib for spectral_tilt_demo]",x); sig(x) = vgroup( "[2] Test Signal [tooltip: See Faust's oscillator.lib for sawtooth_demo]",x); sag(x) = vgroup( "[4] Spectrum Analyzer [tooltip: See Faust's filters.lib for spectral_level_demo]",x); }; Try it Yourself >>

vumeter

declare name "vumeter"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //------------------------------------------------- // Simple vumeter //------------------------------------------------- import("stdfaust.lib"); vmeter(x) = attach(x, envelop(x) : vbargraph("[2][unit:dB]", -70, +5)); hmeter(x) = attach(x, envelop(x) : hbargraph("[2][unit:dB]", -70, +5)); envelop = abs : max ~ -(1.0/ma.SR) : max(ba.db2linear(-70)) : ba.linear2db; process = hmeter,hmeter; Try it Yourself >>

bela

AdditiveSynth_Analog

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Additive synthesizer, must be used with OSC message to program sound. // It as 8 harmonics. Each have it's own volume envelope. // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_0 : vol0 (volum of fundamental) // ANALOG_1 : vol1 // ... // ANALOG_7 : vol7 // // OSC messages (see BELA console for precise adress) // For each harmonics (%rang indicate harmonic number, starting at 0) : // A%rang : Attack // D%rang : Decay // S%rang : Sustain // R%rang : Release // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL midigate = button("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 10, 0.01); // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; partiel(rang) = os.oscrs(gFreq*(rang+1))*volume with { // UI vol = hslider("vol%rang[BELA: ANALOG_%rang]", 1, 0, 1, 0.001); a = 0.01 * hslider("A%rang", 1, 0, 400, 0.001); d = 0.01 * hslider("D%rang", 1, 0, 400, 0.001); s = hslider("S%rang", 1, 0, 1, 0.001); r = 0.01 * hslider("R%rang", 1, 0, 800, 0.001); volume = ((en.adsr(a,d,s,r,midigate))*vol) : max (0) : min (1); }; process = par(i, 8, partiel(i)) :> / (8); Try it Yourself >>

AdditiveSynth

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Additive synthesizer, must be used with OSC message to program sound. // It as 8 harmonics. Each have it's own volume envelope. // /////////////////////////////////////////////////////////////////////////////////////////////////// // // OSC messages (see BELA console for precise adress) // For each harmonics (%rang indicate harmonic number, starting at 0) : // vol%rang : General Volume (vol0 control the volume of the fundamental) // A%rang : Attack // D%rang : Decay // S%rang : Sustain // R%rang : Release // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL midigate = button("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 10, 0.01); // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; partiel(rang) = os.oscrs(gFreq*(rang+1))*volume with { // UI vol = hslider("vol%rang", 1, 0, 1, 0.001); a = 0.01 * hslider("A%rang", 1, 0, 400, 0.001); d = 0.01 * hslider("D%rang", 1, 0, 400, 0.001); s = hslider("S%rang", 1, 0, 1, 0.001); r = 0.01 * hslider("R%rang", 1, 0, 800, 0.001); volume = ((en.adsr(a,d,s,r,midigate))*vol) : max (0) : min (1); }; process = par(i, 8, partiel(i)) :> / (8); Try it Yourself >>

crossDelay2

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Stereo Delay with feedback and crossfeedback (L to R and R to L feedback). // And pitch shifting on feedback. // A pre-delay without feedback is added for a wider stereo effect. // // Designed to use the Analog Input for parameters controls. // /////////////////////////////////////////////////////////////////////////////////////////////////// // // ANALOG IN: // ANALOG 0 : Pre-Delay L // ANALOG 1 : Pre-Delay R // ANALOG 2 : Delay L // ANALOG 3 : Delay R // ANALOG 4 : Cross feedback // ANALOG 5 : Feedback // ANALOG 6 : Pitchshifter L // ANALOG 7 : Pitchshifter R // // Available by OSC : (see BELA console for precise adress) // Feedback filter: // crossLF : Crossfeedback Lowpass // crossHF : Crossfeedback Highpass // feedbLF : Feedback Lowpass // feedbHF : Feedback Highpass // /////////////////////////////////////////////////////////////////////////////////////////////////// preDelL = ba.sec2samp(hslider("preDelL[BELA: ANALOG_0]", 1,0,2,0.001)):si.smoo; preDelR = ba.sec2samp(hslider("preDelR[BELA: ANALOG_1]", 1,0,2,0.001)):si.smoo; delL = ba.sec2samp(hslider("delL[BELA: ANALOG_2]", 1,0,2,0.001)):si.smoo; delR = ba.sec2samp(hslider("delR[BELA: ANALOG_3]", 1,0,2,0.001)):si.smoo; crossLF = hslider("crossLF", 12000, 20, 20000, 0.001); crossHF = hslider("crossHF", 60, 20, 20000, 0.001); feedbLF = hslider("feedbLF", 12000, 20, 20000, 0.001); feedbHF = hslider("feedbHF", 60, 20, 20000, 0.001); CrossFeedb = hslider("CrossFeedb[BELA: ANALOG_4]", 0.0, 0., 1, 0.001):si.smoo; feedback = hslider("feedback[BELA: ANALOG_5]", 0.0, 0., 1, 0.001):si.smoo; pitchL = hslider("shiftL[BELA: ANALOG_6]", 0,-12,12,0.001):si.smoo; pitchR = hslider("shiftR[BELA: ANALOG_7]", 0,-12,12,0.001):si.smoo; routeur(a,b,c,d) = ((a*CrossFeedb):fi.lowpass(2,crossLF):fi.highpass(2,crossHF))+((b*feedback):fi.lowpass(2,feedbLF):fi.highpass(2,feedbHF))+c, ((b*CrossFeedb):fi.lowpass(2,crossLF):fi.highpass(2,crossHF))+((a*feedback):fi.lowpass(2,feedbLF):fi.highpass(2,feedbHF))+d; process = (de.sdelay(65536, 512,preDelL),de.sdelay(65536, 512,preDelR)):(routeur : de.sdelay(65536, 512,delL) , de.sdelay(65536, 512,delR))~(ef.transpose(512, 256, pitchL) , ef.transpose(512, 256, pitchR)); Try it Yourself >>

FMSynth2_Analog

import("all.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple FM synthesizer. /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_0 : Modulator frequency ratio // ANALOG_1 : Attack // ANALOG_2 : Decay/Release // ANALOG_3 : Sustain // // MIDI: // CC 1 : FM feedback on modulant oscillator. // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL, Keyboard midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 1, 0, 1, 0.01); // modwheel: feedb = (gFreq-1) * (hslider("feedb[midi:ctrl 1]", 0, 0, 1, 0.001) : si.smoo); modFreqRatio = hslider("ratio[BELA: ANALOG_0]",2,0,20,0.01) : si.smoo; // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; //=================================== Parameters Mapping ================================= //======================================================================================== // Same for volum & modulation: volA = hslider("A[BELA: ANALOG_1]",0.01,0.01,4,0.01); volDR = hslider("DR[BELA: ANALOG_2]",0.6,0.01,8,0.01); volS = hslider("S[BELA: ANALOG_3]",0.2,0,1,0.01); envelop = en.adsre(volA,volDR,volS,volDR,midigate); // modulator frequency modFreq = gFreq * modFreqRatio; // modulation index FMdepth = envelop * 1000 * midigain; // Out Amplitude vol = envelop; //============================================ DSP ======================================= //======================================================================================== FMfeedback(frq) = (+(_,frq):os.osci) ~ (* (feedb)); FMall(f) = os.osci(f+ (FMdepth*FMfeedback(f*modFreqRatio))); process = FMall(gFreq) * vol; Try it Yourself >>

FMSynth2

import("all.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple FM synthesizer. // 2 oscillators and FM feedback on modulant oscillator // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // // CC 1 : FM feedback on modulant oscillator. // CC 14 : Modulator frequency ratio. // // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // CC 72 : Release // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL, Keyboard midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 1, 0, 1, 0.01); // modwheel: feedb = (gFreq-1) * (hslider("feedb[midi:ctrl 1]", 0, 0, 1, 0.001) : si.smoo); modFreqRatio = hslider("ratio[midi:ctrl 14]",2,0,20,0.01) : si.smoo; // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; //=================================== Parameters Mapping ================================= //======================================================================================== // Same for volum & modulation: volA = hslider("A[midi:ctrl 73]",0.01,0.01,4,0.01); volD = hslider("D[midi:ctrl 76]",0.6,0.01,8,0.01); volS = hslider("S[midi:ctrl 77]",0.2,0,1,0.01); volR = hslider("R[midi:ctrl 72]",0.8,0.01,8,0.01); envelop = en.adsre(volA,volD,volS,volR,midigate); // modulator frequency modFreq = gFreq*modFreqRatio; // modulation index FMdepth = envelop * 1000 * midigain; // Out Amplitude vol = envelop; //============================================ DSP ======================================= //======================================================================================== FMfeedback(frq) = (+(_,frq):os.osci ) ~ (* (feedb)); FMall(f) = os.osci(f+(FMdepth*FMfeedback(f*modFreqRatio))); process = FMall(gFreq) * vol; Try it Yourself >>

FMSynth2_FX_Analog

import("all.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple FM synthesizer. // 2 oscillators and FM feedback on modulant oscillator // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_0 : Modulator frequency ratio // ANALOG_1 : Attack // ANALOG_2 : Decay/Release // ANALOG_3 : Sustain // // MIDI: // CC 1 : FM feedback on modulant oscillator. // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL, Keyboard midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 1, 0, 1, 0.01); // modwheel: feedb = (gFreq-1) * (hslider("feedb[midi:ctrl 1]", 0, 0, 1, 0.001) : si.smoo); modFreqRatio = hslider("ratio[BELA: ANALOG_0]",2,0,20,0.01) : si.smoo; // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; //=================================== Parameters Mapping ================================= //======================================================================================== // Same for volum & modulation: volA = hslider("A[BELA: ANALOG_1]",0.01,0.01,4,0.01); volDR = hslider("DR[BELA: ANALOG_2]",0.6,0.01,8,0.01); volS = hslider("S[BELA: ANALOG_3]",0.2,0,1,0.01); envelop = en.adsre(volA,volDR,volS,volDR,midigate); // modulator frequency modFreq = gFreq * modFreqRatio; // modulation index FMdepth = envelop * 1000 * midigain; // Out Amplitude vol = envelop; //============================================ DSP ======================================= //======================================================================================== FMfeedback(frq) = (+(_,frq):os.osci) ~ (* (feedb)); FMall(f) = os.osci(f+ (FMdepth*FMfeedback(f*modFreqRatio))); //#################################################################################################// //##################################### EFFECT SECTION ############################################// //#################################################################################################// // // Simple FX chaine build for a mono synthesizer. // It controle general volume and pan. // FX Chaine is: // Drive // Flanger // Reverberation // // This version use ANALOG IN to controle some of the parameters. // Other parameters continue to be available by MIDI or OSC. // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_4 : Distortion Drive // ANALOG_5 : Flanger Dry/Wet // ANALOG_6 : Reverberation Dry/Wet // ANALOG_7 : Reverberation Room size // // MIDI: // CC 7 : Volume // CC 10 : Pan // // CC 13 : Flanger Delay // CC 13 : Flanger Delay // CC 94 : Flanger Feedback // // CC 95 : Reverberation Damp // CC 90 : Reverberation Stereo Width // /////////////////////////////////////////////////////////////////////////////////////////////////// // VOLUME: volFX = hslider("volume[midi:ctrl 7]",1,0,1,0.001); // Should be 7 according to MIDI CC norm. // EFFECTS ///////////////////////////////////////////// drive = hslider("drive[BELA: ANALOG_4]",0.3,0,1,0.001); // Flanger curdel = hslider("flangDel[midi:ctrl 13]",4,0.001,10,0.001); fb = hslider("flangFeedback[midi:ctrl 94]",0.7,0,1,0.001); fldw = hslider("dryWetFlang[BELA: ANALOG_5]",0.5,0,1,0.001); flanger = efx with { fldel = (curdel + (os.lf_triangle(1) * 2) ) : min(10); efx = _ <: _, pf.flanger_mono(10,fldel,1,fb,0) : dry_wet(fldw); }; // Pannoramique: panno = _ : sp.panner(hslider ("pan[midi:ctrl 10]",0.5,0,1,0.001)) : _,_; // REVERB (from freeverb_demo) reverb = _,_ <: (*(g)*fixedgain,*(g)*fixedgain : re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)), *(1-g), *(1-g) :> _,_ with { scaleroom = 0.28; offsetroom = 0.7; allpassfeed = 0.5; scaledamp = 0.4; fixedgain = 0.1; origSR = 44100; damping = vslider("Damp[midi:ctrl 95]",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR; combfeed = vslider("RoomSize[BELA: ANALOG_7]", 0.7, 0, 1, 0.025)*scaleroom*origSR/ma.SR + offsetroom; spatSpread = vslider("Stereo[midi:ctrl 90]",0.6,0,1,0.01)*46*ma.SR/origSR; g = vslider("dryWetReverb[BELA: ANALOG_6]", 0.4, 0, 1, 0.001); // (g = Dry/Wet) }; // Dry-Wet (from C. LEBRETON) dry_wet(dw,x,y) = wet*y + dry*x with { wet = 0.5*(dw+1.0); dry = 1.0-wet; }; // ALL effect = _ *(volFX) : ef.cubicnl_nodc(drive, 0.1) : flanger : panno : reverb; process = FMall(gFreq) * vol; Try it Yourself >>

FMSynth2_FX

import("all.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple FM synthesizer. // 2 oscillators and FM feedback on modulant oscillator // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // // CC 1 : FM feedback on modulant oscillator. // CC 14 : Modulator frequency ratio. // // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // CC 72 : Release // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL, Keyboard midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 1, 0, 1, 0.01); // modwheel: feedb = (gFreq-1) * (hslider("feedb[midi:ctrl 1]", 0, 0, 1, 0.001) : si.smoo); modFreqRatio = hslider("ratio[midi:ctrl 14]",2,0,20,0.01) : si.smoo; // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; //=================================== Parameters Mapping ================================= //======================================================================================== // Same for volum & modulation: volA = hslider("A[midi:ctrl 73]",0.01,0.01,4,0.01); volD = hslider("D[midi:ctrl 76]",0.6,0.01,8,0.01); volS = hslider("S[midi:ctrl 77]",0.2,0,1,0.01); volR = hslider("R[midi:ctrl 72]",0.8,0.01,8,0.01); envelop = en.adsre(volA,volD,volS,volR,midigate); // modulator frequency modFreq = gFreq*modFreqRatio; // modulation index FMdepth = envelop * 1000 * midigain; // Out Amplitude vol = envelop; //============================================ DSP ======================================= //======================================================================================== FMfeedback(frq) = ( +(_,frq):os.osci ) ~ (* (feedb)); FMall(f) = os.osci(f+ (FMdepth*FMfeedback(f*modFreqRatio))); //#################################################################################################// //##################################### EFFECT SECTION ############################################// //#################################################################################################// // Simple FX chaine build for a mono synthesizer. // It controle general volume and pan. // FX Chaine is: // Drive // Flanger // Reverberation // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // (All are available by OSC) // // CC 7 : Volume // CC 10 : Pan // // CC 92 : Distortion Drive // // CC 13 : Flanger Delay // CC 93 : Flanger Dry/Wet // CC 94 : Flanger Feedback // // CC 12 : Reverberation Room size // CC 91 : Reverberation Dry/Wet // CC 95 : Reverberation Damp // CC 90 : Reverberation Stereo Width // /////////////////////////////////////////////////////////////////////////////////////////////////// // VOLUME: volFX = hslider("volume[midi:ctrl 7]",1,0,1,0.001);// Should be 7 according to MIDI CC norm. // EFFECTS ///////////////////////////////////////////// drive = hslider("drive[midi:ctrl 92]",0.3,0,1,0.001); // Flanger curdel = hslider("flangDel[midi:ctrl 13]",4,0.001,10,0.001); fb = hslider("flangFeedback[midi:ctrl 94]",0.7,0,1,0.001); fldw = hslider("dryWetFlang[midi:ctrl 93]",0.5,0,1,0.001); flanger = efx with { fldel = (curdel + (os.lf_triangle(1) * 2) ) : min(10); efx = _ <: _, pf.flanger_mono(10,fldel,1,fb,0) : dry_wet(fldw); }; // Pannoramique: panno = _ : sp.panner(hslider ("pan[midi:ctrl 10]",0.5,0,1,0.001)) : _,_; // REVERB (from freeverb_demo) reverb = _,_ <: (*(g)*fixedgain,*(g)*fixedgain : re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)), *(1-g), *(1-g) :> _,_ with { scaleroom = 0.28; offsetroom = 0.7; allpassfeed = 0.5; scaledamp = 0.4; fixedgain = 0.1; origSR = 44100; damping = vslider("Damp[midi:ctrl 95]",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR; combfeed = vslider("RoomSize[midi:ctrl 12]", 0.7, 0, 1, 0.025)*scaleroom*origSR/ma.SR + offsetroom; spatSpread = vslider("Stereo[midi:ctrl 90]",0.6,0,1,0.01)*46*ma.SR/origSR; g = vslider("dryWetReverb[midi:ctrl 91]", 0.4, 0, 1, 0.001); // (g = Dry/Wet) }; // Dry-Wet (from C. LEBRETON) dry_wet(dw,x,y) = wet*y + dry*x with { wet = 0.5*(dw+1.0); dry = 1.0-wet; }; // ALL effect = _ *(volFX) : ef.cubicnl_nodc(drive, 0.1) : flanger : panno : reverb; process = FMall(gFreq) * vol; Try it Yourself >>

FXChaine2

import("stdfaust.lib"); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // A complete Stereo FX chain with: // CHORUS // PHASER // DELAY // REVERB // // Designed to use the Analog Input for parameters controls. // // CONTROLES //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // ANALOG IN: // ANALOG 0 : Chorus Depth // ANALOG 1 : Chorus Delay // ANALOG 2 : Phaser Dry/Wet // ANALOG 3 : Phaser Frequency ratio // ANALOG 4 : Delay Dry/Wet // ANALOG 5 : Delay Time // ANALOG 6 : Reverberation Dry/Wet // ANALOG 7 : Reverberation Room size // // Available by OSC : (see BELA console for precise adress) // Rate : Chorus LFO modulation rate (Hz) // Deviation : Chorus delay time deviation. // // InvertSum : Phaser inversion of phaser in sum. (On/Off) // VibratoMode : Phaser vibrato Mode. (On/Off) // Speed : Phaser LFO frequency // NotchDepth : Phaser LFO depth // Feedback : Phaser Feedback // NotchWidth : Phaser Notch Width // MinNotch1 : Phaser Minimal frequency // MaxNotch1 : Phaser Maximal Frequency // // Damp : Reverberation Damp // Stereo : Reverberation Stereo Width // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// process = chorus_stereo(dmax,curdel,rate,sigma,do2,voices) : phaserSt : xdelay : reverb; // CHORUS (from SAM demo lib) ////////////////////////////////////////////////////////////////////////////////////////////////////////// voices = 8; // MUST BE EVEN pi = 4.0*atan(1.0); periodic = 1; dmax = 8192; curdel = dmax * vslider("Delay[BELA: ANALOG_1]", 0.5, 0, 1, 1) : si.smooth(0.999); rateMax = 7.0; // Hz rateMin = 0.01; rateT60 = 0.15661; rate = vslider("Rate", 0.5, rateMin, rateMax, 0.0001): si.smooth(ba.tau2pole(rateT60/6.91)); depth = vslider("Depth [BELA: ANALOG_0]", 0.5, 0, 1, 0.001) : si.smooth(ba.tau2pole(depthT60/6.91)); // (dept = dry/wet) depthT60 = 0.15661; delayPerVoice = 0.5*curdel/voices; sigma = delayPerVoice * vslider("Deviation",0.5,0,1,0.001) : si.smooth(0.999); do2 = depth; // use when depth=1 means "multivibrato" effect (no original => all are modulated) chorus_stereo(dmax,curdel,rate,sigma,do2,voices) = _,_ <: *(1-do2),*(1-do2),(*(do2),*(do2) <: par(i,voices,voice(i)):>_,_) : ro.interleave(2,2) : +,+; voice(i) = de.fdelay(dmax,min(dmax,del(i)))/(i+1) with { angle(i) = 2*pi*(i/2)/voices + (i%2)*pi/2; voice(i) = de.fdelay(dmax,min(dmax,del(i))) * cos(angle(i)); del(i) = curdel*(i+1)/voices + dev(i); rates(i) = rate/float(i+1); dev(i) = sigma * os.oscp(rates(i),i*2*pi/voices); }; // PHASER (from demo lib.) ///////////////////////////////////////////////////////////////////////////////////////////////////////////// phaserSt = _,_ <: _, _, phaser2_stereo : dry_wetST(dwPhaz) with { invert = checkbox("InvertSum"); vibr = checkbox("VibratoMode"); // In this mode you can hear any "Doppler" phaser2_stereo = pf.phaser2_stereo(Notches,width,frqmin,fratio,frqmax,speed,mdepth,fb,invert); Notches = 4; // Compile-time parameter: 2 is typical for analog phaser stomp-boxes speed = hslider("Speed", 0.5, 0, 10, 0.001); depth = hslider("NotchDepth", 1, 0, 1, 0.001); fb = hslider("Feedback", 0.7, -0.999, 0.999, 0.001); width = hslider("NotchWidth",1000, 10, 5000, 1); frqmin = hslider("MinNotch1",100, 20, 5000, 1); frqmax = hslider("MaxNotch1",800, 20, 10000, 1) : max(frqmin); fratio = hslider("NotchFreqRatio[BELA: ANALOG_3]",1.5, 1.1, 4, 0.001); dwPhaz = vslider("dryWetPhaser[BELA: ANALOG_2]", 0.5, 0, 1, 0.001); mdepth = select2(vibr,depth,2); // Improve "ease of use" }; // DELAY (with feedback and crossfeeback) ////////////////////////////////////////////////////////////////////////////////////////////// delay = ba.sec2samp(hslider("delay[BELA: ANALOG_5]", 1,0,2,0.001)); preDelL = delay/2; delL = delay; delR = delay; crossLF = 1200; CrossFeedb = 0.6; dwDel = vslider("dryWetDelay[BELA: ANALOG_4]", 0.5, 0, 1, 0.001); routeur(a,b,c,d) = ((a*CrossFeedb):fi.lowpass(2,crossLF))+c, ((b*CrossFeedb):fi.lowpass(2,crossLF))+d; xdelay = _,_ <: _,_,((de.sdelay(65536, 512,preDelL),_): (routeur : de.sdelay(65536, 512,delL) ,de.sdelay(65536, 512,delR) ) ~ (_,_)) : dry_wetST(dwDel); // REVERB (from freeverb_demo) ///////////////////////////////////////////////////////////////////////////////////////////////////////// reverb = _,_ <: (*(g)*fixedgain,*(g)*fixedgain : re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)), *(1-g), *(1-g) :> _,_ with { scaleroom = 0.28; offsetroom = 0.7; allpassfeed = 0.5; scaledamp = 0.4; fixedgain = 0.1; origSR = 44100; damping = vslider("Damp",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR; combfeed = vslider("RoomSize[BELA: ANALOG_7]", 0.5, 0, 1, 0.001)*scaleroom*origSR/ma.SR + offsetroom; spatSpread = vslider("Stereo",0.5,0,1,0.01)*46*ma.SR/origSR; g = vslider("dryWetReverb[BELA: ANALOG_6]", 0.2, 0, 1, 0.001); // (g = Dry/Wet) }; // Dry-Wet (from C. LEBRETON) dry_wetST(dw,x1,x2,y1,y2) = (wet*y1 + dry*x1),(wet*y2 + dry*x2) with { wet = 0.5*(dw+1.0); dry = 1.0-wet; }; Try it Yourself >>

GrainGenerator

/////////////////////////////////////////////////////////////////////////////////////////////////// // // Grain Generator. // Another granular synthesis example. // This one is not finished, but ready for more features and improvements... // /////////////////////////////////////////////////////////////////////////////////////////////////// // // ANALOG IN: // ANALOG 0 : Population: 0=almost nothing. 1=Full grain // ANALOG 1 : Depth of each grin, in ms. // ANALOG 2 : Position in the table = delay // ANALOG 3 : Speed = pitch change of the grains // ANALOG 4 : Feedback // /////////////////////////////////////////////////////////////////////////////////////////////////// import("all.lib"); // FOR 4 grains - MONO // UI ////////////////////////////////////////// popul = 1 - hslider("population[BELA: ANALOG_0]", 1, 0, 1, 0.001); // Coef 1= maximum; 0 = almost nothing (0.95) taille = hslider("taille[BELA: ANALOG_1]", 100, 4, 200, 0.001 ); // Size in millisecondes decal = 1 - hslider("decal[BELA: ANALOG_2]",0,0,1,0.001); // read position compared to table srite position speed = hslider("speed[BELA: ANALOG_3]", 1, 0.125, 4, 0.001); feedback = hslider("feedback[BELA: ANALOG_4]",0,0,2,0.001); freq = 1000/taille; tmpTaille = taille*ma.SR/ 1000; clocSize = int(tmpTaille + (tmpTaille*popul*10)); // duration between 2 clicks // CLK GENERAL ///////////////////////////////// // 4 clicks vers 4 generateurs de grains. // (idem clk freq/4 et un compteur...) detect1(x) = select2 (x < 10, 0, 1); detect2(x) = select2 (x > clocSize*1/3, 0, 1) : select2 (x < (clocSize*1/3)+10, 0, _); detect3(x) = select2 (x > clocSize*2/3, 0, 1) : select2 (x < (clocSize*2/3)+10, 0, _); detect4(x) = select2 (x > clocSize-10, 0, 1); cloc = (%(_,clocSize))~(+(1)) <: (detect1: trig),(detect2: trig),(detect3: trig),(detect4: trig); // SIGNAUX Ctrls Player //////////////////////// trig = _<:_,mem: >; envelop = *(2*PI):+(PI):cos:*(0.5):+(0.5); rampe(f, t) = delta : (+ : select2(t,_,delta<0) : max(0)) ~ _ : raz with { raz(x) = select2 (x > 1, x, 0); delta = sh(f,t)/ma.SR; sh(x,t) = ba.sAndH(t,x); }; rampe2(speed, t) = delta : (+ : select2(t,_,delta<0) : max(0)) ~ _ with { delta = sh(speed,t); sh(x,t) = ba.sAndH(t,x); }; // RWTable ////////////////////////////////////// unGrain(input, clk) = (linrwtable( wf , rindex) : *(0.2 * EnvGrain)) with { SR = 44100; buffer_sec = 1; size = int(SR * buffer_sec); init = 0.; EnvGrain = clk : (rampe(freq) : envelop); windex = (%(_,size) ) ~ ( +(1) ); posTabl = int(ba.sAndH(clk, windex)); rindex = %(int(rampe2(speed, clk)) + posTabl + int(size * decal), size); wf = size, init, int(windex), input; }; // LINEAR_INTERPOLATION_RWTABLE ////////////////////////////////// // read rwtable with linear interpolation // wf : waveform to read ( wf is defined by (size_buffer,init, windex, input )) // x : position to read (0 <= x < size(wf)) and float // nota: rwtable(size, init, windex, input, rindex) linrwtable(wf,x) = linterpolation(y0,y1,d) with { x0 = int(x); // x1 = int(x+1); // d = x-x0; y0 = rwtable(wf,x0); // y1 = rwtable(wf,x1); // linterpolation(v0,v1,c) = v0*(1-c)+v1*c; }; // FINALISATION ///////////////////////////////////////////////////////////////////////////////////// routeur (a, b, c, d, e) = a, b, a, c, a, d, a, e; processus = _ , cloc : routeur : (unGrain, unGrain, unGrain, unGrain) :> fi.dcblockerat(20); process = _,_: ((+(_,_) :processus) ~(*(feedback))),((+(_,_) :processus) ~(*(feedback))); Try it Yourself >>

granulator

// FROM FAUST DEMO // Designed to use the Analog Input for parameters contrôles. // /////////////////////////////////////////////////////////////////////////////////////////////////// // // ANALOG IN: // ANALOG 0 : Grain Size // ANALOG 1 : Speed // ANALOG 2 : Probability // (others analog inputs are not used) // /////////////////////////////////////////////////////////////////////////////////////////////////// process = vgroup("Granulator", environment { declare name "Granulator"; declare author "Adapted from sfIter by Christophe Lebreton"; /* =========== DESCRIPTION ============= - The granulator takes very small parts of a sound, called GRAINS, and plays them at a varying speed - Front = Medium size grains - Back = short grains - Left Slow rhythm - Right = Fast rhythm - Bottom = Regular occurrences - Head = Irregular occurrences */ import("stdfaust.lib"); process = hgroup("Granulator", *(excitation : ampf)); excitation = noiseburst(gate,P) * (gain); ampf = an.amp_follower_ud(duree_env,duree_env); //----------------------- NOISEBURST ------------------------- noiseburst(gate,P) = no.noise : *(gate : trigger(P)) with { upfront(x) = (x-x') > 0; decay(n,x) = x - (x>0)/n; release(n) = + ~ decay(n); trigger(n) = upfront : release(n) : > (0.0); }; //------------------------------------------------------------- P = freq; // fundamental period in samples freq = hslider("[1]GrainSize[BELA: ANALOG_0]", 200,5,2205,1); // la frequence donne la largeur de bande extraite du bruit blanc Pmax = 4096; // maximum P (for de.delay-line allocation) // PHASOR_BIN ////////////////////////////// phasor_bin (init) = (+(float(speed)/float(ma.SR)) : fmod(_,1.0)) ~ *(init); gate = phasor_bin(1) :-(0.001):pulsar; gain = 1; // PULSAR ////////////////////////////// //Le pulsar permet de creer une 'pulsation' plus ou moins aleatoire (proba). pulsar = _<:((_<(ratio_env)):@(100))*(proba>(_,abs(no.noise):ba.latch)); speed = hslider ("[2]Speed[BELA: ANALOG_1]", 10,1,20,0.0001):fi.lowpass(1,1); ratio_env = 0.5; fade = (0.5); // min > 0 pour eviter division par 0 proba = hslider ("[3]Probability[BELA: ANALOG_2]", 70,50,100,1) * (0.01):fi.lowpass(1,1); duree_env = 1/(speed: / (ratio_env*(0.25)*fade)); }.process); Try it Yourself >>

repeater

// REPEATER: // Freeze and repeat a small part of input signal 'n' time' // /////////////////////////////////////////////////////////////////////////////////////////////////// // // ANALOG IN: // ANALOG 0 : Duration (ms) between 2 repeat series (500 to 2000 ms) // ANALOG 1 : Duration of one repeat (2 to 200 ms) // ANALOG 2 : Number of repeat // /////////////////////////////////////////////////////////////////////////////////////////////////// import("all.lib"); process = _, _ , (pathClock : compteurUpReset2(nbRepet): rampePlayer, _) : routageIO : rec_play_table , rec_play_table; /////////////////////////////////////////////////////////////////////////////////////////////////// // General loop duration MasterTaille =hslider("MasterTaille[BELA: ANALOG_0]", 500, 200, 2000,0.01); MasterClocSize = int(MasterTaille*ma.SR/ 1000); // Depth of repeat fragments taille =hslider("taille[BELA: ANALOG_1]", 50, 2, 200,0.01); clocSize = int(taille*ma.SR/ 1000); // Number of repeat fragments nbRepet = int (hslider("nbRepet[BELA: ANALOG_2]",4,1,16,1) ); trig = _<:_,mem: >; routageIO (a, b, c, d) = a, c, d, b, c, d; rec_play_table(input, inReadIndex, reset) = ( rwtable( wf , rindex):fi.dcblockerat(20) ) with { SR = 44100; buffer_sec = 2; size = int(SR * buffer_sec); init = 0.; windex = (%(_,size))~(+(1):*(1-reset)); rindex = (%( int(inReadIndex),size)); wf = size, init, int(windex), input; }; MasterClock = (%(_,MasterClocSize))~(+(1)) : detect with { detect(x) = select2 (x < 100, 0, 1); }; SlaveClock(reset) = (%(_,clocSize))~(+(1):*(1-reset)); detect1(x) = select2 (x < clocSize/2, 0, 1); pathClock = MasterClock <: trig, _ : SlaveClock, _ : detect1, _ ; compteurUpReset2(nb, in, reset) = ((in:trig), reset : (routage : memo2)~_), reset with { memo2(a, b) = (ba.if(b>0.5, 0, _) )~(+(a)); compare(value) = ba.if(value>nb, 1, 0); // :trig; routage(d,e,f) = e , (f, compare(d) : RSLatch <: +(f)); }; RSLatch(R, S) = latch(S,R) with { trig = _<:_,mem: >; latch(S,R) = _~( ba.if(R>0.5, 0, _) : ba.if(S>0.5,1,_) ); }; rampePlayer(reset) = rampe with { rst = reset : trig; rampe = _~(+(1):*(1-rst)); toZero = _ : ba.if(reset<0.5,0,_); }; Try it Yourself >>

simpleFX_Analog

import("stdfaust.lib"); // /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple FX chaine build for a mono synthesizer. // It controle general volume and pan. // FX Chaine is: // Drive // Flanger // Reverberation // // This version use ANALOG IN to controle some of the parameters. // Other parameters continue to be available by MIDI or OSC. // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_4 : Distortion Drive // ANALOG_5 : Flanger Dry/Wet // ANALOG_6 : Reverberation Dry/Wet // ANALOG_7 : Reverberation Room size // // MIDI: // CC 7 : Volume // CC 10 : Pan // // CC 13 : Flanger Delay // CC 13 : Flanger Delay // CC 94 : Flanger Feedback // // CC 95 : Reverberation Damp // CC 90: Reverberation Stereo Width // /////////////////////////////////////////////////////////////////////////////////////////////////// // VOLUME: vol = hslider("volume[midi:ctrl 7]",1,0,1,0.001);// Should be 7 according to MIDI CC norm. // EFFECTS ///////////////////////////////////////////// drive = hslider ("drive[BELA: ANALOG_4]",0.3,0,1,0.001); // Flanger curdel = hslider("flangDel[midi:ctrl 13]",4,0.001,10,0.001); fb = hslider("flangFeedback[midi:ctrl 94]",0.7,0,1,0.001); fldw = hslider("dryWetFlang[BELA: ANALOG_5]",0.5,0,1,0.001); flanger = efx with { fldel = (curdel + (os.lf_triangle(1) * 2) ) : min(10); efx = _ <: _, pf.flanger_mono(10,fldel,1,fb,0) : dry_wet(fldw); }; // Pannoramique: panno = _ : sp.panner(hslider ("pan[midi:ctrl 10]",0.5,0,1,0.001)) : _,_; // REVERB (from freeverb_demo) reverb = _,_ <: (*(g)*fixedgain,*(g)*fixedgain : re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)), *(1-g), *(1-g) :> _,_ with { scaleroom = 0.28; offsetroom = 0.7; allpassfeed = 0.5; scaledamp = 0.4; fixedgain = 0.1; origSR = 44100; damping = vslider("Damp[midi:ctrl 95]",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR; combfeed = vslider("RoomSize[BELA: ANALOG_7]", 0.7, 0, 1, 0.025)*scaleroom*origSR/ma.SR + offsetroom; spatSpread = vslider("Stereo[midi:ctrl 90]",0.6,0,1,0.01)*46*ma.SR/origSR; g = vslider("dryWetReverb[BELA: ANALOG_6]", 0.4, 0, 1, 0.001); // (g = Dry/Wet) }; // Dry-Wet (from C. LEBRETON) dry_wet(dw,x,y) = wet*y + dry*x with { wet = 0.5*(dw+1.0); dry = 1.0-wet; }; // ALL effets = _ *(vol) : ef.cubicnl_nodc(drive, 0.1) : flanger : panno : reverb; process = effets; Try it Yourself >>

simpleFX

import("stdfaust.lib"); // /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple FX chaine build for a mono synthesizer. // It controle general volume and pan. // FX Chaine is: // Drive // Flanger // Reverberation // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // (All are available by OSC) // // CC 7 : Volume // CC 10 : Pan // // CC 92 : Distortion Drive // // CC 13 : Flanger Delay // CC 93 : Flanger Dry/Wet // CC 94 : Flanger Feedback // // CC 12 : Reverberation Room size // CC 91 : Reverberation Dry/Wet // CC 95 : Reverberation Damp // CC 90 : Reverberation Stereo Width // /////////////////////////////////////////////////////////////////////////////////////////////////// // VOLUME: vol = hslider ("volume[midi:ctrl 7]",1,0,1,0.001);// Should be 7 according to MIDI CC norm. // EFFECTS ///////////////////////////////////////////// drive = hslider ("drive[midi:ctrl 92]",0.3,0,1,0.001); // Flanger curdel = hslider ("flangDel[midi:ctrl 13]",4,0.001,10,0.001); fb = hslider ("flangFeedback[midi:ctrl 94]",0.7,0,1,0.001); fldw = hslider ("dryWetFlang[midi:ctrl 93]",0.5,0,1,0.001); flanger = efx with { fldel = (curdel + (os.lf_triangle(1) * 2) ) : min(10); efx = _ <: _, pf.flanger_mono(10,fldel,1,fb,0) : dry_wet(fldw); }; // Panoramique: panno = _ : sp.panner(hslider ("pan[midi:ctrl 10]",0.5,0,1,0.001)) : _,_; // REVERB (from freeverb_demo) reverb = _,_ <: (*(g)*fixedgain,*(g)*fixedgain : re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)), *(1-g), *(1-g) :> _,_ with { scaleroom = 0.28; offsetroom = 0.7; allpassfeed = 0.5; scaledamp = 0.4; fixedgain = 0.1; origSR = 44100; damping = vslider("Damp[midi:ctrl 95]",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR; combfeed = vslider("RoomSize[midi:ctrl 12]", 0.7, 0, 1, 0.025)*scaleroom*origSR/ma.SR + offsetroom; spatSpread = vslider("Stereo[midi:ctrl 90]",0.6,0,1,0.01)*46*ma.SR/origSR; g = vslider("dryWetReverb[midi:ctrl 91]", 0.4, 0, 1, 0.001); // (g = Dry/Wet) }; // Dry-Wet (from C. LEBRETON) dry_wet(dw,x,y) = wet*y + dry*x with { wet = 0.5*(dw+1.0); dry = 1.0-wet; }; // ALL effets = _ *(vol) : ef.cubicnl_nodc(drive, 0.1) : flanger : panno : reverb; process = effets; Try it Yourself >>

simpleSynth_Analog

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // A very simple subtractive synthesizer with 1 VCO 1 VCF. // The VCO Waveform is variable between Saw and Square // The frequency is modulated by an LFO // The envelope control volum and filter frequency // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_0 : waveform (Saw to square) // ANALOG_1 : Filter Cutoff frequency // ANALOG_2 : Filter resonance (Q) // ANALOG_3 : Filter Envelope Modulation // // MIDI: // CC 79 : Filter keyboard tracking (0 to X2, default 1) // // Envelope // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // CC 72 : Release // // CC 78 : LFO frequency (0.001Hz to 10Hz) // CC 1 : LFO Amplitude (Modulation) // /////////////////////////////////////////////////////////////////////////////////////////////////// // // HUI ////////////////////////////////////////////////// // Keyboard midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 0.5, 0.01);// MIDI KEYBOARD // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); // VCO wfFade = hslider("waveform[BELA: ANALOG_0]",0.5,0,1,0.001):si.smoo; // VCF res = hslider("resonnance[BELA: ANALOG_2]",0.5,0,1,0.001):si.smoo; fr = hslider("fc[BELA: ANALOG_1]", 10, 15, 12000, 0.001):si.smoo; track = hslider("tracking[midi:ctrl 79]", 1, 0, 2, 0.001); envMod = hslider("envMod[BELA: ANALOG_3]",50,0,100,0.01):si.smoo; // ENV att = 0.01 * (hslider ("attack[midi:ctrl 73]",0.1,0.1,400,0.001)); dec = 0.01 * (hslider ("decay[midi:ctrl 76]",60,0.1,400,0.001)); sust = hslider ("sustain[midi:ctrl 77]",0.2,0,1,0.001); rel = 0.01 * (hslider ("release[midi:ctrl 72]",100,0.1,400,0.001)); // LFO lfoFreq = hslider ("lfoFreq[midi:ctrl 78]",6,0.001,10,0.001):si.smoo; modwheel = hslider ("modwheel[midi:ctrl 1]",0,0,0.5,0.001):si.smoo; // PROCESS ///////////////////////////////////////////// allfreq = (midifreq * pitchwheel) + LFO; // VCF cutoff = ((allfreq * track) + fr + (envMod * midigain * env)) : min(ma.SR/8); // VCO oscillo(f) = (os.sawtooth(f)*(1-wfFade))+(os.square(f)*wfFade); // VCA volume = midigain * env; // Enveloppe env = en.adsre(att,dec,sust,rel,midigate); // LFO LFO = os.lf_triangle(lfoFreq)*modwheel*10; // SYNTH //////////////////////////////////////////////// synth = (oscillo(allfreq) :ve.moog_vcf(res,cutoff)) * volume; // PROCESS ///////////////////////////////////////////// process = synth; Try it Yourself >>

simpleSynth

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // A very simple subtractive synthesizer with 1 VCO 1 VCF. // The VCO Waveform is variable between Saw and Square // The frequency is modulated by an LFO // The envelope control volum and filter frequency // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // // CC 70 : waveform (Saw to square) // CC 71 : Filter resonance (Q) // CC 74 : Filter Cutoff frequency // CC 79 : Filter keyboard tracking (0 to X2, default 1) // CC 75 : Filter Envelope Modulation // // Envelope // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // CC 72 : Release // // CC 78 : LFO frequency (0.001Hz to 10Hz) // CC 1 : LFO Amplitude (Modulation) // /////////////////////////////////////////////////////////////////////////////////////////////////// // // HUI ////////////////////////////////////////////////// // Keyboard midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 0.5, 0.01);// MIDI KEYBOARD // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); // VCO wfFade= hslider("waveform[midi:ctrl 70]",0.5,0,1,0.001):si.smoo; // VCF res = hslider("resonnance[midi:ctrl 71]",0.5,0,1,0.001):si.smoo; fr = hslider("fc[midi:ctrl 74]", 10, 15, 12000, 0.001):si.smoo; track = hslider("tracking[midi:ctrl 79]", 1, 0, 2, 0.001); envMod = hslider("envMod[midi:ctrl 75]",50,0,100,0.01):si.smoo; // ENV att = 0.01 * (hslider ("attack[midi:ctrl 73]",0.1,0.1,400,0.001)); dec = 0.01 * (hslider ("decay[midi:ctrl 76]",60,0.1,400,0.001)); sust = hslider ("sustain[midi:ctrl 77]",0.1,0,1,0.001); rel = 0.01 * (hslider ("release[midi:ctrl 72]",100,0.1,400,0.001)); // LFO lfoFreq = hslider("lfoFreq[midi:ctrl 78]",6,0.001,10,0.001):si.smoo; modwheel = hslider("modwheel[midi:ctrl 1]",0,0,0.5,0.001):si.smoo; // PROCESS ///////////////////////////////////////////// allfreq = (midifreq * pitchwheel) + LFO; // VCF cutoff = ((allfreq * track) + fr + (envMod * midigain * env)) : min(ma.SR/8); // VCO oscillo(f) = (os.sawtooth(f)*(1-wfFade))+(os.square(f)*wfFade); // VCA volume = midigain * env; // Enveloppe env = en.adsre(att,dec,sust,rel,midigate); // LFO LFO = os.lf_triangle(lfoFreq)*modwheel*10; // SYNTH //////////////////////////////////////////////// synth = (oscillo(allfreq) :ve.moog_vcf(res,cutoff)) * volume; // PROCESS ///////////////////////////////////////////// process = synth; Try it Yourself >>

simpleSynth_FX_Analog

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // A very simple subtractive synthesizer with 1 VCO 1 VCF. // The VCO Waveform is variable between Saw and Square // The frequency is modulated by an LFO // The envelope control volum and filter frequency // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_0 : waveform (Saw to square) // ANALOG_1 : Filter Cutoff frequency // ANALOG_2 : Filter resonance (Q) // ANALOG_3 : Filter Envelope Modulation // // MIDI: // CC 79 : Filter keyboard tracking (0 to X2, default 1) // // Envelope // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // CC 72 : Release // // CC 78 : LFO frequency (0.001Hz to 10Hz) // CC 1 : LFO Amplitude (Modulation) // /////////////////////////////////////////////////////////////////////////////////////////////////// // // HUI ////////////////////////////////////////////////// // Keyboard midigate = button("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 0.5, 0.01);// MIDI KEYBOARD // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); // VCO wfFade = hslider("waveform[BELA: ANALOG_0]",0.5,0,1,0.001):si.smoo; // VCF res = hslider("resonnance[BELA: ANALOG_2]",0.5,0,1,0.001):si.smoo; fr = hslider("fc[BELA: ANALOG_1]", 10, 15, 12000, 0.001):si.smoo; track = hslider("tracking[midi:ctrl 79]", 1, 0, 2, 0.001); envMod = hslider("envMod[BELA: ANALOG_3]",50,0,100,0.01):si.smoo; // ENV att = 0.01 * (hslider ("attack[midi:ctrl 73]",0.1,0.1,400,0.001)); dec = 0.01 * (hslider ("decay[midi:ctrl 76]",60,0.1,400,0.001)); sust = hslider ("sustain[midi:ctrl 77]",0.2,0,1,0.001); rel = 0.01 * (hslider ("release[midi:ctrl 72]",100,0.1,400,0.001)); // LFO lfoFreq = hslider("lfoFreq[midi:ctrl 78]",6,0.001,10,0.001):si.smoo; modwheel = hslider("modwheel[midi:ctrl 1]",0,0,0.5,0.001):si.smoo; // PROCESS ///////////////////////////////////////////// allfreq = (midifreq * pitchwheel) + LFO; // VCF cutoff = ((allfreq * track) + fr + (envMod * midigain * env)) : min(ma.SR/8); // VCO oscillo(f) = (os.sawtooth(f)*(1-wfFade))+(os.square(f)*wfFade); // VCA volume = midigain * env; // Enveloppe env = en.adsre(att,dec,sust,rel,midigate); // LFO LFO = os.lf_triangle(lfoFreq)*modwheel*10; // SYNTH //////////////////////////////////////////////// synth = (oscillo(allfreq) :ve.moog_vcf(res,cutoff)) * volume; //#################################################################################################// //##################################### EFFECT SECTION ############################################// //#################################################################################################// // // Simple FX chaine build for a mono synthesizer. // It controle general volume and pan. // FX Chaine is: // Drive // Flanger // Reverberation // // This version use ANALOG IN to controle some of the parameters. // Other parameters continue to be available by MIDI or OSC. // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_4 : Distortion Drive // ANALOG_5 : Flanger Dry/Wet // ANALOG_6 : Reverberation Dry/Wet // ANALOG_7 : Reverberation Room size // // MIDI: // CC 7 : Volume // CC 10 : Pan // // CC 13 : Flanger Delay // CC 13 : Flanger Delay // CC 94 : Flanger Feedback // // CC 95 : Reverberation Damp // CC 90 : Reverberation Stereo Width // /////////////////////////////////////////////////////////////////////////////////////////////////// // VOLUME: volFX = hslider ("volume[midi:ctrl 7]",1,0,1,0.001);// Should be 7 according to MIDI CC norm. // EFFECTS ///////////////////////////////////////////// drive = hslider ("drive[BELA: ANALOG_4]",0.3,0,1,0.001); // Flanger curdel = hslider ("flangDel[midi:ctrl 13]",4,0.001,10,0.001); fb = hslider ("flangFeedback[midi:ctrl 94]",0.7,0,1,0.001); fldw = hslider ("dryWetFlang[BELA: ANALOG_5]",0.5,0,1,0.001); flanger = efx with { fldel = (curdel + (os.lf_triangle(1) * 2) ) : min(10); efx = _ <: _, pf.flanger_mono(10,fldel,1,fb,0) : dry_wet(fldw); }; // Pannoramique: panno = _ : sp.panner(hslider ("pan[midi:ctrl 10]",0.5,0,1,0.001)) : _,_; // REVERB (from freeverb_demo) reverb = _,_ <: (*(g)*fixedgain,*(g)*fixedgain : re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)), *(1-g), *(1-g) :> _,_ with { scaleroom = 0.28; offsetroom = 0.7; allpassfeed = 0.5; scaledamp = 0.4; fixedgain = 0.1; origSR = 44100; damping = vslider("Damp[midi:ctrl 95]",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR; combfeed = vslider("RoomSize[BELA: ANALOG_7]", 0.7, 0, 1, 0.025)*scaleroom*origSR/ma.SR + offsetroom; spatSpread = vslider("Stereo[midi:ctrl 90]",0.6,0,1,0.01)*46*ma.SR/origSR; g = vslider("dryWetReverb[BELA: ANALOG_6]", 0.4, 0, 1, 0.001); // (g = Dry/Wet) }; // Dry-Wet (from C. LEBRETON) dry_wet(dw,x,y) = wet*y + dry*x with { wet = 0.5*(dw+1.0); dry = 1.0-wet; }; // ALL effect = _ *(volFX) : ef.cubicnl_nodc(drive, 0.1) : flanger : panno : reverb; // PROCESS ///////////////////////////////////////////// process = synth; Try it Yourself >>

simpleSynth_FX

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // A very simple subtractive synthesizer with 1 VCO 1 VCF. // The VCO Waveform is variable between Saw and Square // The frequency is modulated by an LFO // The envelope control volum and filter frequency // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // // CC 70 : waveform (Saw to square) // CC 71 : Filter resonance (Q) // CC 74 : Filter Cutoff frequency // CC 79 : Filter keyboard tracking (0 to X2, default 1) // CC 75 : Filter Envelope Modulation // // Envelope // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // CC 72 : Release // // CC 78 : LFO frequency (0.001Hz to 10Hz) // CC 1 : LFO Amplitude (Modulation) // /////////////////////////////////////////////////////////////////////////////////////////////////// // // HUI ////////////////////////////////////////////////// // Keyboard midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 0.5, 0.01);// MIDI KEYBOARD // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); // VCO wfFade = hslider("waveform[midi:ctrl 70]",0.5,0,1,0.001):si.smoo; // VCF res = hslider("resonnance[midi:ctrl 71]",0.5,0,1,0.001):si.smoo; fr = hslider("fc[midi:ctrl 74]", 10, 15, 12000, 0.001):si.smoo; track = hslider("tracking[midi:ctrl 79]", 1, 0, 2, 0.001); envMod = hslider("envMod[midi:ctrl 75]",50,0,100,0.01):si.smoo; // ENV att = 0.01 * (hslider ("attack[midi:ctrl 73]",0.1,0.1,400,0.001)); dec = 0.01 * (hslider ("decay[midi:ctrl 76]",60,0.1,400,0.001)); sust = hslider ("sustain[midi:ctrl 77]",0.1,0,1,0.001); rel = 0.01 * (hslider ("release[midi:ctrl 72]",100,0.1,400,0.001)); // LFO lfoFreq = hslider ("lfoFreq[midi:ctrl 78]",6,0.001,10,0.001):si.smoo; modwheel= hslider ("modwheel[midi:ctrl 1]",0,0,0.5,0.001):si.smoo; // PROCESS ///////////////////////////////////////////// allfreq = (midifreq * pitchwheel) + LFO; // VCF cutoff= ((allfreq * track) + fr + (envMod * midigain * env)) : min(ma.SR/8); // VCO oscillo(f) = (os.sawtooth(f)*(1-wfFade))+(os.square(f)*wfFade); // VCA volume = midigain * env; // Enveloppe env = en.adsre(att,dec,sust,rel,midigate); // LFO LFO = os.lf_triangle(lfoFreq)*modwheel*10; // SYNTH //////////////////////////////////////////////// synth = (oscillo(allfreq) :ve.moog_vcf(res,cutoff)) * volume; //#################################################################################################// //##################################### EFFECT SECTION ############################################// //#################################################################################################// // Simple FX chaine build for a mono synthesizer. // It controle general volume and pan. // FX Chaine is: // Drive // Flanger // Reverberation // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // (All are available by OSC) // // CC 7 : Volume // CC 10 : Pan // // CC 92 : Distortion Drive // // CC 13 : Flanger Delay // CC 93 : Flanger Dry/Wet // CC 94 : Flanger Feedback // // CC 12 : Reverberation Room size // CC 91 : Reverberation Dry/Wet // CC 95 : Reverberation Damp // CC 90 : Reverberation Stereo Width // /////////////////////////////////////////////////////////////////////////////////////////////////// // VOLUME: volFX = hslider ("volume[midi:ctrl 7]",1,0,1,0.001);// Should be 7 according to MIDI CC norm. // EFFECTS ///////////////////////////////////////////// drive = hslider ("drive[midi:ctrl 92]",0.3,0,1,0.001); // Flanger curdel = hslider ("flangDel[midi:ctrl 13]",4,0.001,10,0.001); fb = hslider ("flangFeedback[midi:ctrl 94]",0.7,0,1,0.001); fldw = hslider ("dryWetFlang[midi:ctrl 93]",0.5,0,1,0.001); flanger = efx with { fldel = (curdel + (os.lf_triangle(1) * 2) ) : min(10); efx = _ <: _, pf.flanger_mono(10,fldel,1,fb,0) : dry_wet(fldw); }; // Pannoramique: panno = _ : sp.panner(hslider ("pan[midi:ctrl 10]",0.5,0,1,0.001)) : _,_; // REVERB (from freeverb_demo) reverb = _,_ <: (*(g)*fixedgain,*(g)*fixedgain : re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)), *(1-g), *(1-g) :> _,_ with { scaleroom = 0.28; offsetroom = 0.7; allpassfeed = 0.5; scaledamp = 0.4; fixedgain = 0.1; origSR = 44100; damping = vslider("Damp[midi:ctrl 95]",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR; combfeed = vslider("RoomSize[midi:ctrl 12]", 0.7, 0, 1, 0.025)*scaleroom*origSR/ma.SR + offsetroom; spatSpread = vslider("Stereo[midi:ctrl 90]",0.6,0,1,0.01)*46*ma.SR/origSR; g = vslider("dryWetReverb[midi:ctrl 91]", 0.4, 0, 1, 0.001); // (g = Dry/Wet) }; // Dry-Wet (from C. LEBRETON) dry_wet(dw,x,y) = wet*y + dry*x with { wet = 0.5*(dw+1.0); dry = 1.0-wet; }; // ALL effect = _ *(volFX) : ef.cubicnl_nodc(drive, 0.1) : flanger : panno : reverb; // PROCESS ///////////////////////////////////////////// process = synth; Try it Yourself >>

WaveSynth_Analog

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple demo of wavetable synthesis. A LFO modulate the interpolation between 4 tables. // It's possible to add more tables step. // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_0 : Wave travelling // ANALOG_1 : LFO Frequency // ANALOG_2 : LFO Depth (wave travel modulation) // ANALOG_3 : Release // // MIDI: // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 1, 0.01); waveTravel = hslider("waveTravel[BELA: ANALOG_0]",0,0,1,0.01); // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; // LFO lfoDepth = hslider("lfoDepth[BELA: ANALOG_2]",0,0.,1,0.001):si.smoo; lfoFreq = hslider("lfoFreq[BELA: ANALOG_1]",0.1,0.01,10,0.001):si.smoo; moov = ((os.lf_trianglepos(lfoFreq) * lfoDepth) + waveTravel) : min(1) : max(0); volA = hslider("A[midi:ctrl 73]",0.01,0.01,4,0.01); volD = hslider("D[midi:ctrl 76]",0.6,0.01,8,0.01); volS = hslider("S[midi:ctrl 77]",0.2,0,1,0.01); volR = hslider("R[BELA: ANALOG_3]",0.8,0.01,8,0.01); envelop = en.adsre(volA,volD,volS,volR,midigate); // Out Amplitude vol = envelop * midigain; WF(tablesize, rang) = abs((fmod ((1+(float(ba.time)*rang)/float(tablesize)), 4.0 ))-2) -1.; // 4 WF maxi with this version: scanner(nb, position) = -(_,soustraction) : *(_,coef) : cos : max(0) with { coef = 3.14159 * ((nb-1)*0.5); soustraction = select2( position>0, 0, (position/(nb-1)) ); }; wfosc(freq) = (rdtable(tablesize, wt1, faze)*(moov : scanner(4,0)))+(rdtable(tablesize, wt2, faze)*(moov : scanner(4,1))) + (rdtable(tablesize, wt3, faze)*(moov : scanner(4,2)))+(rdtable(tablesize, wt4, faze)*(moov : scanner(4,3))) with { tablesize = 1024; wt1 = WF(tablesize, 16); wt2 = WF(tablesize, 8); wt3 = WF(tablesize, 6); wt4 = WF(tablesize, 4); faze = int(os.phasor(tablesize,freq)); }; process = wfosc(gFreq) * vol; Try it Yourself >>

WaveSynth

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple demo of wavetable synthesis. A LFO modulate the interpolation between 4 tables. // It's possible to add more tables step. // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // // CC 1 : LFO Depth (wave travel modulation) // CC 14 : LFO Frequency // CC 70 : Wave travelling // // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // CC 72 : Release // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 1, 0.01); waveTravel = hslider("waveTravel [midi:ctrl ]",0,0,1,0.01); // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; // LFO lfoDepth = hslider ("lfoDepth[midi:ctrl 1]",0,0.,1,0.001):si.smoo; lfoFreq = hslider ("lfoFreq[midi:ctrl 14]",0.1,0.01,10,0.001):si.smoo; moov = ((os.lf_trianglepos(lfoFreq) * lfoDepth) + waveTravel) : min(1) : max(0); volA = hslider("A[midi:ctrl 73]",0.01,0.01,4,0.01); volD = hslider("D[midi:ctrl 76]",0.6,0.01,8,0.01); volS = hslider("S[midi:ctrl 77]",0.2,0,1,0.01); volR = hslider("R[midi:ctrl 72]",0.8,0.01,8,0.01); envelop = en.adsre(volA,volD,volS,volR,midigate); // Out Amplitude vol = envelop * midigain ; WF(tablesize, rang) = abs((fmod ((1+(float(ba.time)*rang)/float(tablesize)), 4.0 ))-2) -1.; // 4 WF maxi with this version: scanner(nb, position) = -(_,soustraction) : *(_,coef) : cos : max(0) with{ coef = 3.14159 * ((nb-1)*0.5); soustraction = select2( position>0, 0, (position/(nb-1)) ); }; wfosc(freq) = (rdtable(tablesize, wt1, faze)*(moov : scanner(4,0)))+(rdtable(tablesize, wt2, faze)*(moov : scanner(4,1))) + (rdtable(tablesize, wt3, faze)*(moov : scanner(4,2)))+(rdtable(tablesize, wt4, faze)*(moov : scanner(4,3))) with { tablesize = 1024; wt1 = WF(tablesize, 16); wt2 = WF(tablesize, 8); wt3 = WF(tablesize, 6); wt4 = WF(tablesize, 4); faze = int(os.phasor(tablesize,freq)); }; process = wfosc(gFreq) * vol; Try it Yourself >>

WaveSynth_FX_Analog

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple demo of wavetable synthesis. A LFO modulate the interpolation between 4 tables. // It's possible to add more tables step. // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_0 : Wave travelling // ANALOG_1 : LFO Frequency // ANALOG_2 : LFO Depth (wave travel modulation) // ANALOG_3 : Release // // MIDI: // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 1, 0.01); waveTravel = hslider("waveTravel[BELA: ANALOG_0]",0,0,1,0.01); // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; // LFO lfoDepth = hslider("lfoDepth[BELA: ANALOG_2]",0,0.,1,0.001):si.smoo; lfoFreq = hslider("lfoFreq[BELA: ANALOG_1]",0.1,0.01,10,0.001):si.smoo; moov = ((os.lf_trianglepos(lfoFreq) * lfoDepth) + waveTravel) : min(1) : max(0); volA = hslider("A[midi:ctrl 73]",0.01,0.01,4,0.01); volD = hslider("D[midi:ctrl 76]",0.6,0.01,8,0.01); volS = hslider("S[midi:ctrl 77]",0.2,0,1,0.01); volR = hslider("R[BELA: ANALOG_3]",0.8,0.01,8,0.01); envelop = en.adsre(volA,volD,volS,volR,midigate); // Out Amplitude vol = envelop * midigain ; WF(tablesize, rang) = abs((fmod ((1+(float(ba.time)*rang)/float(tablesize)), 4.0 ))-2) -1.; // 4 WF maxi with this version: scanner(nb, position) = -(_,soustraction) : *(_,coef) : cos : max(0) with { coef = 3.14159 * ((nb-1)*0.5); soustraction = select2( position>0, 0, (position/(nb-1)) ); }; wfosc(freq) = (rdtable(tablesize, wt1, faze)*(moov : scanner(4,0)))+(rdtable(tablesize, wt2, faze)*(moov : scanner(4,1))) + (rdtable(tablesize, wt3, faze)*(moov : scanner(4,2)))+(rdtable(tablesize, wt4, faze)*(moov : scanner(4,3))) with { tablesize = 1024; wt1 = WF(tablesize, 16); wt2 = WF(tablesize, 8); wt3 = WF(tablesize, 6); wt4 = WF(tablesize, 4); faze = int(os.phasor(tablesize,freq)); }; //#################################################################################################// //##################################### EFFECT SECTION ############################################// //#################################################################################################// // // Simple FX chaine build for a mono synthesizer. // It controle general volume and pan. // FX Chaine is: // Drive // Flanger // Reverberation // // This version use ANALOG IN to controle some of the parameters. // Other parameters continue to be available by MIDI or OSC. // /////////////////////////////////////////////////////////////////////////////////////////////////// // ANALOG IMPLEMENTATION: // // ANALOG_4 : Distortion Drive // ANALOG_5 : Flanger Dry/Wet // ANALOG_6 : Reverberation Dry/Wet // ANALOG_7 : Reverberation Room size // // MIDI: // CC 7 : Volume // CC 10 : Pan // // CC 13 : Flanger Delay // CC 13 : Flanger Delay // CC 94 : Flanger Feedback // // CC 95 : Reverberation Damp // CC 90 : Reverberation Stereo Width // /////////////////////////////////////////////////////////////////////////////////////////////////// // VOLUME: volFX = hslider("volume[midi:ctrl 7]",1,0,1,0.001);// Should be 7 according to MIDI CC norm. // EFFECTS ///////////////////////////////////////////// drive = hslider ("drive[BELA: ANALOG_4]",0.3,0,1,0.001); // Flanger curdel = hslider("flangDel[midi:ctrl 13]",4,0.001,10,0.001); fb = hslider("flangFeedback[midi:ctrl 94]",0.7,0,1,0.001); fldw = hslider("dryWetFlang[BELA: ANALOG_5]",0.5,0,1,0.001); flanger = efx with { fldel = (curdel + (os.lf_triangle(1) * 2) ) : min(10); efx = _ <: _, pf.flanger_mono(10,fldel,1,fb,0) : dry_wet(fldw); }; // Pannoramique: panno = _ : sp.panner(hslider ("pan[midi:ctrl 10]",0.5,0,1,0.001)) : _,_; // REVERB (from freeverb_demo) reverb = _,_ <: (*(g)*fixedgain,*(g)*fixedgain : re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)), *(1-g), *(1-g) :> _,_ with { scaleroom = 0.28; offsetroom = 0.7; allpassfeed = 0.5; scaledamp = 0.4; fixedgain = 0.1; origSR = 44100; damping = vslider("Damp[midi:ctrl 95]",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR; combfeed = vslider("RoomSize[BELA: ANALOG_7]", 0.7, 0, 1, 0.025)*scaleroom*origSR/ma.SR + offsetroom; spatSpread = vslider("Stereo[midi:ctrl 90]",0.6,0,1,0.01)*46*ma.SR/origSR; g = vslider("dryWetReverb[BELA: ANALOG_6]", 0.4, 0, 1, 0.001); // (g = Dry/Wet) }; // Dry-Wet (from C. LEBRETON) dry_wet(dw,x,y) = wet*y + dry*x with { wet = 0.5*(dw+1.0); dry = 1.0-wet; }; // ALL effect = _ *(volFX) : ef.cubicnl_nodc(drive, 0.1) : flanger : panno : reverb; process = wfosc(gFreq) * vol; Try it Yourself >>

WaveSynth_FX

import("stdfaust.lib"); /////////////////////////////////////////////////////////////////////////////////////////////////// // // Simple demo of wavetable synthesis. A LFO modulate the interpolation between 4 tables. // It's possible to add more tables step. // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // // CC 1 : LFO Depth (wave travel modulation) // CC 14 : LFO Frequency // CC 70 : Wave travelling // // CC 73 : Attack // CC 76 : Decay // CC 77 : Sustain // CC 72 : Release // /////////////////////////////////////////////////////////////////////////////////////////////////// // GENERAL midigate = button ("gate"); midifreq = nentry("freq[unit:Hz]", 440, 20, 20000, 1); midigain = nentry("gain", 0.5, 0, 1, 0.01); waveTravel = hslider("waveTravel [midi:ctrl ]",0,0,1,0.01); // pitchwheel pitchwheel = hslider("bend [midi:pitchwheel]",1,0.001,10,0.01); gFreq = midifreq * pitchwheel; // LFO lfoDepth = hslider("lfoDepth[midi:ctrl 1]",0,0.,1,0.001):si.smoo; lfoFreq = hslider("lfoFreq[midi:ctrl 14]",0.1,0.01,10,0.001):si.smoo; moov = ((os.lf_trianglepos(lfoFreq) * lfoDepth) + waveTravel) : min(1) : max(0); volA = hslider("A[midi:ctrl 73]",0.01,0.01,4,0.01); volD = hslider("D[midi:ctrl 76]",0.6,0.01,8,0.01); volS = hslider("S[midi:ctrl 77]",0.2,0,1,0.01); volR = hslider("R[midi:ctrl 72]",0.8,0.01,8,0.01); envelop = en.adsre(volA,volD,volS,volR,midigate); // Out Amplitude vol = envelop * midigain ; WF(tablesize, rang) = abs((fmod ((1+(float(ba.time)*rang)/float(tablesize)), 4.0 ))-2) -1.; // 4 WF maxi with this version: scanner(nb, position) = -(_,soustraction) : *(_,coef) : cos : max(0) with { coef = 3.14159 * ((nb-1)*0.5); soustraction = select2( position>0, 0, (position/(nb-1)) ); }; wfosc(freq) = (rdtable(tablesize, wt1, faze)*(moov : scanner(4,0)))+(rdtable(tablesize, wt2, faze)*(moov : scanner(4,1))) + (rdtable(tablesize, wt3, faze)*(moov : scanner(4,2)))+(rdtable(tablesize, wt4, faze)*(moov : scanner(4,3))) with { tablesize = 1024; wt1 = WF(tablesize, 16); wt2 = WF(tablesize, 8); wt3 = WF(tablesize, 6); wt4 = WF(tablesize, 4); faze = int(os.phasor(tablesize,freq)); }; //#################################################################################################// //##################################### EFFECT SECTION ############################################// //#################################################################################################// // Simple FX chaine build for a mono synthesizer. // It controle general volume and pan. // FX Chaine is: // Drive // Flanger // Reverberation // /////////////////////////////////////////////////////////////////////////////////////////////////// // MIDI IMPLEMENTATION: // (All are available by OSC) // // CC 7 : Volume // CC 10 : Pan // // CC 92 : Distortion Drive // // CC 13 : Flanger Delay // CC 93 : Flanger Dry/Wet // CC 94 : Flanger Feedback // // CC 12 : Reverberation Room size // CC 91 : Reverberation Dry/Wet // CC 95 : Reverberation Damp // CC 90 : Reverberation Stereo Width // /////////////////////////////////////////////////////////////////////////////////////////////////// // VOLUME: volFX = hslider("volume[midi:ctrl 7]",1,0,1,0.001);// Should be 7 according to MIDI CC norm. // EFFECTS ///////////////////////////////////////////// drive = hslider ("drive[midi:ctrl 92]",0.3,0,1,0.001); // Flanger curdel = hslider("flangDel[midi:ctrl 13]",4,0.001,10,0.001); fb = hslider("flangFeedback[midi:ctrl 94]",0.7,0,1,0.001); fldw = hslider("dryWetFlang[midi:ctrl 93]",0.5,0,1,0.001); flanger = efx with { fldel = (curdel + (os.lf_triangle(1) * 2) ) : min(10); efx = _ <: _, pf.flanger_mono(10,fldel,1,fb,0) : dry_wet(fldw); }; // Pannoramique: panno = _ : sp.panner(hslider ("pan[midi:ctrl 10]",0.5,0,1,0.001)) : _,_; // REVERB (from freeverb_demo) reverb = _,_ <: (*(g)*fixedgain,*(g)*fixedgain : re.stereo_freeverb(combfeed, allpassfeed, damping, spatSpread)), *(1-g), *(1-g) :> _,_ with { scaleroom = 0.28; offsetroom = 0.7; allpassfeed = 0.5; scaledamp = 0.4; fixedgain = 0.1; origSR = 44100; damping = vslider("Damp[midi:ctrl 95]",0.5, 0, 1, 0.025)*scaledamp*origSR/ma.SR; combfeed = vslider("RoomSize[midi:ctrl 12]", 0.7, 0, 1, 0.025)*scaleroom*origSR/ma.SR + offsetroom; spatSpread = vslider("Stereo[midi:ctrl 90]",0.6,0,1,0.01)*46*ma.SR/origSR; g = vslider("dryWetReverb[midi:ctrl 91]", 0.4, 0, 1, 0.001); // (g = Dry/Wet) }; // Dry-Wet (from C. LEBRETON) dry_wet(dw,x,y) = wet*y + dry*x with { wet = 0.5*(dw+1.0); dry = 1.0-wet; }; // ALL effect = _ *(volFX) : ef.cubicnl_nodc(drive, 0.1) : flanger : panno : reverb; process = wfosc(gFreq) * vol; Try it Yourself >>

delayEcho

echo

// WARNING: This a "legacy example based on a deprecated library". Check misceffects.lib // for more accurate examples of echo functions declare name "echo"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //----------------------------------------------- // A Simple Echo //----------------------------------------------- import("stdfaust.lib"); process = vgroup("echo-simple", ef.echo1s); Try it Yourself >>

quadEcho

// WARNING: This a "legacy example based on a deprecated library". Check misceffects.lib // for more accurate examples of echo functions declare name "quadEcho"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2007"; //----------------------------------------------- // A 1 second quadriphonic Echo //----------------------------------------------- import("stdfaust.lib"); process = vgroup("stereo echo", multi(ef.echo1s, 4)) with{ multi(f,1) = f; multi(f,n) = f,multi(f,n-1); }; Try it Yourself >>

smoothDelay

declare name "smoothDelay"; declare author "Yann Orlarey"; declare copyright "Grame"; declare version "1.0"; declare license "STK-4.3"; //--------------------------process---------------------------- // // A stereo smooth delay with a feedback control // // This example shows how to use sdelay, a delay that doesn't // click and doesn't transpose when the delay time is changed //------------------------------------------------------------- import("stdfaust.lib"); process = par(i, 2, voice) with { voice = (+ : de.sdelay(N, interp, dtime)) ~ *(fback); N = int(2^19); interp = hslider("interpolation[unit:ms][style:knob]",10,1,100,0.1)*ma.SR/1000.0; dtime = hslider("delay[unit:ms][style:knob]", 0, 0, 5000, 0.1)*ma.SR/1000.0; fback = hslider("feedback[style:knob]",0,0,100,0.1)/100.0; }; Try it Yourself >>

stereoEcho

// WARNING: This a "legacy example based on a deprecated library". Check misceffects.lib // for more accurate examples of echo functions declare name "stereoEcho"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2007"; //----------------------------------------------- // A 1 second Stereo Echo //----------------------------------------------- import("stdfaust.lib"); process = vgroup("stereo echo", (ef.echo1s, ef.echo1s)); Try it Yourself >>

tapiir

declare name "tapiir"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //====================================================== // // TAPIIR // (from Maarten de Boer's Tapiir) // //====================================================== import("stdfaust.lib"); dsize = 524288; // user interface //--------------- tap(n) = vslider("tap %n", 0,0,1,0.1); in(n) = vslider("input %n", 1,0,1,0.1); gain = vslider("gain", 1,0,1,0.1); del = vslider("delay (sec)", 0, 0, 5, 0.01) * ma.SR; // mixer and matrix //----------------------------------------------------------- mixer(taps,lines) = par(i,taps,*(tap(i))), par(i,lines,*(in(i))) :> *(gain); matrix(taps,lines) = ( si.bus(lines+taps) <: tgroup("", par(i, taps, hgroup("Tap %i", mixer(taps,lines) : de.delay(dsize,del)))) ) ~ si.bus(taps); // tapiir //-------- tapiir(taps,lines) = vgroup("Tapiir", si.bus(lines) <: (matrix(taps,lines), si.bus(lines)) <: vgroup( "outputs", par( i, lines, hgroup("output %i", mixer(taps,lines)) ) ) ); process = tapiir(6,2); Try it Yourself >>

dynamic

compressor

declare name "compressor"; declare version "0.0"; declare author "JOS, revised by RM"; declare description "Compressor demo application"; import("stdfaust.lib"); process = dm.compressor_demo; Try it Yourself >>

distortion

declare name "distortion"; declare version "0.0"; declare author "JOS, revised by RM"; declare description "Distortion demo application."; import("stdfaust.lib"); process = dm.cubicnl_demo; Try it Yourself >>

gateCompressor

declare name "gateCompressor"; import("stdfaust.lib"); process = // ol.sawtooth_demo <: // el.gate_demo : ef.compressor_demo :> fi.spectral_level_demo <: _,_; vgroup("[1]", dm.sawtooth_demo) <: vgroup("[2]", dm.gate_demo) : vgroup("[3]", dm.compressor_demo) :> vgroup("[4]", dm.spectral_level_demo) <: _,_; Try it Yourself >>

noiseGate

declare name "noiseGate"; declare version "0.0"; declare author "JOS, revised by RM"; declare description "Gate demo application."; import("stdfaust.lib"); process = dm.gate_demo; Try it Yourself >>

volume

declare name "volume"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //----------------------------------------------- // Volume control in dB //----------------------------------------------- import("stdfaust.lib"); gain = vslider("[1]", 0, -70, +4, 0.1) : ba.db2linear : si.smoo; process = *(gain); Try it Yourself >>

filtering

APF

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "APF"; import("maxmsp.lib"); G = hslider("Gain [unit:dB]", 0, -10, 10, 0.1); F = hslider("Freq", 1000, 100, 10000, 1); Q = hslider("Q", 1, 0.01, 100, 0.01); process(x) = APF(x,F,G,Q); Try it Yourself >>

bandFilter

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "bandFilter"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; import("stdfaust.lib"); //---------------------second order filter-------------------------- // filter(Q,F,G) // Q : quality factor [1..100] // F : frequency (Hz) // G : gain [0..1] //------------------------------------------------------------------ filter(Q,F,G) = fi.TF2( (1 + K/Q + K*K) / D, 2 * (K*K - 1) / D, (1 - K/Q + K*K) / D, 2 * (K*K - 1) / D, (1 - V*K/Q + K*K) / D ) with { V = ba.db2linear(G); K = tan(ma.PI*F/ma.SR); D = 1 + V*K/Q + K*K; }; //--------------- Band Filter with user interface ------------------ // bandfilter(F) // F : default frequency (Hz) // //------------------------------------------------------------------ bandfilter(F) = filter( nentry("Q factor [style:knob]",50,0.1,100,0.1), nentry("freq [unit:Hz][style:knob]", F, 20, 20000, 1), 0 - vslider("gain [unit:dB]", 0, -50, 50, 0.1) ); //------------------------- Process -------------------------------- process = vgroup("Bandfilter", bandfilter(1000)); Try it Yourself >>

BPF

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "BPF"; import("maxmsp.lib"); G = hslider("Gain [unit:dB]", 0, -10, 10, 0.1); F = hslider("Freq", 1000, 100, 10000, 1); Q = hslider("Q", 1, 0.01, 100, 0.01); process(x) = BPF(x,F,G,Q); Try it Yourself >>

cryBaby

declare name "cryBaby"; declare description "Application demonstrating the CryBaby wah pedal emulation"; import("stdfaust.lib"); process = dm.crybaby_demo; Try it Yourself >>

DNN

// Forward Deep Neural Net (DNN), any number of layers of any size each declare name "DNN"; declare author "JOS"; declare license "STK-4.3"; import("stdfaust.lib"); layerSizes = (8,5,8); // autoencoder with 8 in & out, 5-state hidden layer w(m,n,k) = m*100+n*10+k; // placeholder weights: m=layer, n=fromNode, k=destNode M = ba.count(layerSizes); N(l) = ba.take(l+1,layerSizes); // Nodes per layer process = seq(m, M-1, layer(m)) // look at weights: // process = par(m,M,par(n,N(m),par(k,N(m),w(m,n,k)))) with { layer(m) = weights(m) :> nonlinearities(m); nonlinearities(m) = bus(N(m)*N(m+1)) :> par(n,N(m+1),nl(n)); weights(m) = bus(N(m)) <: par(n,N(m),(bus(N(m+1))<:wts(m,n))); wts(m,n) = bus(N(m+1)) : par(k,N(m+1),*(w(m,n,k))); nl(n,x) = x * (x>0); // ReLU bus(N) = par(k,N,_); }; Try it Yourself >>

filterBank

declare name "filterBank"; declare description "Graphic Equalizer consisting of a filter-bank driving a bank of faders"; import("stdfaust.lib"); process = dm.filterbank_demo; Try it Yourself >>

graphicEqLab

declare name "graphicEqLab"; declare description "Signal generators through a filter bank with spectrum analysis display"; import("stdfaust.lib"); process = // ol.sawtooth_demo : fl.filterbank_demo : fl.spectral_level_demo <: _,_; vgroup("[1]",dm.sawtooth_demo) : vgroup("[2]",dm.filterbank_demo) : vgroup("[3]",dm.spectral_level_demo) <: _,_; Try it Yourself >>

highShelf

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "highShelf"; import("maxmsp.lib"); G = hslider("Gain [unit:dB]", 0, -10, 10, 0.1); F = hslider("Freq", 1000, 100, 10000, 1); Q = hslider("Q", 1, 0.01, 100, 0.01); process(x) = highShelf(x,F,G,Q); Try it Yourself >>

HPF

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "HPF"; import("maxmsp.lib"); G = hslider("Gain [unit:dB]", 0, -10, 10, 0.1); F = hslider("Freq", 1000, 100, 10000, 1); Q = hslider("Q", 1, 0.01, 100, 0.01); process(x) = HPF(x,F,G,Q); Try it Yourself >>

lfBoost

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "lfboost"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //------------------------------------------------------------------ // DAFX, Digital Audio Effects (Wiley ed.) // chapter 2 : filters // section 2.3 : Equalizers // page 53 : second order shelving filter design //------------------------------------------------------------------ import("stdfaust.lib"); //----------------------low frequency boost filter ------------------------------- // lfboost(F,G) // F : frequency (in Hz) // G : gain (in dB) // //-------------------------------------------------------------------------------- lfboost(F,G) = fi.TF2((1 + sqrt(2*V)*K + V*K*K) / denom, 2 * (V*K*K - 1) / denom, (1 - sqrt(2*V)*K + V*K*K) / denom, 2 * (K*K - 1) / denom, (1 - sqrt(2)*K + K*K) / denom) with { V = ba.db2linear(G); K = tan(ma.PI*F/ma.SR); denom = 1 + sqrt(2)*K + K*K; }; //====================low frequency boost process =============================== process = vgroup("lowboost", lfboost(nentry("freq [unit:Hz][style:knob]", 100, 20, 150, 1), vslider("gain [unit:dB]", 0, -20, 20, 0.1))); Try it Yourself >>

lowBoost

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "lowboost"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //------------------------------------------------------------------ // DAFX, Digital Audio Effects (Wiley ed.) // chapter 2 : filters // section 2.3 : Equalizers // page 53 : second order shelving filter design //------------------------------------------------------------------ import("stdfaust.lib"); //------------------- low-frequency shelving boost (table 2.3) -------------------- V0(g) = pow(10,g/20.0); K(fc) = tan(ma.PI*fc/ma.SR); square(x) = x*x; denom(fc) = 1 + sqrt(2)*K(fc) + square(K(fc)); lfboost(fc, g) = fi.TF2((1 + sqrt(2*V0(g))*K(fc) + V0(g)*square(K(fc))) / denom(fc), 2 * (V0(g)*square(K(fc)) - 1) / denom(fc), (1 - sqrt(2*V0(g))*K(fc) + V0(g)*square(K(fc))) / denom(fc), 2 * (square(K(fc)) - 1) / denom(fc), (1 - sqrt(2)*K(fc) + square(K(fc))) / denom(fc)); //------------------------------ User Interface ----------------------------------- freq = hslider("[1]freq [unit:Hz][style:knob]", 1000, 20, 20000, 0.1); gain = hslider("[2]gain [unit:dB][style:knob]", 0, -20, 20, 0.1); //----------------------------------- Process ------------------------------------- process = vgroup("low-freq shelving boost", lfboost(freq,gain)); Try it Yourself >>

lowCut

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "lowcut"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //------------------------------------------------------------------ // DAFX, Digital Audio Effects (Wiley ed.) // chapter 2 : filters // section 2.3 : Equalizers // page 53 : second order shelving filter design //------------------------------------------------------------------ import("stdfaust.lib"); //------------------- low-frequency shelving cut (table 2.3) -------------------- V0(g) = pow(10,g/-20.0); K(fc) = tan(ma.PI*fc/ma.SR); squ(x) = x*x; denom(fc,g) = 1 + sqrt(2*V0(g))*K(fc) + V0(g)*squ(K(fc)); lfcut(fc, g) = fi.TF2((1 + sqrt(2)*K(fc) + squ(K(fc))) / denom(fc,g), 2 * (squ(K(fc)) - 1) / denom(fc,g), (1 - sqrt(2)*K(fc) + squ(K(fc))) / denom(fc,g), 2 * (V0(g)*squ(K(fc)) - 1) / denom(fc,g), (1 - sqrt(2*V0(g))*K(fc) + V0(g)*squ(K(fc))) / denom(fc,g)); //------------------------------ User Interface ----------------------------------- freq = hslider("freq [unit:Hz][style:knob]", 100, 20, 5000, 1); att = hslider("attenuation [unit:dB][style:knob]", 0, -96, 10, 0.1); //----------------------------------- Process ------------------------------------- process = vgroup("low-freq shelving cut", lfcut(freq,att)); Try it Yourself >>

lowShelf

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "lowShelf"; import("maxmsp.lib"); G = hslider("Gain [unit:dB]", 0, -10, 10, 0.1); F = hslider("Freq", 1000, 100, 10000, 1); Q = hslider("Q", 1, 0.01, 100, 0.01); process(x) = lowShelf(x,F,G,Q); Try it Yourself >>

LPF

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "LPF"; import("maxmsp.lib"); G = hslider("Gain [unit:dB]", 0, -10, 10, 0.1); F = hslider("Freq", 1000, 100, 10000, 1); Q = hslider("Q", 1, 0.01, 100, 0.01); process(x) = LPF(x,F,G,Q); Try it Yourself >>

moogVCF

declare name "moogVCF"; declare description "Exercise and compare three Moog VCF implementations"; import("stdfaust.lib"); process = dm.moog_vcf_demo; Try it Yourself >>

notch

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "notch"; import("maxmsp.lib"); G = hslider("Gain [unit:dB]", 0, -10, 10, 0.1); F = hslider("Freq", 1000, 100, 10000, 1); Q = hslider("Q", 1, 0.01, 100, 0.01); process(x) = notch(x,F,G,Q); Try it Yourself >>

parametricEqLab

declare name "parametricEqLab"; declare description "Demonstrate the Parametric Equalizer sections on test signals with spectrum analysis display"; import("stdfaust.lib"); //process = ol.sawtooth_demo : fl.parametric_eq_demo : // fl.mth_octave_spectral_level_demo(2) <: _,_; process = vgroup("[1]", dm.sawtooth_demo) : vgroup("[2]", dm.parametric_eq_demo) : vgroup("[3]", dm.mth_octave_spectral_level_demo(2)) <: _,_; Try it Yourself >>

parametricEqualizer

declare name "parametricEqualizer"; declare description "Exercise and compare Parametric Equalizer sections on test signals"; import("stdfaust.lib"); process = dm.parametric_eq_demo; Try it Yourself >>

peakingEQ

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "peakingEQ"; import("maxmsp.lib"); G = hslider("Gain [unit:dB]", 0, -10, 10, 0.1); F = hslider("Freq", 1000, 100, 10000, 1); Q = hslider("Q", 1, 0.01, 100, 0.01); process(x) = peakingEQ(x,F,G,Q); Try it Yourself >>

peakNotch

// WARNING: This a "legacy example based on a deprecated library". Check filters.lib // for more accurate examples of filter functions declare name "peakNotch"; import("maxmsp.lib"); G = hslider("Gain [unit: lin]", 1, 0, 8, 0.01); F = hslider("Freq", 1000, 100, 10000, 1); Q = hslider("Q", 1, 0.01, 100, 0.01); process(x) = peakNotch(x,F,G,Q); Try it Yourself >>

spectralTilt

declare name "spectralTilt"; declare description "Demonstrate the Spectral Tilt effect on test signals"; import("stdfaust.lib"); O = 2; // filter order process = dm.spectral_tilt_demo(2); Try it Yourself >>

vcfWahLab

import("stdfaust.lib"); declare description "Demonstrate competing variable-lowpass-filter effects on test signals with spectrum analysis display"; declare name "vcfWahLab"; // process = ol.sawtooth_demo : // el.crybaby_demo : el.moog_vcf_demo : el.wah4_demo : // fl.spectral_level_demo <: _,_; process = vgroup("[1]", dm.sawtooth_demo) : vgroup("[2]", dm.crybaby_demo) : vgroup("[3]", dm.wah4_demo) : vgroup("[4]", dm.moog_vcf_demo) : vgroup("[5]", dm.spectral_level_demo) <: _,_; Try it Yourself >>

vocoder

declare name "Vocoder"; declare version "0.0"; declare author "RM"; declare description "Use example of the vocoder function where an impulse train is used as excitation."; import("stdfaust.lib"); process = dm.vocoder_demo; Try it Yourself >>

wahPedal

declare name "wahPedal"; declare description "Demonstrate the Fourth-Order Wah pedal (similar to the Moog VCF)"; import("stdfaust.lib"); process = dm.wah4_demo; Try it Yourself >>

gameaudio

bubble

declare name "bubble"; declare description "Production of a water drop bubble sound."; declare license "MIT"; declare copyright "(c) 2017: Yann Orlarey, GRAME"; import("stdfaust.lib"); //---------------------------`bubble`-------------------------- // bubble(f0, trig) : produces a water drop bubble sound // // #### Usage // // ``` // bubble(f0, trig) : _ // ``` // // Where: // // * ` f0 `: base frequency of bubble sound // * `trig`: trigs the bubble sound on the rising front // // #### Example // // ``` // button("drop") : bubble(600) : _ // ``` // // #### Reference: // // <http://www.cs.ubc.ca/~kvdoel/publications/tap05.pdf> //------------------------------------------------------------ bubble(f0,trig) = os.osc(f) * (exp(-damp*time) : si.smooth(0.99)) with { damp = 0.043*f0 + 0.0014*f0^(3/2); f = f0*(1+sigma*time); sigma = eta * damp; eta = 0.075; time = 0 : (select2(trig>trig'):+(1)) ~ _ : ba.samp2sec; }; process = button("drop") : bubble(hslider("v:bubble/freq", 600, 150, 2000, 1)) <: dm.freeverb_demo; Try it Yourself >>

rain

//----------------------`rain`-------------------------- // A very simple rain simulator // // #### Usage // // ``` // rain(d,l) : _,_ // ``` // // Where: // // * `d`: is the density of the rain: between 0 and 1 // * `l`: is the level (volume) of the rain: between 0 and 1 // //---------------------------------------------------------- import("stdfaust.lib"); rain(density,level) = no.multinoise(2) : par(i, 2, drop) : par(i, 2, *(level)) with { drop = _ <: @(1), (abs < density) : *; }; process = rain ( hslider("v:rain/density", 300, 0, 1000, 1) / 1000, hslider("v:rain/volume", 0.5, 0, 1, 0.01) ); Try it Yourself >>

wind

//----------------------`wind`-------------------------- // A very simple wind simulator, based on a filtered white noise // // #### Usage // // ``` // wind(f) : _ // ``` // // Where: // // * `f`: is the force of the wind: between 0 and 1 // //---------------------------------------------------------- import("stdfaust.lib"); wind(force) = no.multinoise(2) : par(i, 2, ve.moog_vcf_2bn(force,freq)) : par(i, 2, *(force)) with { freq = (force*87)+1 : ba.pianokey2hz; }; process = wind ( hslider("v:wind/force",0.66,0,1,0.01) : si.smooth (0.997) ); Try it Yourself >>

generator

filterOsc

declare name "filterOSC"; declare version "0.0"; declare author "JOS, revised by RM"; declare description "Simple application demoing filter based oscillators."; import("stdfaust.lib"); process = dm.oscrs_demo; Try it Yourself >>

noise

// WARNING: This a "legacy example based on a deprecated library". Check noises.lib // for more accurate examples of noise functions declare name "Noise"; declare version "1.1"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2009"; //----------------------------------------------------------------- // Noise generator and demo file for the Faust math documentation //----------------------------------------------------------------- <mdoc> \section{Presentation of the "noise.dsp" Faust program} This program describes a white noise generator with an interactive volume, using a random function. \subsection{The random function} The \texttt{random} function describes a generator of random numbers, which equation follows. You should notice hereby the use of an integer arithmetic on 32 bits, relying on integer wrapping for big numbers. <equation>random</equation> \subsection{The noise function} The white noise then corresponds to: <equation>noise</equation> </mdoc> random = +(12345)~*(1103515245); noise = random/2147483647.0; <mdoc> \subsection{Just add a user interface element to play volume!} Endly, the sound level of this program is controlled by a user slider, which gives the following equation: <equation>process</equation> </mdoc> <mdoc> \section{Block-diagram schema of process} This process is illustrated on figure 1. <diagram>process</diagram> </mdoc> process = noise * vslider("Volume[style:knob][acc: 0 0 -10 0 10]", 0.5, 0, 1, 0.1); <mdoc> \section{Notice of this documentation} You might be careful of certain information and naming conventions used in this documentation: <notice/> \section{Listing of the input code} The following listing shows the input Faust code, parsed to compile this mathematical documentation. <listing/> </mdoc> Try it Yourself >>

noiseMetadata

// WARNING: This a "legacy example based on a deprecated library". Check noises.lib // for more accurate examples of noise functions <mdoc> \title{<metadata>name</metadata>} \author{<metadata>author</metadata>} \date{\today} \maketitle \begin{tabular}{ll} \hline \textbf{name} & <metadata>name</metadata> \\ \textbf{version} & <metadata>version</metadata> \\ \textbf{author} & <metadata>author</metadata> \\ \textbf{license} & <metadata>license</metadata> \\ \textbf{copyright} & <metadata>copyright</metadata> \\ \hline \end{tabular} \bigskip </mdoc> //----------------------------------------------------------------- // Noise generator and demo file for the Faust math documentation //----------------------------------------------------------------- declare name "noiseMetadata"; // avoid same name as in noise.dsp declare version "1.1"; declare author "Grame"; declare author "Yghe"; declare license "BSD"; declare copyright "(c)GRAME 2009"; <mdoc> \section{Presentation of the "noise.dsp" Faust program} This program describes a white noise generator with an interactive volume, using a random function. \subsection{The random function} </mdoc> random = +(12345)~*(1103515245); <mdoc> The \texttt{random} function describes a generator of random numbers, which equation follows. You should notice hereby the use of an integer arithmetic on 32 bits, relying on integer wrapping for big numbers. <equation>random</equation> \subsection{The noise function} </mdoc> noise = random/2147483647.0; <mdoc> The white noise then corresponds to: <equation>noise</equation> \subsection{Just add a user interface element to play volume!} </mdoc> process = noise * vslider("Volume[style:knob]", 0, 0, 1, 0.1); <mdoc> Endly, the sound level of this program is controlled by a user slider, which gives the following equation: <equation>process</equation> \section{Block-diagram schema of process} This process is illustrated on figure 1. <diagram>process</diagram> \section{Notice of this documentation} You might be careful of certain information and naming conventions used in this documentation: <notice /> \section{Listing of the input code} The following listing shows the input Faust code, parsed to compile this mathematical documentation. <listing mdoctags="false" dependencies="false" distributed="false" /> </mdoc> Try it Yourself >>

osc

declare name "osc"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2009"; //----------------------------------------------- // Sinusoidal Oscillator //----------------------------------------------- import("stdfaust.lib"); vol = hslider("volume [unit:dB]", 0, -96, 0, 0.1) : ba.db2linear : si.smoo ; freq = hslider("freq [unit:Hz]", 1000, 20, 24000, 1); process = vgroup("Oscillator", os.osc(freq) * vol); Try it Yourself >>

osci

declare name "osci"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2009"; //----------------------------------------------- // Sinusoidal Oscillator // (with linear interpolation) //----------------------------------------------- import("stdfaust.lib"); vol = hslider("volume [unit:dB]", 0, -96, 0, 0.1) : ba.db2linear : si.smoo ; freq = hslider("freq [unit:Hz]", 1000, 20, 24000, 1); process = vgroup("Oscillator", os.osci(freq) * vol); Try it Yourself >>

sawtoothLab

declare name "sawtoothLab"; declare version "0.0"; declare author "JOS, revised by RM"; declare description "An application demonstrating the different sawtooth oscillators of Faust."; import("stdfaust.lib"); process = dm.sawtooth_demo; Try it Yourself >>

virtualAnalog

declare name "VirtualAnalog"; declare version "0.0"; declare author "JOS, revised by RM"; declare description "Virtual analog oscillator demo application."; import("stdfaust.lib"); process = dm.virtual_analog_oscillator_demo; Try it Yourself >>

virtualAnalogLab

declare name "virtualAnalogLab"; import("stdfaust.lib"); process = vgroup("[1]", dm.virtual_analog_oscillator_demo) : vgroup("[2]", dm.moog_vcf_demo) : vgroup("[3]", dm.spectral_level_demo) // See also: vgroup("[3]", dm.fft_spectral_level_demo(32)) <: _,_; Try it Yourself >>

misc

capture

declare name "capture"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //------------------------------------------------- // Capture : record up to 8s of sound and // playback the recorded sound in loop //------------------------------------------------- import("stdfaust.lib"); B = button("Capture"); // Capture sound while pressed I = int(B); // convert button signal from float to integer R = (I-I') <= 0; // Reset capture when button is pressed D = (+(I):*(R))~_; // Compute capture duration while button is pressed: 0..NNNN0..MMM capture = *(B) : (+ : de.delay(8*65536, D-1)) ~ *(1.0-B) ; level = hslider("level (db)", 0, -96, 4, 0.1) : ba.db2linear : si.smoo; process = vgroup( "Audio Capture", capture : *(level) ) ; Try it Yourself >>

matrix

declare name "matrix"; declare version "1.0"; declare author "Grame"; declare license "BSD"; declare copyright "(c)GRAME 2006"; //----------------------------------------------- // Audio Matrix : N inputs x M outputs //----------------------------------------------- import("stdfaust.lib"); Fader(in) = ba.db2linear(vslider("Input %in", -10, -96, 4, 0.1)); Mixer(N,out) = hgroup("Output %out", par(in, N, *(Fader(in)) ) :> _ ); Matrix(N,M) = tgroup("Matrix %N x %M", par(in, N, _) <: par(out, M, Mixer(N, out))); process = Matrix(8, 8); Try it Yourself >>

midiTester

declare name "midiTester"; declare version "1.0"; declare author "Vincent Rateau, GRAME"; declare license "GPL v3"; declare reference "www.sonejo.net"; // FAUST MIDI TESTER process = _*0, (vgroup("FAUST MIDI TESTER", hgroup("[1]", controltester, noteontester, noteofftester, midiclocktester), hgroup("[2]", kattester, pctester, chattester, pitchwheeltester) :> _)) : attach; /////////////////////////// //Ctrl tester (ctrl ): tester(midi in, midi out) controltester = vgroup("CTRL IN/OUT", valuetest(50,51), booltest(100,101)) with{ valuetest(i,o) = hslider("Ctrl Value IN (Ctrl %i) [midi:ctrl %i]", 60, 0, 127, 1) : hbargraph("Ctrl Value OUT (Ctrl %o) [midi:ctrl %o]", 0, 127); booltest(i,o) = checkbox("Ctrl Bool IN (Ctrl %i) [midi:ctrl %i]") : hbargraph("Ctrl Bool OUT (Ctrl %o) [midi:ctrl %o]", 0, 1); }; //Note tester (keyon) : tester(midi in, midi out) noteontester = vgroup("NOTE ON IN/OUT", valuetest(50,51), booltest(100,101)) with{ valuetest(i,o) = hslider("NoteOn Value IN (Note %i) [midi:keyon %i]", 60, 0, 127, 1) : hbargraph("NoteOn Value OUT (Note %o) [midi:keyon %o]", 0, 127); booltest(i,o) = checkbox("NoteOn Bool IN (Note %i) [midi:keyon %i]") : hbargraph("NoteOn Bool OUT (Note %o) [midi:keyon %o]", 0, 1); }; //Note tester (keyoff) : tester(midi in, midi out) noteofftester = vgroup("NOTE OFF IN/OUT", valuetest(50,51), booltest(100,101)) with{ valuetest(i,o) = hslider("NoteOff Value IN (Note %i) [midi:keyoff %i]", 60, 0, 127, 1) : hbargraph("NoteOff Value OUT (Note %o) [midi:keyoff %o]", 0, 127); booltest(i,o) = checkbox("NoteOff Bool IN (Note %i) [midi:keyoff %i]") : hbargraph("NoteOff Bool OUT (Note %o) [midi:keyoff %o]", 0, 1); }; //Midisync tester midiclocktester = vgroup("MIDI SYNC (IN)", clock, startstop) with{ clock = checkbox("MIDI clock signal [midi:clock]"); startstop = checkbox("MIDI START/STOP [midi:start] [midi:stop]"); }; //Key Aftertouch tester (keypress) : tester(midi in, midi out) kattester = vgroup("KEY AFTERTOUCH (KAT) IN/OUT",valuetest(50,51), booltest(100,101)) with{ valuetest(i,o) = hslider("Note KAT Value IN (Note %i) [midi:keypress %i]", 60, 0, 127, 1) : hbargraph("Note KAT Value OUT (Note %o) [midi:keypress %o]", 0, 127); booltest(i,o) = checkbox("Note KAT Bool IN (Note %i) [midi:keypress %i]") : hbargraph("Note KAT Bool OUT (Note %o) [midi:keypress %o]", 0, 1); }; //ProgramChange tester (pgm) : tester(midi in, midi out) pctester = vgroup("PROGRAM CHANGE (PC) IN/OUT",valuetest(50,51), booltest(100,101)) with{ valuetest(i,o) = hslider("ProgramChange Value IN (PC %i) [midi:pgm %i]", 60, 0, 127, 1) : hbargraph("ProgramChange Value OUT (PC %o) [midi:pgm %o]", 0, 127); booltest(i