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.

118 lines
4.6KB

  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, c_char_p, c_uint, c_uint64, 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. ("build", c_uint),
  47. ("type", c_uint),
  48. ("hints", c_uint),
  49. ("category", c_char_p),
  50. ("filename", c_char_p),
  51. ("name", c_char_p),
  52. ("label", c_char_p),
  53. ("maker", c_char_p),
  54. ("uniqueId", c_uint64),
  55. ("audioIns", c_uint),
  56. ("audioOuts", c_uint),
  57. ("cvIns", c_uint),
  58. ("cvOuts", c_uint),
  59. ("midiIns", c_uint),
  60. ("midiOuts", c_uint),
  61. ("parametersIns", c_uint),
  62. ("parametersOuts", c_uint),
  63. ]
  64. # ------------------------------------------------------------------------------------------------------------
  65. # Carla Frontend object using a DLL
  66. class CarlaFrontendLib():
  67. def __init__(self, filename):
  68. self.lib = cdll.LoadLibrary(filename)
  69. self.lib.carla_frontend_createAndExecAboutJuceDialog.argtypes = (c_void_p,)
  70. self.lib.carla_frontend_createAndExecAboutJuceDialog.restype = None
  71. self.lib.carla_frontend_createAndExecJackAppDialog.argtypes = (c_void_p, c_char_p)
  72. self.lib.carla_frontend_createAndExecJackAppDialog.restype = POINTER(JackApplicationDialogResults)
  73. self.lib.carla_frontend_createPluginListDialog.argtypes = (c_void_p,)
  74. self.lib.carla_frontend_createPluginListDialog.restype = c_void_p
  75. self.lib.carla_frontend_execPluginListDialog.argtypes = (c_void_p,)
  76. self.lib.carla_frontend_execPluginListDialog.restype = POINTER(PluginListDialogResults)
  77. self.lib.carla_frontend_createAndExecPluginListDialog.argtypes = (c_void_p,)
  78. self.lib.carla_frontend_createAndExecPluginListDialog.restype = POINTER(PluginListDialogResults)
  79. # --------------------------------------------------------------------------------------------------------
  80. def createAndExecAboutJuceDialog(self, parent):
  81. self.lib.carla_frontend_createAndExecAboutJuceDialog(unwrapinstance(parent))
  82. def createAndExecJackAppDialog(self, parent, projectFilename):
  83. return structToDictOrNull(self.lib.carla_frontend_createAndExecJackAppDialog(unwrapinstance(parent),
  84. projectFilename.encode("utf-8")))
  85. def createPluginListDialog(self, parent, useSystemIcons):
  86. return self.lib.carla_frontend_createPluginListDialog(unwrapinstance(parent))
  87. def execPluginListDialog(self, dialog):
  88. return structToDictOrNull(self.lib.carla_frontend_execPluginListDialog(dialog))
  89. def createAndExecPluginListDialog(self, parent, useSystemIcons):
  90. return structToDictOrNull(self.lib.carla_frontend_createAndExecPluginListDialog(unwrapinstance(parent)))
  91. # ------------------------------------------------------------------------------------------------------------