Dup Ver Goto 📝

Scripts1

PT2/music/plugins/uvi-falcon does not exist
To
69 lines, 240 words, 1611 chars Page 'Scripts1' does not exist.

Falcon scripts are written in Lua 5.1.

To create a new event processor, drag a 'Script Processor' into an EVent slot. Create a .lua file in a text editor. Then click on the folder to load the script.

For example:

-- play quavers with all held keys

isEventPlaying = {}

function tableLength(T)
  local count = 0
  for _ in pairs(T) do count = count + 1 end
  return count
end

local seqLaunched = false
local timeVal = 1.0
local duration = 0.5
function seq()
  local dur = duration * getBeatDuration()
  while true do
    len = tableLength(isEventPlaying)
    if( len == 0 ) then break end

    for k, e in pairs(isEventPlaying) do
      playNote(e.note, e.velocity, dur, e.layer, e.channel, e.input, e.vol, e.pan, e.tune, e.slice)
    end
    waitBeat(timeVal)
  end
  seqLaunched = false
end

function onNote(e)
  isEventPlaying[e.id] = e
  if not seqLaunched then
    seqLaunched = true
    run(seq,e) -- run(func,params) => execute func in parallel
  end
end

function onRelease(e)
  isEventPlaying[e.id] = nil
end

Event notes e.note are integers corresponding to midi pitches. We can do

function seq()
  local dur = duration * getBeatDuration()
  local count
  local note
  while true do
    len = tableLength(isEventPlaying)
    if( len == 0 ) then break end

    count = 0
    for k, e in pairs(isEventPlaying) do
      note = e.note - 24 + 12 * count 
      playNote(note, e.velocity, dur, e.layer, count % 4, e.input, e.vol, e.pan, e.tune, e.slice)
      count = count + 1
    end
    waitBeat(timeVal)
  end
  seqLaunched = false
end