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.

92 lines
3.5KB

  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_bool, c_char_p, c_int, 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. class PluginListDialogResults(Structure):
  45. _fields_ = [
  46. ("btype", c_int),
  47. ("ptype", c_int),
  48. ("binary", c_char_p),
  49. ("label", c_char_p)
  50. ]
  51. # ------------------------------------------------------------------------------------------------------------
  52. # Carla Frontend object using a DLL
  53. class CarlaFrontendLib():
  54. def __init__(self, filename):
  55. self.lib = cdll.LoadLibrary(filename)
  56. self.lib.carla_frontend_createAndExecAboutJuceDialog.argtypes = (c_void_p,)
  57. self.lib.carla_frontend_createAndExecAboutJuceDialog.restype = None
  58. self.lib.carla_frontend_createAndExecJackAppDialog.argtypes = (c_void_p, c_char_p)
  59. self.lib.carla_frontend_createAndExecJackAppDialog.restype = POINTER(JackApplicationDialogResults)
  60. self.lib.carla_frontend_createAndExecPluginListDialog.argtypes = (c_void_p, c_bool)
  61. self.lib.carla_frontend_createAndExecPluginListDialog.restype = POINTER(JackApplicationDialogResults)
  62. # --------------------------------------------------------------------------------------------------------
  63. def createAndExecAboutJuceDialog(self, parent):
  64. self.lib.carla_frontend_createAndExecAboutJuceDialog(unwrapinstance(parent))
  65. def createAndExecJackAppDialog(self, parent, projectFilename):
  66. return structToDictOrNull(self.lib.carla_frontend_createAndExecJackAppDialog(unwrapinstance(parent), projectFilename.encode("utf-8")))
  67. def createAndExecPluginListDialog(self, parent, useSystemIcons):
  68. self.lib.carla_frontend_createAndExecPluginListDialog(unwrapinstance(parent), useSystemIcons)
  69. # ------------------------------------------------------------------------------------------------------------