diff --git a/source/tests/CarlaUtils.cpp b/source/tests/CarlaUtils.cpp index bc0609cf8..1a00e0632 100644 --- a/source/tests/CarlaUtils.cpp +++ b/source/tests/CarlaUtils.cpp @@ -33,6 +33,7 @@ #include "CarlaLadspaUtils.hpp" #include "CarlaDssiUtils.hpp" #include "CarlaLv2Utils.hpp" +#include "CarlaVstUtils.hpp" // used in dssi utils #include "juce_core.h" @@ -56,6 +57,7 @@ // #include "JucePluginWindow.hpp" +#if 0 // ----------------------------------------------------------------------- static void test_CarlaUtils() noexcept @@ -576,7 +578,7 @@ static void test_CarlaLv2Utils() noexcept delete lv2_rdf_new("http://calf.sourceforge.net/plugins/Reverb", true); delete lv2_rdf_new("http://www.openavproductions.com/fabla", true); delete lv2_rdf_new("http://invadarecords.com/plugins/lv2/meter", true); - //delete lv2_rdf_new("http://gareus.org/oss/lv2/meters#spectr30stereo", true); + delete lv2_rdf_new("http://gareus.org/oss/lv2/meters#spectr30stereo", true); delete lv2_rdf_new("http://plugin.org.uk/swh-plugins/revdelay", true); delete lv2_rdf_new("http://lv2plug.in/plugins/eg-scope#Stereo", true); delete lv2_rdf_new("http://kxstudio.sf.net/carla/plugins/carlarack", true); @@ -591,21 +593,42 @@ static void test_CarlaLv2Utils() noexcept is_lv2_feature_supported("test1"); is_lv2_ui_feature_supported("test2"); } +#endif // ----------------------------------------------------------------------- -// main -int main() +static intptr_t test_vst_dispatcher(AEffect*, int, int, intptr_t, void*, float) { - test_CarlaUtils(); - test_CarlaMathUtils(); + return 0; +} - test_CarlaBackendUtils(); - test_CarlaEngineUtils(); +static void test_CarlaVstUtils() noexcept +{ + AEffect effect; + carla_zeroStruct(effect); + effect.dispatcher = test_vst_dispatcher; - test_CarlaLadspaUtils(); - test_CarlaDssiUtils(); - test_CarlaLv2Utils(); + vstPluginCanDo(&effect, "test"); + carla_stdout(vstEffectOpcode2str(effOpen)); + carla_stdout(vstMasterOpcode2str(audioMasterAutomate)); +} + +// ----------------------------------------------------------------------- +// main + +int main() +{ + // already tested, skip for now +// test_CarlaUtils(); +// test_CarlaMathUtils(); +// +// test_CarlaBackendUtils(); +// test_CarlaEngineUtils(); +// +// test_CarlaLadspaUtils(); +// test_CarlaDssiUtils(); +// test_CarlaLv2Utils(); + test_CarlaVstUtils(); return 0; } diff --git a/source/utils/CarlaVstUtils.hpp b/source/utils/CarlaVstUtils.hpp index 513db7e15..6bd05f488 100644 --- a/source/utils/CarlaVstUtils.hpp +++ b/source/utils/CarlaVstUtils.hpp @@ -1,6 +1,6 @@ /* * Carla VST utils - * Copyright (C) 2011-2013 Filipe Coelho + * Copyright (C) 2011-2014 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -143,6 +143,9 @@ typedef AEffect* (*VST_Function)(audioMasterCallback); static inline bool vstPluginCanDo(AEffect* const effect, const char* const feature) noexcept { + CARLA_SAFE_ASSERT_RETURN(effect != nullptr, false); + CARLA_SAFE_ASSERT_RETURN(feature != nullptr && feature[0] != '\0', false); + try { return (effect->dispatcher(effect, effCanDo, 0, 0, const_cast(feature), 0.0f) == 1); } CARLA_SAFE_EXCEPTION_RETURN("vstPluginCanDo", false); @@ -174,10 +177,8 @@ const char* vstEffectOpcode2str(const int32_t opcode) noexcept return "effGetParamDisplay"; case effGetParamName: return "effGetParamName"; -#if ! VST_FORCE_DEPRECATED - case effGetVu: + case DECLARE_VST_DEPRECATED(effGetVu): return "effGetVu"; -#endif case effSetSampleRate: return "effSetSampleRate"; case effSetBlockSize: @@ -190,24 +191,20 @@ const char* vstEffectOpcode2str(const int32_t opcode) noexcept return "effEditOpen"; case effEditClose: return "effEditClose"; -#if ! VST_FORCE_DEPRECATED - case effEditDraw: + case DECLARE_VST_DEPRECATED(effEditDraw): return "effEditDraw"; - case effEditMouse: + case DECLARE_VST_DEPRECATED(effEditMouse): return "effEditMouse"; - case effEditKey: + case DECLARE_VST_DEPRECATED(effEditKey): return "effEditKey"; -#endif case effEditIdle: return "effEditIdle"; -#if ! VST_FORCE_DEPRECATED - case effEditTop: + case DECLARE_VST_DEPRECATED(effEditTop): return "effEditTop"; - case effEditSleep: + case DECLARE_VST_DEPRECATED(effEditSleep): return "effEditSleep"; - case effIdentify: + case DECLARE_VST_DEPRECATED(effIdentify): return "effIdentify"; -#endif case effGetChunk: return "effGetChunk"; case effSetChunk: @@ -218,32 +215,26 @@ const char* vstEffectOpcode2str(const int32_t opcode) noexcept return "effCanBeAutomated"; case effString2Parameter: return "effString2Parameter"; -#if ! VST_FORCE_DEPRECATED - case effGetNumProgramCategories: + case DECLARE_VST_DEPRECATED(effGetNumProgramCategories): return "effGetNumProgramCategories"; -#endif case effGetProgramNameIndexed: return "effGetProgramNameIndexed"; -#if ! VST_FORCE_DEPRECATED - case effCopyProgram: + case DECLARE_VST_DEPRECATED(effCopyProgram): return "effCopyProgram"; - case effConnectInput: + case DECLARE_VST_DEPRECATED(effConnectInput): return "effConnectInput"; - case effConnectOutput: + case DECLARE_VST_DEPRECATED(effConnectOutput): return "effConnectOutput"; -#endif case effGetInputProperties: return "effGetInputProperties"; case effGetOutputProperties: return "effGetOutputProperties"; case effGetPlugCategory: return "effGetPlugCategory"; -#if ! VST_FORCE_DEPRECATED - case effGetCurrentPosition: + case DECLARE_VST_DEPRECATED(effGetCurrentPosition): return "effGetCurrentPosition"; - case effGetDestinationBuffer: + case DECLARE_VST_DEPRECATED(effGetDestinationBuffer): return "effGetDestinationBuffer"; -#endif case effOfflineNotify: return "effOfflineNotify"; case effOfflinePrepare: @@ -254,18 +245,14 @@ const char* vstEffectOpcode2str(const int32_t opcode) noexcept return "effProcessVarIo"; case effSetSpeakerArrangement: return "effSetSpeakerArrangement"; -#if ! VST_FORCE_DEPRECATED - case effSetBlockSizeAndSampleRate: + case DECLARE_VST_DEPRECATED(effSetBlockSizeAndSampleRate): return "effSetBlockSizeAndSampleRate"; -#endif case effSetBypass: return "effSetBypass"; case effGetEffectName: return "effGetEffectName"; -#if ! VST_FORCE_DEPRECATED - case effGetErrorText: + case DECLARE_VST_DEPRECATED(effGetErrorText): return "effGetErrorText"; -#endif case effGetVendorString: return "effGetVendorString"; case effGetProductString: @@ -278,20 +265,16 @@ const char* vstEffectOpcode2str(const int32_t opcode) noexcept return "effCanDo"; case effGetTailSize: return "effGetTailSize"; -#if ! VST_FORCE_DEPRECATED - case effIdle: + case DECLARE_VST_DEPRECATED(effIdle): return "effIdle"; - case effGetIcon: + case DECLARE_VST_DEPRECATED(effGetIcon): return "effGetIcon"; - case effSetViewPosition: + case DECLARE_VST_DEPRECATED(effSetViewPosition): return "effSetViewPosition"; -#endif case effGetParameterProperties: return "effGetParameterProperties"; -#if ! VST_FORCE_DEPRECATED - case effKeysRequired: + case DECLARE_VST_DEPRECATED(effKeysRequired): return "effKeysRequired"; -#endif case effGetVstVersion: return "effGetVstVersion"; case effEditKeyDown: @@ -357,32 +340,26 @@ const char* vstMasterOpcode2str(const int32_t opcode) noexcept return "audioMasterCurrentId"; case audioMasterIdle: return "audioMasterIdle"; -#if ! VST_FORCE_DEPRECATED - case audioMasterPinConnected: + case DECLARE_VST_DEPRECATED(audioMasterPinConnected): return "audioMasterPinConnected"; - case audioMasterWantMidi: + case DECLARE_VST_DEPRECATED(audioMasterWantMidi): return "audioMasterWantMidi"; -#endif case audioMasterGetTime: return "audioMasterGetTime"; case audioMasterProcessEvents: return "audioMasterProcessEvents"; -#if ! VST_FORCE_DEPRECATED - case audioMasterSetTime: + case DECLARE_VST_DEPRECATED(audioMasterSetTime): return "audioMasterSetTime"; - case audioMasterTempoAt: + case DECLARE_VST_DEPRECATED(audioMasterTempoAt): return "audioMasterTempoAt"; - case audioMasterGetNumAutomatableParameters: + case DECLARE_VST_DEPRECATED(audioMasterGetNumAutomatableParameters): return "audioMasterGetNumAutomatableParameters"; - case audioMasterGetParameterQuantization: + case DECLARE_VST_DEPRECATED(audioMasterGetParameterQuantization): return "audioMasterGetParameterQuantization"; -#endif case audioMasterIOChanged: return "audioMasterIOChanged"; -#if ! VST_FORCE_DEPRECATED - case audioMasterNeedIdle: + case DECLARE_VST_DEPRECATED(audioMasterNeedIdle): return "audioMasterNeedIdle"; -#endif case audioMasterSizeWindow: return "audioMasterSizeWindow"; case audioMasterGetSampleRate: @@ -393,14 +370,12 @@ const char* vstMasterOpcode2str(const int32_t opcode) noexcept return "audioMasterGetInputLatency"; case audioMasterGetOutputLatency: return "audioMasterGetOutputLatency"; -#if ! VST_FORCE_DEPRECATED - case audioMasterGetPreviousPlug: + case DECLARE_VST_DEPRECATED(audioMasterGetPreviousPlug): return "audioMasterGetPreviousPlug"; - case audioMasterGetNextPlug: + case DECLARE_VST_DEPRECATED(audioMasterGetNextPlug): return "audioMasterGetNextPlug"; - case audioMasterWillReplaceOrAccumulate: + case DECLARE_VST_DEPRECATED(audioMasterWillReplaceOrAccumulate): return "audioMasterWillReplaceOrAccumulate"; -#endif case audioMasterGetCurrentProcessLevel: return "audioMasterGetCurrentProcessLevel"; case audioMasterGetAutomationState: @@ -415,12 +390,10 @@ const char* vstMasterOpcode2str(const int32_t opcode) noexcept return "audioMasterOfflineGetCurrentPass"; case audioMasterOfflineGetCurrentMetaPass: return "audioMasterOfflineGetCurrentMetaPass"; -#if ! VST_FORCE_DEPRECATED - case audioMasterSetOutputSampleRate: + case DECLARE_VST_DEPRECATED(audioMasterSetOutputSampleRate): return "audioMasterSetOutputSampleRate"; - case audioMasterGetOutputSpeakerArrangement: + case DECLARE_VST_DEPRECATED(audioMasterGetOutputSpeakerArrangement): return "audioMasterGetOutputSpeakerArrangement"; -#endif case audioMasterGetVendorString: return "audioMasterGetVendorString"; case audioMasterGetProductString: @@ -429,20 +402,16 @@ const char* vstMasterOpcode2str(const int32_t opcode) noexcept return "audioMasterGetVendorVersion"; case audioMasterVendorSpecific: return "audioMasterVendorSpecific"; -#if ! VST_FORCE_DEPRECATED - case audioMasterSetIcon: + case DECLARE_VST_DEPRECATED(audioMasterSetIcon): return "audioMasterSetIcon"; -#endif case audioMasterCanDo: return "audioMasterCanDo"; case audioMasterGetLanguage: return "audioMasterGetLanguage"; -#if ! VST_FORCE_DEPRECATED - case audioMasterOpenWindow: + case DECLARE_VST_DEPRECATED(audioMasterOpenWindow): return "audioMasterOpenWindow"; - case audioMasterCloseWindow: + case DECLARE_VST_DEPRECATED(audioMasterCloseWindow): return "audioMasterCloseWindow"; -#endif case audioMasterGetDirectory: return "audioMasterGetDirectory"; case audioMasterUpdateDisplay: @@ -455,14 +424,12 @@ const char* vstMasterOpcode2str(const int32_t opcode) noexcept return "audioMasterOpenFileSelector"; case audioMasterCloseFileSelector: return "audioMasterCloseFileSelector"; -#if ! VST_FORCE_DEPRECATED - case audioMasterEditFile: + case DECLARE_VST_DEPRECATED(audioMasterEditFile): return "audioMasterEditFile"; - case audioMasterGetChunkFile: + case DECLARE_VST_DEPRECATED(audioMasterGetChunkFile): return "audioMasterGetChunkFile"; - case audioMasterGetInputSpeakerArrangement: + case DECLARE_VST_DEPRECATED(audioMasterGetInputSpeakerArrangement): return "audioMasterGetInputSpeakerArrangement"; -#endif default: return "unknown"; }