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.

30 lines
533B

  1. -- lua utils
  2. local util = {}
  3. -- include cdefs
  4. function util.requireCdef(incpath)
  5. local incfile = io.open(incpath)
  6. if incfile==nil then
  7. error ("can't open include file : "..incpath)
  8. end
  9. local incstring = incfile:read "*a"
  10. incfile:close()
  11. ffi.cdef (incstring)
  12. end
  13. -- merge in modules or tables in general
  14. function util.merge (src, dst)
  15. for k,v in pairs(src) do
  16. dst[k] = v
  17. end
  18. end
  19. -- round x to n decimal places
  20. function util.roundDecimal(x, n)
  21. local p = math.pow(10, n)
  22. return math.floor(x*p+0.5)/p
  23. end
  24. return util