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.

60 lines
1.2KB

  1. --[[
  2. name: Delay Line
  3. description: Simple delay line effect with DC removal
  4. author: osar.fr
  5. --]]
  6. require "include/protoplug"
  7. local length, feedback
  8. stereoFx.init()
  9. -- everything is per stereo channel
  10. function stereoFx.Channel:init()
  11. self.buf = ffi.new("double[512]")
  12. self.it = 0 -- iterator
  13. self.dc1, self.dc2 = 0,0
  14. end
  15. function stereoFx.Channel:goBack()
  16. local nit = self.it-length
  17. if nit<0 then nit = nit+512 end
  18. local o = self.buf[nit]
  19. nit = nit-1
  20. if nit<0 then nit = nit+512 end
  21. o = o+self.buf[nit]
  22. o = o*0.4992*feedback
  23. return o
  24. end
  25. function stereoFx.Channel:dcRemove(s)
  26. self.dc1 = self.dc1 + (s - self.dc2) * 0.000002
  27. self.dc2 = self.dc2 + self.dc1
  28. self.dc1 = self.dc1 * 0.96
  29. return s-self.dc2
  30. end
  31. function stereoFx.Channel:processBlock(samples, smax)
  32. for i = 0,smax do
  33. samples[i] = samples[i]+self:dcRemove(samples[i]+self:goBack())
  34. self.buf[self.it] = samples[i]
  35. self.it = self.it+1
  36. if self.it>=512 then self.it=0 end
  37. end
  38. end
  39. params = plugin.manageParams {
  40. {
  41. name = "Length";
  42. type = "int";
  43. max = 510;
  44. changed = function(val) length = val end;
  45. };
  46. {
  47. name = "Feedback";
  48. max = 1;
  49. changed = function(val) feedback = val end;
  50. };
  51. }