Adjust for liblo API breakage, dont define lo_message type
[carla.git] / source / backend / CarlaPlugin.hpp
blob35ee2f18889f31e40bb72d470af3ff08e22498f7
1 /*
2 * Carla Plugin Host
3 * Copyright (C) 2011-2023 Filipe Coelho <falktx@falktx.com>
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.
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.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef CARLA_PLUGIN_HPP_INCLUDED
19 #define CARLA_PLUGIN_HPP_INCLUDED
21 #include "CarlaBackend.h"
22 #include "CarlaPluginPtr.hpp"
24 // -----------------------------------------------------------------------
25 // Avoid including extra libs here
27 typedef struct _NativePluginDescriptor NativePluginDescriptor;
28 struct LADSPA_RDF_Descriptor;
30 // -----------------------------------------------------------------------
32 CARLA_BACKEND_START_NAMESPACE
34 #ifdef _MSC_VER
35 # define CARLA_PLUGIN_WARN_UNUSED_RESULT
36 #else
37 # define CARLA_PLUGIN_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
38 #endif
40 // -----------------------------------------------------------------------
42 /*!
43 * @defgroup CarlaPluginAPI Carla Plugin API
45 * The Carla Plugin API.
46 * @{
49 class CarlaEngineAudioPort;
50 class CarlaEngineCVPort;
51 class CarlaEngineEventPort;
52 class CarlaEngineCVSourcePorts;
53 class CarlaEngineBridge;
54 struct CarlaStateSave;
55 struct EngineEvent;
57 // -----------------------------------------------------------------------
59 /*!
60 * Carla Backend base plugin class
62 * This is the base class for all available plugin types available in Carla Backend.
63 * All virtual calls are implemented in this class as fallback (except reload and process),
64 * so it's safe to only override needed calls.
66 * @see PluginType
68 class CARLA_API CarlaPlugin
70 protected:
71 /*!
72 * This is the constructor of the base plugin class.
74 * @param engine The engine which this plugin belongs to, must not be null
75 * @param id The 'id' of this plugin, must be between 0 and CarlaEngine::maxPluginNumber()
77 CarlaPlugin(CarlaEngine* engine, uint id);
79 public:
80 /*!
81 * This is the destructor of the base plugin class.
83 virtual ~CarlaPlugin();
85 // -------------------------------------------------------------------
86 // Information (base)
88 /*!
89 * Get the plugin's type (a subclass of CarlaPlugin).
91 * @note Plugin bridges will return their respective plugin type, there is no plugin type such as "bridge".
92 * To check if a plugin is a bridge use:
93 * @code
94 * if (getHints() & PLUGIN_IS_BRIDGE)
95 * ...
96 * @endcode
98 virtual PluginType getType() const noexcept = 0;
101 * Get the plugin's id (as passed in the constructor).
103 * @see setId()
105 uint getId() const noexcept;
108 * Get the plugin's hints.
110 * @see PluginHints
112 uint getHints() const noexcept;
115 * Get the plugin's options (currently in use).
117 * @see PluginOptions, getOptionsAvailable() and setOption()
119 uint getOptionsEnabled() const noexcept;
122 * Check if the plugin is enabled.
123 * When a plugin is disabled, it will never be processed or managed in any way.
125 * @see setEnabled()
127 bool isEnabled() const noexcept;
130 * Get the plugin's internal name.
131 * This name is unique within all plugins in an engine.
133 * @see getRealName() and setName()
135 const char* getName() const noexcept;
138 * Get the currently loaded DLL filename for this plugin.
139 * (Sound kits return their exact filename).
141 const char* getFilename() const noexcept;
144 * Get the plugins's icon name.
146 const char* getIconName() const noexcept;
149 * Get the plugin's category (delay, filter, synth, etc).
151 virtual PluginCategory getCategory() const noexcept;
154 * Get the plugin's native unique Id.
155 * May return 0 on plugin types that don't support Ids.
157 virtual int64_t getUniqueId() const noexcept;
160 * Get the plugin's latency, in sample frames.
162 virtual uint32_t getLatencyInFrames() const noexcept;
164 // -------------------------------------------------------------------
165 // Information (count)
168 * Get the number of audio inputs.
170 uint32_t getAudioInCount() const noexcept;
173 * Get the number of audio outputs.
175 uint32_t getAudioOutCount() const noexcept;
178 * Get the number of CV inputs.
180 uint32_t getCVInCount() const noexcept;
183 * Get the number of CV outputs.
185 uint32_t getCVOutCount() const noexcept;
188 * Get the number of MIDI inputs.
190 virtual uint32_t getMidiInCount() const noexcept;
193 * Get the number of MIDI outputs.
195 virtual uint32_t getMidiOutCount() const noexcept;
198 * Get the number of parameters.
199 * To know the number of parameter inputs and outputs separately use getParameterCountInfo() instead.
201 uint32_t getParameterCount() const noexcept;
204 * Get the number of scalepoints for parameter @a parameterId.
206 virtual uint32_t getParameterScalePointCount(uint32_t parameterId) const noexcept;
209 * Get the number of programs.
211 uint32_t getProgramCount() const noexcept;
214 * Get the number of MIDI programs.
216 uint32_t getMidiProgramCount() const noexcept;
219 * Get the number of custom data sets.
221 uint32_t getCustomDataCount() const noexcept;
223 // -------------------------------------------------------------------
224 // Information (current data)
227 * Get the current program number (-1 if unset).
229 * @see setProgram()
231 int32_t getCurrentProgram() const noexcept;
234 * Get the current MIDI program number (-1 if unset).
236 * @see setMidiProgram()
237 * @see setMidiProgramById()
239 int32_t getCurrentMidiProgram() const noexcept;
242 * Get hints about an audio port.
244 virtual uint getAudioPortHints(bool isOutput, uint32_t portIndex) const noexcept;
247 * Get the parameter data of @a parameterId.
249 const ParameterData& getParameterData(uint32_t parameterId) const noexcept;
252 * Get the parameter ranges of @a parameterId.
254 const ParameterRanges& getParameterRanges(uint32_t parameterId) const noexcept;
257 * Check if parameter @a parameterId is of output type.
259 bool isParameterOutput(uint32_t parameterId) const noexcept;
262 * Get the MIDI program at @a index.
264 * @see getMidiProgramName()
266 const MidiProgramData& getMidiProgramData(uint32_t index) const noexcept;
269 * Get the custom data set at @a index.
271 * @see getCustomDataCount() and setCustomData()
273 const CustomData& getCustomData(uint32_t index) const noexcept;
276 * Get the complete plugin chunk data into @a dataPtr.
278 * @note Make sure to verify the plugin supports chunks before calling this function!
279 * @return The size of the chunk or 0 if invalid.
281 * @see setChunkData()
283 virtual std::size_t getChunkData(void** dataPtr) noexcept;
285 // -------------------------------------------------------------------
286 // Information (per-plugin data)
289 * Get the plugin available options.
291 * @see PluginOptions, getOptions() and setOption()
293 virtual uint getOptionsAvailable() const noexcept;
296 * Get the current parameter value of @a parameterId.
298 virtual float getParameterValue(uint32_t parameterId) const noexcept;
301 * Get the scalepoint @a scalePointId value of the parameter @a parameterId.
303 virtual float getParameterScalePointValue(uint32_t parameterId, uint32_t scalePointId) const noexcept;
306 * Get the plugin's label (URI for LV2 plugins).
308 CARLA_PLUGIN_WARN_UNUSED_RESULT
309 virtual bool getLabel(char* strBuf) const noexcept;
312 * Get the plugin's maker.
314 CARLA_PLUGIN_WARN_UNUSED_RESULT
315 virtual bool getMaker(char* strBuf) const noexcept;
318 * Get the plugin's copyright/license.
320 CARLA_PLUGIN_WARN_UNUSED_RESULT
321 virtual bool getCopyright(char* strBuf) const noexcept;
324 * Get the plugin's (real) name.
326 * @see getName() and setName()
328 CARLA_PLUGIN_WARN_UNUSED_RESULT
329 virtual bool getRealName(char* strBuf) const noexcept;
332 * Get the name of the parameter @a parameterId.
334 CARLA_PLUGIN_WARN_UNUSED_RESULT
335 virtual bool getParameterName(uint32_t parameterId, char* strBuf) const noexcept;
338 * Get the symbol of the parameter @a parameterId.
340 CARLA_PLUGIN_WARN_UNUSED_RESULT
341 virtual bool getParameterSymbol(uint32_t parameterId, char* strBuf) const noexcept;
344 * Get the custom text of the parameter @a parameterId.
345 * @see PARAMETER_USES_CUSTOM_TEXT
347 CARLA_PLUGIN_WARN_UNUSED_RESULT
348 virtual bool getParameterText(uint32_t parameterId, char* strBuf) noexcept;
351 * Get the unit of the parameter @a parameterId.
353 CARLA_PLUGIN_WARN_UNUSED_RESULT
354 virtual bool getParameterUnit(uint32_t parameterId, char* strBuf) const noexcept;
357 * Get the comment (documentation) of the parameter @a parameterId.
359 CARLA_PLUGIN_WARN_UNUSED_RESULT
360 virtual bool getParameterComment(uint32_t parameterId, char* strBuf) const noexcept;
363 * Get the group name of the parameter @a parameterId.
364 * @note The group name is prefixed by a unique symbol and ":".
366 CARLA_PLUGIN_WARN_UNUSED_RESULT
367 virtual bool getParameterGroupName(uint32_t parameterId, char* strBuf) const noexcept;
370 * Get the scalepoint @a scalePointId label of the parameter @a parameterId.
372 CARLA_PLUGIN_WARN_UNUSED_RESULT
373 virtual bool getParameterScalePointLabel(uint32_t parameterId, uint32_t scalePointId, char* strBuf) const noexcept;
376 * Get the current parameter value of @a parameterId.
377 * @a parameterId can be negative to allow internal parameters.
378 * @see InternalParametersIndex
380 float getInternalParameterValue(int32_t parameterId) const noexcept;
383 * Get the name of the program at @a index.
385 CARLA_PLUGIN_WARN_UNUSED_RESULT
386 bool getProgramName(uint32_t index, char* strBuf) const noexcept;
389 * Get the name of the MIDI program at @a index.
391 * @see getMidiProgramInfo()
393 CARLA_PLUGIN_WARN_UNUSED_RESULT
394 bool getMidiProgramName(uint32_t index, char* strBuf) const noexcept;
397 * Get information about the plugin's parameter count.
398 * This is used to check how many input, output and total parameters are available.
400 * @note Some parameters might not be input or output (ie, invalid).
402 * @see getParameterCount()
404 void getParameterCountInfo(uint32_t& ins, uint32_t& outs) const noexcept;
406 // -------------------------------------------------------------------
407 // Set data (state)
410 * Tell the plugin to prepare for save.
411 * @param temporary Wherever we are saving into a temporary location
412 * (for duplication, renaming or similar)
414 virtual void prepareForSave(bool temporary);
417 * Reset all possible parameters.
419 virtual void resetParameters() noexcept;
422 * Randomize all possible parameters.
424 virtual void randomizeParameters() noexcept;
427 * Get the plugin's save state.
428 * The plugin will automatically call prepareForSave() if requested.
430 * @see loadStateSave()
432 const CarlaStateSave& getStateSave(bool callPrepareForSave = true);
435 * Get the plugin's save state.
437 * @see getStateSave()
439 void loadStateSave(const CarlaStateSave& stateSave);
442 * Save the current plugin state to @a filename.
444 * @see loadStateFromFile()
446 bool saveStateToFile(const char* filename);
449 * Save the plugin state from @a filename.
451 * @see saveStateToFile()
453 bool loadStateFromFile(const char* filename);
455 #ifndef CARLA_PLUGIN_ONLY_BRIDGE
457 * Export this plugin as its own LV2 plugin, using a carla wrapper around it for the LV2 functionality.
459 bool exportAsLV2(const char* lv2path);
460 #endif
462 // -------------------------------------------------------------------
463 // Set data (internal stuff)
466 * Set the plugin's id to @a newId.
468 * @see getId()
469 * @note RT call
471 virtual void setId(uint newId) noexcept;
474 * Set the plugin's name to @a newName.
476 * @see getName() and getRealName()
478 virtual void setName(const char* newName);
481 * Set a plugin's option.
483 * @see getOptions() and getOptionsAvailable()
485 virtual void setOption(uint option, bool yesNo, bool sendCallback);
488 * Enable or disable the plugin according to @a yesNo.
489 * When a plugin is disabled, it will never be processed or managed in any way.
491 * @see isEnabled()
493 void setEnabled(bool yesNo) noexcept;
496 * Set plugin as active according to @a active.
498 * @param sendOsc Send message change over OSC
499 * @param sendCallback Send message change to registered callback
501 void setActive(bool active, bool sendOsc, bool sendCallback) noexcept;
503 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
505 * Set the plugin's dry/wet signal value to @a value.
506 * @a value must be between 0.0 and 1.0.
508 * @param sendOsc Send message change over OSC
509 * @param sendCallback Send message change to registered callback
511 void setDryWet(float value, bool sendOsc, bool sendCallback) noexcept;
514 * Set the plugin's output volume to @a value.
515 * @a value must be between 0.0 and 1.27.
517 * @param sendOsc Send message change over OSC
518 * @param sendCallback Send message change to registered callback
520 void setVolume(float value, bool sendOsc, bool sendCallback) noexcept;
523 * Set the plugin's output left balance value to @a value.
524 * @a value must be between -1.0 and 1.0.
526 * @param sendOsc Send message change over OSC
527 * @param sendCallback Send message change to registered callback
529 * @note Pure-Stereo plugins only!
531 void setBalanceLeft(float value, bool sendOsc, bool sendCallback) noexcept;
534 * Set the plugin's output right balance value to @a value.
535 * @a value must be between -1.0 and 1.0.
537 * @param sendOsc Send message change over OSC
538 * @param sendCallback Send message change to registered callback
540 * @note Pure-Stereo plugins only!
542 void setBalanceRight(float value, bool sendOsc, bool sendCallback) noexcept;
545 * Set the plugin's output panning value to @a value.
546 * @a value must be between -1.0 and 1.0.
548 * @param sendOsc Send message change over OSC
549 * @param sendCallback Send message change to registered callback
551 * @note Force-Stereo plugins only!
553 void setPanning(float value, bool sendOsc, bool sendCallback) noexcept;
556 * Overloaded functions, to be called from within RT context only.
558 void setDryWetRT(float value, bool sendCallbackLater) noexcept;
559 void setVolumeRT(float value, bool sendCallbackLater) noexcept;
560 void setBalanceLeftRT(float value, bool sendCallbackLater) noexcept;
561 void setBalanceRightRT(float value, bool sendCallbackLater) noexcept;
562 void setPanningRT(float value, bool sendCallbackLater) noexcept;
563 #endif // ! BUILD_BRIDGE_ALTERNATIVE_ARCH
566 * Set the plugin's midi control channel.
568 * @param sendOsc Send message change over OSC
569 * @param sendCallback Send message change to registered callback
571 virtual void setCtrlChannel(int8_t channel, bool sendOsc, bool sendCallback) noexcept;
573 // -------------------------------------------------------------------
574 // Set data (plugin-specific stuff)
577 * Set a plugin's parameter value.
579 * @param parameterId The parameter to change
580 * @param value The new parameter value, must be within the parameter's range
581 * @param sendGui Send message change to plugin's custom GUI, if any
582 * @param sendOsc Send message change over OSC
583 * @param sendCallback Send message change to registered callback
585 * @see getParameterValue()
587 virtual void setParameterValue(uint32_t parameterId, float value, bool sendGui, bool sendOsc, bool sendCallback) noexcept;
590 * Overloaded function, to be called from within RT context only.
592 virtual void setParameterValueRT(uint32_t parameterId, float value, uint32_t frameOffset, bool sendCallbackLater) noexcept;
595 * Set a plugin's parameter value, including internal parameters.
596 * @a rindex can be negative to allow internal parameters change (as defined in InternalParametersIndex).
598 * @see setParameterValue()
599 * @see setActive()
600 * @see setDryWet()
601 * @see setVolume()
602 * @see setBalanceLeft()
603 * @see setBalanceRight()
605 void setParameterValueByRealIndex(int32_t rindex, float value, bool sendGui, bool sendOsc, bool sendCallback) noexcept;
608 * Set parameter's @a parameterId MIDI channel to @a channel.
609 * @a channel must be between 0 and 15.
611 virtual void setParameterMidiChannel(uint32_t parameterId, uint8_t channel, bool sendOsc, bool sendCallback) noexcept;
614 * Set parameter's @a parameterId mapped control index to @a index.
615 * @see ParameterData::mappedControlIndex
617 virtual void setParameterMappedControlIndex(uint32_t parameterId, int16_t index,
618 bool sendOsc, bool sendCallback, bool reconfigureNow) noexcept;
621 * Set parameter's @a parameterId mapped range to @a minimum and @a maximum.
623 virtual void setParameterMappedRange(uint32_t parameterId, float minimum, float maximum,
624 bool sendOsc, bool sendCallback) noexcept;
627 * Add a custom data set.
628 * If @a key already exists, its current value will be swapped with @a value.
630 * @param type Type of data used in @a value.
631 * @param key A key identifying this data set.
632 * @param value The value of the data set, of type @a type.
633 * @param sendGui Send message change to plugin's custom GUI, if any
635 * @see getCustomDataCount() and getCustomData()
637 virtual void setCustomData(const char* type, const char* key, const char* value, bool sendGui);
640 * Set the complete chunk data as @a data.
642 * @see getChunkData()
644 * @note Make sure to verify the plugin supports chunks before calling this function
646 virtual void setChunkData(const void* data, std::size_t dataSize);
649 * Change the current plugin program to @a index.
651 * If @a index is negative the plugin's program will be considered unset.
652 * The plugin's default parameter values will be updated when this function is called.
654 * @param index New program index to use
655 * @param sendGui Send message change to plugin's custom GUI, if any
656 * @param sendOsc Send message change over OSC
657 * @param sendCallback Send message change to registered callback
659 virtual void setProgram(int32_t index, bool sendGui, bool sendOsc, bool sendCallback, bool doingInit = false) noexcept;
662 * Change the current MIDI plugin program to @a index.
664 * If @a index is negative the plugin's program will be considered unset.
665 * The plugin's default parameter values will be updated when this function is called.
667 * @param index New program index to use
668 * @param sendGui Send message change to plugin's custom GUI, if any
669 * @param sendOsc Send message change over OSC
670 * @param sendCallback Send message change to registered callback
672 virtual void setMidiProgram(int32_t index, bool sendGui, bool sendOsc, bool sendCallback, bool doingInit = false) noexcept;
675 * This is an overloaded call to setMidiProgram().
676 * It changes the current MIDI program using @a bank and @a program values instead of index.
678 void setMidiProgramById(uint32_t bank, uint32_t program, bool sendGui, bool sendOsc, bool sendCallback) noexcept;
681 * Overloaded functions, to be called from within RT context only.
683 virtual void setProgramRT(uint32_t index, bool sendCallbackLater) noexcept;
684 virtual void setMidiProgramRT(uint32_t index, bool sendCallbackLater) noexcept;
686 // -------------------------------------------------------------------
687 // Plugin state
690 * Reload the plugin's entire state (including programs).
691 * The plugin will be disabled during this call.
693 virtual void reload() = 0;
696 * Reload the plugin's programs state.
698 virtual void reloadPrograms(bool doInit);
700 // -------------------------------------------------------------------
701 // Plugin processing
703 protected:
705 * Plugin activate call.
707 virtual void activate() noexcept;
710 * Plugin activate call.
712 virtual void deactivate() noexcept;
714 public:
716 * Plugin process call.
718 virtual void process(const float* const* audioIn, float** audioOut,
719 const float* const* cvIn, float** cvOut, uint32_t frames) = 0;
722 * Tell the plugin the current buffer size changed.
724 virtual void bufferSizeChanged(uint32_t newBufferSize);
727 * Tell the plugin the current sample rate changed.
729 virtual void sampleRateChanged(double newSampleRate);
732 * Tell the plugin the current offline mode changed.
734 virtual void offlineModeChanged(bool isOffline);
736 // -------------------------------------------------------------------
737 // Misc
740 * Idle function (non-UI), called at regular intervals.
741 * @note: This function is NOT called from the main thread.
743 virtual void idle();
746 * Try to lock the plugin's master mutex.
747 * @param forcedOffline When true, always locks and returns true
749 bool tryLock(bool forcedOffline) noexcept;
752 * Unlock the plugin's master mutex.
754 void unlock() noexcept;
756 // -------------------------------------------------------------------
757 // Plugin buffers
760 * Initialize all RT buffers of the plugin.
762 virtual void initBuffers() const noexcept;
765 * Delete and clear all RT buffers.
767 virtual void clearBuffers() noexcept;
769 // -------------------------------------------------------------------
770 // OSC stuff
773 * Handle an OSC message.
774 * FIXME
776 virtual void handleOscMessage(const char* method,
777 int argc,
778 const void* argv,
779 const char* types,
780 void* msg);
782 // -------------------------------------------------------------------
783 // MIDI events
786 * Send a single midi note to be processed in the next audio callback.
787 * A note with 0 velocity means note-off.
788 * @note Non-RT call
790 void sendMidiSingleNote(uint8_t channel, uint8_t note, uint8_t velo,
791 bool sendGui, bool sendOsc, bool sendCallback);
793 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
795 * Send all midi notes off to the host callback.
796 * This doesn't send the actual MIDI All-Notes-Off event, but 128 note-offs instead (IFF ctrlChannel is valid).
797 * @note RT call
799 void postponeRtAllNotesOff();
800 #endif
802 // -------------------------------------------------------------------
803 // UI Stuff
806 * Set a custom title for the plugin UI window created by Carla.
808 virtual void setCustomUITitle(const char* title) noexcept;
811 * Show (or hide) the plugin's custom UI according to @a yesNo.
812 * This function is always called from the main thread.
814 virtual void showCustomUI(bool yesNo);
817 * Embed the plugin's custom UI to the system pointer @a ptr.
818 * This function is always called from the main thread.
819 * @note This is very experimental and subject to change at this point
821 virtual void* embedCustomUI(void* ptr);
824 * UI idle function, called at regular intervals.
825 * This function is only called from the main thread if PLUGIN_NEEDS_UI_MAIN_THREAD is set.
826 * @note This function may sometimes be called even if the UI is not visible yet.
828 virtual void uiIdle();
831 * Tell the UI a parameter has changed.
832 * @see uiIdle
834 virtual void uiParameterChange(uint32_t index, float value) noexcept;
837 * Tell the UI the current program has changed.
838 * @see uiIdle
840 virtual void uiProgramChange(uint32_t index) noexcept;
843 * Tell the UI the current midi program has changed.
844 * @see uiIdle
846 virtual void uiMidiProgramChange(uint32_t index) noexcept;
849 * Tell the UI a note has been pressed.
850 * @see uiIdle
852 virtual void uiNoteOn(uint8_t channel, uint8_t note, uint8_t velo) noexcept;
855 * Tell the UI a note has been released.
856 * @see uiIdle
858 virtual void uiNoteOff(uint8_t channel, uint8_t note) noexcept;
860 // -------------------------------------------------------------------
861 // Helper functions
864 * Get the plugin's engine, as passed in the constructor.
866 CarlaEngine* getEngine() const noexcept;
869 * Get the plugin's engine client.
871 CarlaEngineClient* getEngineClient() const noexcept;
874 * Get a plugin's audio input port.
876 CarlaEngineAudioPort* getAudioInPort(uint32_t index) const noexcept;
879 * Get a plugin's audio output port.
881 CarlaEngineAudioPort* getAudioOutPort(uint32_t index) const noexcept;
884 * Get a plugin's CV input port.
886 CarlaEngineCVPort* getCVInPort(uint32_t index) const noexcept;
889 * Get a plugin's CV output port.
891 CarlaEngineCVPort* getCVOutPort(uint32_t index) const noexcept;
894 * Get the plugin's default event input port.
896 CarlaEngineEventPort* getDefaultEventInPort() const noexcept;
899 * Get the plugin's default event output port.
901 CarlaEngineEventPort* getDefaultEventOutPort() const noexcept;
903 #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
905 * Check if the plugin is interested on MIDI learn, and if so, map this event to the parameter that wants it.
906 * Event MUST be of control type and not have been handled before.
908 void checkForMidiLearn(EngineEvent& event) noexcept;
909 #endif
912 * Get the plugin's type native handle.
913 * This will be LADSPA_Handle, LV2_Handle, etc.
915 virtual void* getNativeHandle() const noexcept;
918 * Get the plugin's type native descriptor.
919 * This will be LADSPA_Descriptor, DSSI_Descriptor, LV2_Descriptor, AEffect, etc.
921 virtual const void* getNativeDescriptor() const noexcept;
924 * Get the plugin UI bridge process Id.
926 virtual uintptr_t getUiBridgeProcessId() const noexcept;
928 // -------------------------------------------------------------------
931 * Get the plugin's patchbay nodeId.
932 * @see setPatchbayNodeId()
934 uint32_t getPatchbayNodeId() const noexcept;
937 * Set the plugin's patchbay nodeId.
938 * @see getPatchbayNodeId()
940 void setPatchbayNodeId(uint32_t nodeId) noexcept;
942 // -------------------------------------------------------------------
943 // Plugin initializers
946 * Get a plugin's binary type.
947 * This is always BINARY_NATIVE unless the plugin is a bridge.
949 virtual BinaryType getBinaryType() const noexcept
951 return BINARY_NATIVE;
955 * Handy function required by CarlaEngine::clonePlugin().
957 virtual const void* getExtraStuff() const noexcept
959 return nullptr;
962 #ifndef DOXYGEN
963 struct Initializer {
964 CarlaEngine* const engine;
965 const uint id;
966 const char* const filename;
967 const char* const name;
968 const char* const label;
969 const int64_t uniqueId;
970 const uint options; // see PluginOptions
973 static CarlaPluginPtr newBridge(const Initializer& init,
974 BinaryType btype, PluginType ptype,
975 const char* binaryArchName, const char* bridgeBinary);
977 #ifndef CARLA_PLUGIN_ONLY_BRIDGE
978 static CarlaPluginPtr newNative(const Initializer& init);
980 static CarlaPluginPtr newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* rdfDescriptor);
981 static CarlaPluginPtr newDSSI(const Initializer& init);
982 static CarlaPluginPtr newLV2(const Initializer& init);
983 static CarlaPluginPtr newVST2(const Initializer& init);
984 static CarlaPluginPtr newVST3(const Initializer& init);
985 static CarlaPluginPtr newAU(const Initializer& init);
986 static CarlaPluginPtr newJSFX(const Initializer& init);
987 static CarlaPluginPtr newCLAP(const Initializer& init);
989 static CarlaPluginPtr newJuce(const Initializer& init, const char* format);
990 static CarlaPluginPtr newFluidSynth(const Initializer& init, PluginType ptype, bool use16Outs);
991 static CarlaPluginPtr newSFZero(const Initializer& init);
993 static CarlaPluginPtr newJackApp(const Initializer& init);
994 #endif
995 #endif
997 // -------------------------------------------------------------------
999 protected:
1001 * Internal data, for CarlaPlugin subclasses only.
1003 struct ProtectedData;
1004 ProtectedData* const pData;
1006 // -------------------------------------------------------------------
1007 // Internal helper functions
1009 protected:
1011 * Clone/copy files from another LV2 plugin into this one..
1013 virtual void cloneLV2Files(const CarlaPlugin& other);
1016 * Call LV2 restore.
1017 * @param temporary Wherever we are saving into a temporary location
1018 * (for duplication, renaming or similar)
1020 virtual void restoreLV2State(bool temporary) noexcept;
1023 * Allow engine to signal that plugin will be deleted soon.
1025 virtual void prepareForDeletion() noexcept;
1028 * Give plugin bridges a change to update their custom data sets.
1030 virtual void waitForBridgeSaveSignal() noexcept;
1032 // -------------------------------------------------------------------
1033 // Helper classes
1036 * Fully disable plugin in scope and also its engine client.
1037 * May wait-block on constructor for plugin process to end.
1039 class ScopedDisabler
1041 public:
1042 ScopedDisabler(CarlaPlugin* plugin) noexcept;
1043 ~ScopedDisabler() noexcept;
1045 private:
1046 CarlaPlugin* const fPlugin;
1047 bool fWasEnabled;
1049 CARLA_PREVENT_HEAP_ALLOCATION
1050 CARLA_DECLARE_NON_COPYABLE(ScopedDisabler)
1054 * Lock the plugin's own run/process call.
1055 * Plugin will still work as normal, but output only silence.
1056 * On destructor needsReset flag might be set if the plugin might have missed some events.
1058 class ScopedSingleProcessLocker
1060 public:
1061 ScopedSingleProcessLocker(CarlaPlugin* plugin, bool block) noexcept;
1062 ~ScopedSingleProcessLocker() noexcept;
1064 private:
1065 CarlaPlugin* const fPlugin;
1066 const bool fBlock;
1068 CARLA_PREVENT_HEAP_ALLOCATION
1069 CARLA_DECLARE_NON_COPYABLE(ScopedSingleProcessLocker)
1072 friend class CarlaEngine;
1073 friend class CarlaEngineBridge;
1074 CARLA_DECLARE_NON_COPYABLE(CarlaPlugin)
1077 /**@}*/
1079 // -----------------------------------------------------------------------
1081 CARLA_BACKEND_END_NAMESPACE
1083 #endif // CARLA_PLUGIN_HPP_INCLUDED