Audio plugin host https://kx.studio/carla
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.

78 lines
2.9KB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # Carla Backend utils
  4. # Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License as
  8. # published by the Free Software Foundation; either version 2 of
  9. # the License, or any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. # ------------------------------------------------------------------------------------------------------------
  18. # Imports (Global)
  19. # ------------------------------------------------------------------------------------------------------------
  20. # Imports (ctypes)
  21. from ctypes import (
  22. c_char_p, c_void_p, cast,
  23. cdll, Structure,
  24. POINTER
  25. )
  26. from sip import unwrapinstance
  27. # ------------------------------------------------------------------------------------------------------------
  28. # Imports (Custom)
  29. from carla_backend import (
  30. structToDict
  31. )
  32. # ---------------------------------------------------------------------------------------------------------------------
  33. # Convert a ctypes struct into a python dict, or None if null
  34. def structToDictOrNull(struct):
  35. return structToDict(struct.contents) if struct else None
  36. # ------------------------------------------------------------------------------------------------------------
  37. # Carla Frontend API (C stuff)
  38. class JackApplicationDialogResults(Structure):
  39. _fields_ = [
  40. ("command", c_char_p),
  41. ("name", c_char_p),
  42. ("labelSetup", c_char_p)
  43. ]
  44. # ------------------------------------------------------------------------------------------------------------
  45. # Carla Frontend object using a DLL
  46. class CarlaFrontendLib():
  47. def __init__(self, filename):
  48. self.lib = cdll.LoadLibrary(filename)
  49. self.lib.carla_frontend_createAndExecAboutJuceW.argtypes = (c_void_p,)
  50. self.lib.carla_frontend_createAndExecAboutJuceW.restype = None
  51. self.lib.carla_frontend_createAndExecJackApplicationW.argtypes = (c_void_p, c_char_p)
  52. self.lib.carla_frontend_createAndExecJackApplicationW.restype = POINTER(JackApplicationDialogResults)
  53. # --------------------------------------------------------------------------------------------------------
  54. def createAndExecAboutJuceW(self, parent):
  55. self.lib.carla_frontend_createAndExecAboutJuceW(unwrapinstance(parent))
  56. def createAndExecJackApplicationW(self, parent, projectFilename):
  57. return structToDictOrNull(self.lib.carla_frontend_createAndExecJackApplicationW(unwrapinstance(parent), projectFilename.encode("utf-8")))
  58. # ------------------------------------------------------------------------------------------------------------