Browse Source

Sample for carla-plugin

tags/1.9.8
falkTX 7 years ago
parent
commit
e280b69cfd
2 changed files with 101 additions and 10 deletions
  1. +39
    -3
      source/plugin/Makefile
  2. +62
    -7
      source/plugin/carla-vst.cpp

+ 39
- 3
source/plugin/Makefile View File

@@ -103,7 +103,10 @@ ifeq ($(HAVE_X11),true)
ifeq ($(HAVE_PYQT),true)
TARGETS += \
$(BINDIR)/CarlaRack$(LIB_EXT) \
$(BINDIR)/CarlaRackFX$(LIB_EXT)
$(BINDIR)/CarlaRackFX$(LIB_EXT) \
$(BINDIR)/CarlaPatchbay$(LIB_EXT) \
$(BINDIR)/CarlaPatchbay16$(LIB_EXT) \
$(BINDIR)/CarlaPatchbayFX$(LIB_EXT)
endif
endif
endif
@@ -139,6 +142,21 @@ $(BINDIR)/CarlaRackFX$(LIB_EXT): $(OBJDIR)/carla-vst.cpp.rack-fx.o $(LIBS)
@echo "Linking CarlaRackFX$(LIB_EXT)"
@$(CXX) $< $(LIBS_START) $(LIBS) $(LIBS_END) $(SHARED) $(LINK_FLAGS) -o $@

$(BINDIR)/CarlaPatchbay$(LIB_EXT): $(OBJDIR)/carla-vst.cpp.patchbay-syn.o $(LIBS)
-@mkdir -p $(BINDIR)
@echo "Linking CarlaPatchbay$(LIB_EXT)"
@$(CXX) $< $(LIBS_START) $(LIBS) $(LIBS_END) $(SHARED) $(LINK_FLAGS) -o $@

$(BINDIR)/CarlaPatchbay16$(LIB_EXT): $(OBJDIR)/carla-vst.cpp.patchbay-syn16.o $(LIBS)
-@mkdir -p $(BINDIR)
@echo "Linking CarlaPatchbay16$(LIB_EXT)"
@$(CXX) $< $(LIBS_START) $(LIBS) $(LIBS_END) $(SHARED) $(LINK_FLAGS) -o $@

$(BINDIR)/CarlaPatchbayFX$(LIB_EXT): $(OBJDIR)/carla-vst.cpp.patchbay-fx.o $(LIBS)
-@mkdir -p $(BINDIR)
@echo "Linking CarlaPatchbayFX$(LIB_EXT)"
@$(CXX) $< $(LIBS_START) $(LIBS) $(LIBS_END) $(SHARED) $(LINK_FLAGS) -o $@

# ----------------------------------------------------------------------------------------------------------------------------

$(OBJDIR)/carla-lv2.cpp.o: carla-lv2.cpp
@@ -149,12 +167,27 @@ $(OBJDIR)/carla-lv2.cpp.o: carla-lv2.cpp
$(OBJDIR)/carla-vst.cpp.rack-fx.o: carla-vst.cpp
-@mkdir -p $(OBJDIR)
@echo "Compiling $< (RackFX)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_PLUGIN_SYNTH=0 -c -o $@
@$(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_PLUGIN_PATCHBAY=0 -DCARLA_PLUGIN_SYNTH=0 -c -o $@

$(OBJDIR)/carla-vst.cpp.rack-syn.o: carla-vst.cpp
-@mkdir -p $(OBJDIR)
@echo "Compiling $< (RackSynth)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_PLUGIN_SYNTH=1 -c -o $@
@$(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_PLUGIN_PATCHBAY=0 -DCARLA_PLUGIN_SYNTH=1 -c -o $@

$(OBJDIR)/carla-vst.cpp.patchbay-fx.o: carla-vst.cpp
-@mkdir -p $(OBJDIR)
@echo "Compiling $< (PatchbayFX)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_PLUGIN_PATCHBAY=1 -DCARLA_PLUGIN_SYNTH=0 -c -o $@

$(OBJDIR)/carla-vst.cpp.patchbay-syn.o: carla-vst.cpp
-@mkdir -p $(OBJDIR)
@echo "Compiling $< (PatchbaySynth)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_PLUGIN_PATCHBAY=1 -DCARLA_PLUGIN_SYNTH=1 -c -o $@

$(OBJDIR)/carla-vst.cpp.patchbay-syn16.o: carla-vst.cpp
-@mkdir -p $(OBJDIR)
@echo "Compiling $< (PatchbaySynth 16ch)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_PLUGIN_PATCHBAY=1 -DCARLA_PLUGIN_SYNTH=1 -DCARLA_PLUGIN_16CH -c -o $@

# ----------------------------------------------------------------------------------------------------------------------------

@@ -185,6 +218,9 @@ $(OBJDIR)/carla-lv2-export.cpp.o: carla-lv2-export.cpp

-include $(OBJDIR)/carla-lv2.cpp.d
-include $(OBJDIR)/carla-lv2-export.cpp.d
-include $(OBJDIR)/carla-vst.cpp.patchbay-fx.d
-include $(OBJDIR)/carla-vst.cpp.patchbay-syn.d
-include $(OBJDIR)/carla-vst.cpp.patchbay-syn16.d
-include $(OBJDIR)/carla-vst.cpp.rack-fx.d
-include $(OBJDIR)/carla-vst.cpp.rack-syn.d



+ 62
- 7
source/plugin/carla-vst.cpp View File

@@ -15,6 +15,10 @@
* For a full copy of the GNU General Public License see the doc/GPL.txt file.
*/

#ifndef CARLA_PLUGIN_PATCHBAY
# error CARLA_PLUGIN_PATCHBAY undefined
#endif

#ifndef CARLA_PLUGIN_SYNTH
# error CARLA_PLUGIN_SYNTH undefined
#endif
@@ -727,15 +731,25 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
if (d_lastSampleRate <= 0.0)
d_lastSampleRate = 44100.0;

const NativePluginDescriptor* pluginDesc = nullptr;
#if CARLA_PLUGIN_PATCHBAY
# ifdef CARLA_PLUGIN_16CH
const char* const pluginLabel = "carlapatchbay16";
# else
const char* const pluginLabel = "carlapatchbay";
# endif
#else
const char* const pluginLabel = "carlarack";
#endif

PluginListManager& plm(PluginListManager::getInstance());
const NativePluginDescriptor* pluginDesc = nullptr;

for (LinkedList<const NativePluginDescriptor*>::Itenerator it = plm.descs.begin2(); it.valid(); it.next())
{
const NativePluginDescriptor* const& tmpDesc(it.getValue(nullptr));
CARLA_SAFE_ASSERT_CONTINUE(tmpDesc != nullptr);

if (std::strcmp(tmpDesc->label, "carlarack") == 0)
if (std::strcmp(tmpDesc->label, pluginLabel) == 0)
{
pluginDesc = tmpDesc;
break;
@@ -783,10 +797,22 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
case effGetEffectName:
if (char* const cptr = (char*)ptr)
{
#if CARLA_PLUGIN_SYNTH
std::strncpy(cptr, "CarlaRack", 32);
#if CARLA_PLUGIN_PATCHBAY
# if CARLA_PLUGIN_SYNTH
# ifdef CARLA_PLUGIN_16CH
std::strncpy(cptr, "Carla-Patchbay16", 32);
# else
std::strncpy(cptr, "Carla-Patchbay", 32);
# endif
# else
std::strncpy(cptr, "Carla-PatchbayFX", 32);
# endif
#else
std::strncpy(cptr, "CarlaRackFX", 32);
# if CARLA_PLUGIN_SYNTH
std::strncpy(cptr, "Carla-Rack", 32);
# else
std::strncpy(cptr, "Carla-RackFX", 32);
# endif
#endif
return 1;
}
@@ -803,10 +829,22 @@ static intptr_t vst_dispatcherCallback(AEffect* effect, int32_t opcode, int32_t
case effGetProductString:
if (char* const cptr = (char*)ptr)
{
#if CARLA_PLUGIN_SYNTH
std::strncpy(cptr, "CarlaRack", 32);
#if CARLA_PLUGIN_PATCHBAY
# if CARLA_PLUGIN_SYNTH
# ifdef CARLA_PLUGIN_16CH
std::strncpy(cptr, "CarlaPatchbay16", 32);
# else
std::strncpy(cptr, "CarlaPatchbay", 32);
# endif
# else
std::strncpy(cptr, "CarlaPatchbayFX", 32);
# endif
#else
# if CARLA_PLUGIN_SYNTH
std::strncpy(cptr, "CarlaRack", 32);
# else
std::strncpy(cptr, "CarlaRackFX", 32);
# endif
#endif
return 1;
}
@@ -882,16 +920,33 @@ const AEffect* VSTPluginMain(audioMasterCallback audioMaster)

static const int32_t uniqueId = CCONST('C', 'r', 'l', 'a');
#if CARLA_PLUGIN_SYNTH
# if CARLA_PLUGIN_PATCHBAY
# ifdef CARLA_PLUGIN_16CH
effect->uniqueID = uniqueId+5;
# else
effect->uniqueID = uniqueId+4;
# endif
# else
effect->uniqueID = uniqueId+3;
# endif
#else
# if CARLA_PLUGIN_PATCHBAY
effect->uniqueID = uniqueId+2;
# else
effect->uniqueID = uniqueId+1;
# endif
#endif

// plugin fields
effect->numParams = 0;
effect->numPrograms = 0;
#ifdef CARLA_PLUGIN_16CH
effect->numInputs = 16;
effect->numOutputs = 16;
#else
effect->numInputs = 2;
effect->numOutputs = 2;
#endif

// plugin flags
effect->flags |= effFlagsCanReplacing;


Loading…
Cancel
Save