3 name = "Lua Fluid Synth",
4 category = "Instrument",
6 author = "Ardour Lua Task Force",
7 description = [[An Example Synth for Prototyping.]]
10 function dsp_ioconfig ()
13 { midi_in = 1, audio_in = 0, audio_out = 2},
19 function dsp_init (rate)
20 fluidsynth = ARDOUR.FluidSynth (rate, 32)
21 assert (fluidsynth:load_sf2 ("/usr/share/sounds/sf2/FluidR3_GM.sf2"))
24 function dsp_run (ins, outs, n_samples)
28 -- parse midi messages
29 assert (type(midiin) == "table") -- global table of midi events (for now)
30 for _, e in pairs (midiin) do
31 local t = e["time"] -- t = [ 1 .. n_samples ]
33 -- synth sound until event
37 fluidsynth:synth (outs[1]:offset (off), outs[2]:offset (off), len)
42 fluidsynth:midi_event (e["bytes"], e["size"]) -- parse midi event
45 -- synth rest of cycle
46 if tme <= n_samples then
48 local len = 1 + n_samples - tme
49 fluidsynth:synth (outs[1]:offset (off), outs[2]:offset (off), len)