Examples
This page is a bit too empty at this time.
More examples are available in the /examples directory.
Polyphonic synth appregiator
A polyphonic synthesizer with filtering envelope, played by a simple appregiator.
appregiator.mp3
j = Jack:new() function Synth() local o1 = Dsp:Square() local o2 = Dsp:Saw() local f = Dsp:Filter { f = 800, Q = 8 } local adsr = Dsp:Adsr { A = 0.01, D = 0.01, S = 0.3 } local adsr2 = Dsp:Adsr { A = 0.03, D = 1.00, S = 0.1 } local pan = Dsp:Pan() local depth = 0 + 0.1 local function instr(note, vel) if vel > 0 then depth = vel end local freq = n2f(note) o1:set { f = freq } o2:set { f = freq * 4.0 + 0.2 } adsr:set { vel = vel } adsr2:set { vel = vel } pan:set { pan = rr(-0.8, 0.8) } end local function gen() f:set { f = adsr2() * 3000 * depth + 20} return pan(0.1 * adsr() * f(o1() + o2() + math.random() * 0.75)) end return instr, gen end instr, gen = Poly(Synth) rev = Dsp:Reverb { damp = 0.2 } j:dsp("synth", 0, 2, function() return rev(gen()) end) j:connect("worp") function play2(instr, note, vel, dur) play(instr, note, vel, dur) at(0.18*3, play, instr, note + 12, vel * 0.9, dur) end ns = { 34, 22, 70, 34, 65, 34, 17, 74, 36, 72, 53, 58 } function appreg(i) local n = ns[i] local v = (i % 5) == 1 and 0.9 or 0.7 play2(instr, n, v, 0.16) at(0.18, function() appreg((i % #ns) + 1) end) end appreg(1)
Linuxsampler + DSP effects
The fragment below plays a piano loop with Linuxsampler, adds a wah-wah effect with a LFO-controlled bandpass filter, and plays some simple reverberated percussion in the background:
example.mp3
j = Jack:new("worp") l = Linuxsampler:new("piano", "/opt/samples") m = Metro:new(150, 10) v = l:add("piano/megapiano.gig", 0) n = Dsp:Noise() nf = Dsp:Filter { type = "bp", f = 8000, Q = 5 } p = Dsp:Pan() a = Dsp:Adsr { A = 0, D = 0.03, S = 1, R = 0.05 } r = Dsp:Reverb { } f = Dsp:Filter { type = "bp", Q = 5 } lfo = Dsp:Osc { f = 4 / m:t_meas() } ns = { 36, 75, 79, 84, 34, 75, 79, 74, 84, 82 } function loop(i) play(v, ns[i], ns[i] < 40 and 0.8 or 0.6, 1.0) i = (i % #ns) + 1 at(m:t_beat(), loop, i) end j:dsp("wah", 1, 1, function(vi) f:set { f = lfo() * 500 + 700 } return f(vi) end) j:dsp("perc", 0, 2, function() return p( r( nf( a() * n() ) ) ) end) function click() nf:set { f = rr(8000, 12000) } p:set { pan = rr(-1, 1) } a:set { vel = rr(0.2, 0.8) } at(0.01, function() a:set { vel = 0 } end) at(m:t_beat() * 0.5, "click") end loop(1) click() j:connect("piano", "worp:wah") j:connect("worp:wah", "system:playback") j:connect("worp:perc", "system:playback")
Linuxsampler
Create a linuxsampler instrument, and map this to midi channel 1.
ls = Linuxsampler:new("synth", "/opt/samples") j = Jack:new("worp") midi = j:midi() piano = ls:add("piano/Bosendorfer.gig", 0) midi:map_instr(1, piano) j:connect("synth") j:connect("worp")