News:

CWP2Song, public beta.
My  DAW is Reaper
YouTube channel

Main Menu

AZ Lua MFX plug-in parallel fifths

Started by F0h, December 15, 2018, 06:58:22 PM

Previous topic - Next topic

F0h

Hello Cakewalkers!
I'm starting to learn AZ LUA, I copied and edited the program that "Convert modulation to the Program Change " I donĀ“t Know what does not work my edition
Please help
Regards.


--[[parallel fifths]]--

function OnInput(pqIn, pqOut)
  for i,e in ipairs(pqIn) do
    if e.Type == Note then
      local n = MfxEvent.new(Note)
      n.Time = e.Time
      n.Chan = e.Chan
      n.Key  = e.Key + 7
      n.Vel  = e.Vel
      n.VelOff = e.VelOff
      n.Duration = e.Duration
      e = n
    end
    pqOut.add(e)
  end
end

OnEvents = function ( From, To, pqIn, pqOut)
OnInput(pqIn, pqOut)
end


F0h

oh, I see the code process when I play a recorded MIDI event, but I would like add a new note every time I play a key... in realtime of course.

azslow3

#2
You took an example which works with CC. And you need one for Notes. That is a bit tricky, when you play recorded notes they are represented as "Note", with duration. But live they are represented as "NoteOn" and "NoteOff". If you dynamically switch what notes do, check MfxOffNotes.new() documentation and "Transpose everything one octave up during C3 "switch key" engaged" as an example.

But for simple static transformation you can use (untested!!!)

function OnInput(pqIn, pqOut)
  for i,e in ipairs(pqIn) do
    if e.Key then
      e.Key = e.Key + 7
    end
    pqOut.add(e)
  end
end
OnEvents = function ( From, To, pqIn, pqOut)
OnInput(pqIn, pqOut)
end

The trick here is simple, "Note", "NoteOn" and "NoteOff" have the field "Key". Other MIDI events do not have it. So you modify the Key if it exists, for all cases at once...

F0h

Oh yes!  :-[ Duration is Delta Time from Note Off to Note on.
I will study "Transpose everything one octave up during C3 "switch key"
and MfxOffNotes.new()
Thanks for your time.


F0h

F0h

Hello Alexey
This is my "Hello World" for AZ Lua
a Power Chord Plug in

Thanks for the advice

Julio.

F7h


--[[ Power Chord
    by Julio Benavides
--]]
local active = MfxOffNotes.new()
local n
function OnInput(pqIn, pqOut)
  for i,e in ipairs(pqIn) do
    if e.Type ~= Note then 
  pqOut.add(e)
end

    e = active.move(e, pqOut )

    if not e then  
elseif e.Vel then
      base = e:copy()  
      n = e.Key
      --Seconde note--  
  e.Key = n + 7
      active.add(base, e)     
      pqOut.add(e)  
      --Third note--
  e.Key = n + 12
      active.add(base, e)     
      pqOut.add(e)       
    end   
  end
end 

OnEvents = function ( From, To, pqIn, pqOut)
OnInput(pqIn, pqOut)
end



azslow3

Great!  :)

It took just several years till someone has tried to use AZ Lua  ::)

F0h

F0h
Hello Alexei
and Merry Christmas!!
This is my second aplication of your fantastic plug-in editor.
The code is not finished yet.
All your white keys is mapping to C Blues Scale
It was based in your drum map plug in.

--[[ C Blues Scale white keys
Based on Drum Map like functionality,
AZ, 2016
Julio Benavides, 2018 C blues scale
]]--
local scale = {}
for i = 1, 128 do --mapping
        k = i - 1 --MIDI KEY 0...127---
if k % 12 == 0  or k % 12 == 7 or k % 12 == 3 or k % 12 == 6 or  k % 12 == 10  then scale[i]=i-1
elseif k % 12 == 2 or  k % 12 == 5 or k % 12 == 9 or k % 12 == 1 or k % 12 == 8 or k % 12 == 4 or k % 12 == 5 or k % 12 == 11 then scale[i]=i
end
end
function OnInput(pqIn, pqOut)
  for i,e in ipairs(pqIn) do
    if e.Key then -- Is Note ?
      local newkey = scale[e.Key+1]
      if newkey then -- Mapping exist ?
        e.Key = newkey -- map the note
      end
    end
    pqOut.add(e)
  end
end
OnEvents = function ( From, To, pqIn, pqOut)
OnInput(pqIn, pqOut)
end


Next version: Scale Root Key change by MIDI Note Numbre 36..47  8)
Regards.

Julio

F0h

azslow3

Merry Christmas!!

I see you have understood how it works  ;)