Extra "ports" of juce-based plugins using the distrho build system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.2KB

  1. -- outputs a stream of semi-chaotic notes on MIDI channel 1
  2. require "include/protoplug"
  3. --Welcome to Lua Protoplug generator (version 1.0.0)
  4. x=0
  5. function plugin.processBlock(samples, smax, midiBuf)
  6. newEvents = {}
  7. if not interval then updateInterval() end
  8. if not i then i = interval + 1 end
  9. for s=0,smax do
  10. if i>=interval then
  11. local f1,v1 = magic(x)
  12. local f2 = magic(x-5)
  13. if f1 then noteOn(f1, v1) end
  14. if f1 then noteOn(f1-5, v1) end
  15. if f2 then noteOff(f2) end
  16. if f2 then noteOff(f2-5) end
  17. i = 0
  18. x = x + 1
  19. end
  20. i = i + 1
  21. end
  22. midiBuf:clear()
  23. if #newEvents>0 then
  24. for _,e in ipairs(newEvents) do
  25. midiBuf:addEvent(e)
  26. end
  27. end
  28. end
  29. function noteOn(n,v)
  30. if n>100 then return end
  31. table.insert(newEvents, midi.Event.noteOn(1, n, v))
  32. end
  33. function noteOff(n)
  34. table.insert(newEvents, midi.Event.noteOff(1, n, 0))
  35. end
  36. function magic(x)
  37. if ((x%19)%11)%4==0 then
  38. return 40+x%((x/6)%8+2)*8, 20+((x/6)%8+2)*8
  39. end
  40. end
  41. function updateInterval()
  42. local int = params[1].getValue()
  43. bpm = plugin.getCurrentPosition().bpm
  44. interval = math.floor((plugin.getSampleRate()*int)/(bpm))
  45. end
  46. params = plugin.manageParams {
  47. {
  48. name = "Interval";
  49. type = "int";
  50. min = 3;
  51. max = 30;
  52. default = 60;
  53. changed = function(val) interval = nil end;
  54. };
  55. }