X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=scripts%2Fsynth1.lua;h=de68c58e46ee8d13550824fb43e6af266ee1c022;hb=eca27d82189c7509f7d010adad9ed3d83bccbf21;hp=046d27404bb4e89733d3196d6ac6adb5dfe2785e;hpb=769163c8899424f839f5cf0f66b76f7dd51eacae;p=ardour.git diff --git a/scripts/synth1.lua b/scripts/synth1.lua index 046d27404b..de68c58e46 100644 --- a/scripts/synth1.lua +++ b/scripts/synth1.lua @@ -1,27 +1,24 @@ ardour { ["type"] = "dsp", name = "Simple Synth", + category = "Instrument", license = "MIT", - author = "Robin Gareus", - email = "robin@gareus.org", - site = "http://gareus.org", - description = [[An Example Synth for prototyping.]] + author = "Ardour Lua Task Force", + description = [[An Example Synth for Prototyping.]] } function dsp_ioconfig () return { - { audio_in = 0, audio_out = -1}, -- any number of channels - -- { audio_in = 0, audio_out = 4}, -- values > 0, precisely N channels - -- { audio_in = 0, audio_out = -6}, -- values < -2, up to -N channels, here 1,..,6 + -- { midi_in = 1, audio_in = 0, audio_out = -1}, -- any number of channels + -- { midi_in = 1, audio_in = 0, audio_out = 1}, -- values > 0, precisely N channels + { midi_in = 1, audio_in = 0, audio_out = 2}, -- values > 0, precisely N channels + { midi_in = 1, audio_in = 0, audio_out = 4}, -- values > 0, precisely N channels + { midi_in = 1, audio_in = 0, audio_out = 8}, -- values > 0, precisely N channels + -- { midi_in = 1, audio_in = 0, audio_out = -6}, -- values < -2, up to -N channels, here 1,..,6 } end -function dsp_midi_input () - return true -end - - local note_table = {} local active_notes = {} local phases = {} @@ -66,8 +63,8 @@ function dsp_run (ins, outs, n_samples) local tme = 1 -- parse midi messages - assert (type(mididata) == "table") -- global table of midi events (for now) - for _,b in pairs (mididata) do + assert (type(midiin) == "table") -- global table of midi events (for now) + for _,b in pairs (midiin) do local t = b["time"] -- t = [ 1 .. n_samples ] -- synth sound until event @@ -76,17 +73,17 @@ function dsp_run (ins, outs, n_samples) local d = b["data"] -- get midi-event -- we ignore the midi channel - if (#d == 3 and bit32.band (d[1], 240) == 144) then -- note on + if (#d == 3 and (d[1] & 240) == 144) then -- note on local n = 1 + d[2]; active_notes[n] = active_notes[n] or {} active_notes[n]["tvel"] = d[3] end - if (#d == 3 and bit32.band (d[1], 240) == 128) then -- note off + if (#d == 3 and (d[1] & 240) == 128) then -- note off local n = 1 + d[2]; active_notes[n] = active_notes[n] or {} active_notes[n]["tvel"] = 0 end - if (#d == 3 and bit32.band (d[1], 240) == 176) then -- CC + if (#d == 3 and (d[1] & 240) == 176) then -- CC if (d[2] == 120 or d[2] == 123) then -- panic active_notes = {} end