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.

134 lines
3.8KB

  1. /*
  2. * Carla Engine utils
  3. * Copyright (C) 2011-2017 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_ENGINE_UTILS_HPP_INCLUDED
  18. #define CARLA_ENGINE_UTILS_HPP_INCLUDED
  19. #include "CarlaEngine.hpp"
  20. #include "CarlaUtils.hpp"
  21. CARLA_BACKEND_START_NAMESPACE
  22. // -----------------------------------------------------------------------
  23. // Maximum internal pre-allocated events
  24. const ushort kMaxEngineEventInternalCount = 512;
  25. // -----------------------------------------------------------------------
  26. static inline
  27. const char* EngineType2Str(const EngineType type) noexcept
  28. {
  29. switch (type)
  30. {
  31. case kEngineTypeNull:
  32. return "kEngineTypeNull";
  33. case kEngineTypeJack:
  34. return "kEngineTypeJack";
  35. case kEngineTypeRtAudio:
  36. return "kEngineTypeRtAudio";
  37. case kEngineTypePlugin:
  38. return "kEngineTypePlugin";
  39. case kEngineTypeBridge:
  40. return "kEngineTypeBridge";
  41. }
  42. carla_stderr("CarlaBackend::EngineType2Str(%i) - invalid type", type);
  43. return nullptr;
  44. }
  45. static inline
  46. const char* EnginePortType2Str(const EnginePortType type) noexcept
  47. {
  48. switch (type)
  49. {
  50. case kEnginePortTypeNull:
  51. return "kEnginePortTypeNull";
  52. case kEnginePortTypeAudio:
  53. return "kEnginePortTypeAudio";
  54. case kEnginePortTypeCV:
  55. return "kEnginePortTypeCV";
  56. case kEnginePortTypeEvent:
  57. return "kEnginePortTypeEvent";
  58. }
  59. carla_stderr("CarlaBackend::EnginePortType2Str(%i) - invalid type", type);
  60. return nullptr;
  61. }
  62. static inline
  63. const char* EngineEventType2Str(const EngineEventType type) noexcept
  64. {
  65. switch (type)
  66. {
  67. case kEngineEventTypeNull:
  68. return "kEngineEventTypeNull";
  69. case kEngineEventTypeControl:
  70. return "kEngineEventTypeControl";
  71. case kEngineEventTypeMidi:
  72. return "kEngineEventTypeMidi";
  73. }
  74. carla_stderr("CarlaBackend::EngineEventType2Str(%i) - invalid type", type);
  75. return nullptr;
  76. }
  77. static inline
  78. const char* EngineControlEventType2Str(const EngineControlEventType type) noexcept
  79. {
  80. switch (type)
  81. {
  82. case kEngineControlEventTypeNull:
  83. return "kEngineNullEvent";
  84. case kEngineControlEventTypeParameter:
  85. return "kEngineControlEventTypeParameter";
  86. case kEngineControlEventTypeMidiBank:
  87. return "kEngineControlEventTypeMidiBank";
  88. case kEngineControlEventTypeMidiProgram:
  89. return "kEngineControlEventTypeMidiProgram";
  90. case kEngineControlEventTypeAllSoundOff:
  91. return "kEngineControlEventTypeAllSoundOff";
  92. case kEngineControlEventTypeAllNotesOff:
  93. return "kEngineControlEventTypeAllNotesOff";
  94. }
  95. carla_stderr("CarlaBackend::EngineControlEventType2Str(%i) - invalid type", type);
  96. return nullptr;
  97. }
  98. // -------------------------------------------------------------------
  99. // Helper classes
  100. class ScopedEngineEnvironmentLocker
  101. {
  102. public:
  103. ScopedEngineEnvironmentLocker(CarlaEngine* const engine) noexcept;
  104. ~ScopedEngineEnvironmentLocker() noexcept;
  105. private:
  106. CarlaEngine::ProtectedData* const pData;
  107. CARLA_PREVENT_HEAP_ALLOCATION
  108. CARLA_DECLARE_NON_COPY_CLASS(ScopedEngineEnvironmentLocker)
  109. };
  110. // -----------------------------------------------------------------------
  111. CARLA_BACKEND_END_NAMESPACE
  112. #endif // CARLA_ENGINE_UTILS_HPP_INCLUDED