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.

105 lines
4.2KB

  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_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. class PluginListRefreshDialogResults(Structure):
  52. _fields_ = [
  53. ("todo", c_char)
  54. ]
  55. # ------------------------------------------------------------------------------------------------------------
  56. # Carla Frontend object using a DLL
  57. class CarlaFrontendLib():
  58. def __init__(self, filename):
  59. self.lib = cdll.LoadLibrary(filename)
  60. self.lib.carla_frontend_createAndExecAboutJuceDialog.argtypes = (c_void_p,)
  61. self.lib.carla_frontend_createAndExecAboutJuceDialog.restype = None
  62. self.lib.carla_frontend_createAndExecJackAppDialog.argtypes = (c_void_p, c_char_p)
  63. self.lib.carla_frontend_createAndExecJackAppDialog.restype = POINTER(JackApplicationDialogResults)
  64. self.lib.carla_frontend_createAndExecPluginListDialog.argtypes = (c_void_p,) # , c_bool)
  65. self.lib.carla_frontend_createAndExecPluginListDialog.restype = POINTER(PluginListDialogResults)
  66. self.lib.carla_frontend_createAndExecPluginListRefreshDialog.argtypes = (c_void_p, c_bool)
  67. self.lib.carla_frontend_createAndExecPluginListRefreshDialog.restype = POINTER(PluginListRefreshDialogResults)
  68. # --------------------------------------------------------------------------------------------------------
  69. def createAndExecAboutJuceDialog(self, parent):
  70. self.lib.carla_frontend_createAndExecAboutJuceDialog(unwrapinstance(parent))
  71. def createAndExecJackAppDialog(self, parent, projectFilename):
  72. return structToDictOrNull(self.lib.carla_frontend_createAndExecJackAppDialog(unwrapinstance(parent),
  73. projectFilename.encode("utf-8")))
  74. def createAndExecPluginListDialog(self, parent, useSystemIcons):
  75. return structToDictOrNull(self.lib.carla_frontend_createAndExecPluginListDialog(unwrapinstance(parent)))
  76. def createAndExecPluginListRefreshDialog(self, parent, useSystemIcons):
  77. return structToDictOrNull(self.lib.carla_frontend_createAndExecPluginListRefreshDialog(unwrapinstance(parent),
  78. useSystemIcons))
  79. # ------------------------------------------------------------------------------------------------------------