1 /* 2 * Carla Plugin Host 3 * Copyright (C) 2011-2021 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 18 #ifndef CARLA_UTILS_H_INCLUDED 19 #define CARLA_UTILS_H_INCLUDED 20 21 #include "CarlaBackend.h" 22 23 #ifdef __cplusplus 24 using CarlaBackend::PluginCategory; 25 using CarlaBackend::PluginType; 26 #endif 27 28 /*! 29 * @defgroup CarlaUtilsAPI Carla Utils API 30 * 31 * The Carla Utils API. 32 * 33 * This API allows to call advanced features from Python. 34 * @{ 35 */ 36 37 /*! 38 * TODO. 39 */ 40 typedef void* CarlaPipeClientHandle; 41 42 /*! 43 * TODO. 44 */ 45 typedef void (*CarlaPipeCallbackFunc)(void* ptr, const char* msg); 46 47 /*! 48 * Information about a cached plugin. 49 * @see carla_get_cached_plugin_info() 50 */ 51 typedef struct _CarlaCachedPluginInfo { 52 /*! 53 * Wherever the data in this struct is valid. 54 * For performance reasons, plugins are only checked on request, 55 * and as such, the count vs number of really valid plugins might not match. 56 * Use this field to skip on plugins which cannot be loaded in Carla. 57 */ 58 bool valid; 59 60 /*! 61 * Plugin category. 62 */ 63 PluginCategory category; 64 65 /*! 66 * Plugin hints. 67 * @see PluginHints 68 */ 69 uint hints; 70 71 /*! 72 * Number of audio inputs. 73 */ 74 uint32_t audioIns; 75 76 /*! 77 * Number of audio outputs. 78 */ 79 uint32_t audioOuts; 80 81 /*! 82 * Number of CV inputs. 83 */ 84 uint32_t cvIns; 85 86 /*! 87 * Number of CV outputs. 88 */ 89 uint32_t cvOuts; 90 91 /*! 92 * Number of MIDI inputs. 93 */ 94 uint32_t midiIns; 95 96 /*! 97 * Number of MIDI outputs. 98 */ 99 uint32_t midiOuts; 100 101 /*! 102 * Number of input parameters. 103 */ 104 uint32_t parameterIns; 105 106 /*! 107 * Number of output parameters. 108 */ 109 uint32_t parameterOuts; 110 111 /*! 112 * Plugin name. 113 */ 114 const char* name; 115 116 /*! 117 * Plugin label. 118 */ 119 const char* label; 120 121 /*! 122 * Plugin author/maker. 123 */ 124 const char* maker; 125 126 /*! 127 * Plugin copyright/license. 128 */ 129 const char* copyright; 130 131 #ifdef __cplusplus 132 /*! 133 * C++ constructor. 134 */ 135 CARLA_API _CarlaCachedPluginInfo() noexcept; 136 CARLA_DECLARE_NON_COPY_STRUCT(_CarlaCachedPluginInfo) 137 #endif 138 139 } CarlaCachedPluginInfo; 140 141 /* -------------------------------------------------------------------------------------------------------------------- 142 * cached plugins */ 143 144 /*! 145 * Get how many cached plugins are available. 146 * Internal and LV2 plugin formats are cached and need to be discovered via this function. 147 * Do not call this for any other plugin formats. 148 * 149 * @note if this carla build uses JUCE, then you must call carla_juce_init beforehand 150 */ 151 CARLA_EXPORT uint carla_get_cached_plugin_count(PluginType ptype, const char* pluginPath); 152 153 /*! 154 * Get information about a cached plugin. 155 * 156 * @note if this carla build uses JUCE, then you must call carla_juce_init beforehand 157 */ 158 CARLA_EXPORT const CarlaCachedPluginInfo* carla_get_cached_plugin_info(PluginType ptype, uint index); 159 160 #ifndef CARLA_HOST_H_INCLUDED 161 /* -------------------------------------------------------------------------------------------------------------------- 162 * information */ 163 164 /*! 165 * Get the complete license text of used third-party code and features. 166 * Returned string is in basic html format. 167 */ 168 CARLA_EXPORT const char* carla_get_complete_license_text(void); 169 170 /*! 171 * Get the juce version used in the current Carla build. 172 */ 173 CARLA_EXPORT const char* carla_get_juce_version(void); 174 175 /*! 176 * Get the list of supported file extensions in carla_load_file(). 177 */ 178 CARLA_EXPORT const char* const* carla_get_supported_file_extensions(void); 179 180 /*! 181 * Get the list of supported features in the current Carla build. 182 */ 183 CARLA_EXPORT const char* const* carla_get_supported_features(void); 184 185 /*! 186 * Get the absolute filename of this carla library. 187 */ 188 CARLA_EXPORT const char* carla_get_library_filename(void); 189 190 /*! 191 * Get the folder where this carla library resides. 192 */ 193 CARLA_EXPORT const char* carla_get_library_folder(void); 194 #endif 195 196 /* -------------------------------------------------------------------------------------------------------------------- 197 * JUCE */ 198 199 /*! 200 * Initialize data structures and GUI support for JUCE. 201 * This is only needed when carla builds use JUCE and you call cached-plugin related APIs. 202 * 203 * Idle must then be called at somewhat regular intervals, though in practice there is no reason for it yet. 204 * 205 * Make sure to call carla_juce_cleanup after you are done with APIs that need JUCE. 206 */ 207 CARLA_EXPORT void carla_juce_init(void); 208 209 /*! 210 * Give idle time to JUCE stuff. 211 * Currently only used for Linux. 212 */ 213 CARLA_EXPORT void carla_juce_idle(void); 214 215 /*! 216 * Cleanup the JUCE stuff that was initialized by carla_juce_init. 217 */ 218 CARLA_EXPORT void carla_juce_cleanup(void); 219 220 /* -------------------------------------------------------------------------------------------------------------------- 221 * pipes */ 222 223 /*! 224 * TODO. 225 */ 226 CARLA_EXPORT CarlaPipeClientHandle carla_pipe_client_new(const char* argv[], CarlaPipeCallbackFunc callbackFunc, void* callbackPtr); 227 228 /*! 229 * TODO. 230 */ 231 CARLA_EXPORT void carla_pipe_client_idle(CarlaPipeClientHandle handle); 232 233 /*! 234 * TODO. 235 */ 236 CARLA_EXPORT bool carla_pipe_client_is_running(CarlaPipeClientHandle handle); 237 238 /*! 239 * TODO. 240 */ 241 CARLA_EXPORT void carla_pipe_client_lock(CarlaPipeClientHandle handle); 242 243 /*! 244 * TODO. 245 */ 246 CARLA_EXPORT void carla_pipe_client_unlock(CarlaPipeClientHandle handle); 247 248 /*! 249 * TODO. 250 */ 251 CARLA_EXPORT const char* carla_pipe_client_readlineblock(CarlaPipeClientHandle handle, uint timeout); 252 253 /*! 254 * Extras. 255 * TODO. 256 */ 257 CARLA_EXPORT bool carla_pipe_client_readlineblock_bool(CarlaPipeClientHandle handle, uint timeout); 258 CARLA_EXPORT int carla_pipe_client_readlineblock_int(CarlaPipeClientHandle handle, uint timeout); 259 CARLA_EXPORT double carla_pipe_client_readlineblock_float(CarlaPipeClientHandle handle, uint timeout); 260 261 /*! 262 * TODO. 263 */ 264 CARLA_EXPORT bool carla_pipe_client_write_msg(CarlaPipeClientHandle handle, const char* msg); 265 266 /*! 267 * TODO. 268 */ 269 CARLA_EXPORT bool carla_pipe_client_write_and_fix_msg(CarlaPipeClientHandle handle, const char* msg); 270 271 /*! 272 * TODO. 273 */ 274 CARLA_EXPORT bool carla_pipe_client_flush(CarlaPipeClientHandle handle); 275 276 /*! 277 * TODO. 278 */ 279 CARLA_EXPORT bool carla_pipe_client_flush_and_unlock(CarlaPipeClientHandle handle); 280 281 /*! 282 * TODO. 283 */ 284 CARLA_EXPORT void carla_pipe_client_destroy(CarlaPipeClientHandle handle); 285 286 /* -------------------------------------------------------------------------------------------------------------------- 287 * system stuff */ 288 289 /*! 290 * Flush stdout or stderr. 291 */ 292 CARLA_EXPORT void carla_fflush(bool err); 293 294 /*! 295 * Print the string @a string to stdout or stderr. 296 */ 297 CARLA_EXPORT void carla_fputs(bool err, const char* string); 298 299 /*! 300 * Set the current process name to @a name. 301 */ 302 CARLA_EXPORT void carla_set_process_name(const char* name); 303 304 /* -------------------------------------------------------------------------------------------------------------------- 305 * window control */ 306 307 /*! 308 * Get the global/desktop scale factor. 309 */ 310 CARLA_EXPORT double carla_get_desktop_scale_factor(void); 311 312 CARLA_EXPORT int carla_cocoa_get_window(void* nsViewPtr); 313 CARLA_EXPORT void carla_cocoa_set_transient_window_for(void* nsViewChild, void* nsViewParent); 314 315 CARLA_EXPORT void carla_x11_reparent_window(uintptr_t winId1, uintptr_t winId2); 316 317 CARLA_EXPORT void carla_x11_move_window(uintptr_t winId, int x, int y); 318 319 CARLA_EXPORT int* carla_x11_get_window_pos(uintptr_t winId); 320 321 /* ----------------------------------------------------------------------------------------------------------------- */ 322 323 /** @} */ 324 325 #endif /* CARLA_UTILS_H_INCLUDED */ 326