Browse Source

LV2: Add turtle-writer program

pull/22/head
reuk 4 years ago
parent
commit
1d04669410
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
4 changed files with 97 additions and 0 deletions
  1. +2
    -0
      CMakeLists.txt
  2. +2
    -0
      modules/CMakeLists.txt
  3. +22
    -0
      modules/juce_audio_plugin_client/CMakeLists.txt
  4. +71
    -0
      modules/juce_audio_plugin_client/LV2/juce_LV2TurtleDumpProgram.cpp

+ 2
- 0
CMakeLists.txt View File

@@ -148,3 +148,5 @@ install(FILES "${JUCE_BINARY_DIR}/JUCEConfigVersion.cmake"
"${JUCE_CMAKE_UTILS_DIR}/copyDir.cmake"
"${JUCE_CMAKE_UTILS_DIR}/juce_runtime_arch_detection.cpp"
DESTINATION "${JUCE_INSTALL_DESTINATION}")

install(EXPORT LV2_HELPER NAMESPACE juce:: DESTINATION "${JUCE_INSTALL_DESTINATION}")

+ 2
- 0
modules/CMakeLists.txt View File

@@ -37,3 +37,5 @@ juce_add_modules(
juce_osc
juce_product_unlocking
juce_video)

add_subdirectory(juce_audio_plugin_client)

+ 22
- 0
modules/juce_audio_plugin_client/CMakeLists.txt View File

@@ -0,0 +1,22 @@
# ==============================================================================
#
# This file is part of the JUCE 7 technical preview.
# Copyright (c) 2022 - Raw Material Software Limited
#
# You may use this code under the terms of the GPL v3
# (see www.gnu.org/licenses).
#
# For the technical preview this file cannot be licensed commercially.
#
# JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
# EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
# DISCLAIMED.
#
# ==============================================================================

add_executable(juce_lv2_helper LV2/juce_LV2TurtleDumpProgram.cpp)
add_executable(juce::juce_lv2_helper ALIAS juce_lv2_helper)
target_compile_features(juce_lv2_helper PRIVATE cxx_std_14)
set_target_properties(juce_lv2_helper PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
target_link_libraries(juce_lv2_helper PRIVATE ${CMAKE_DL_LIBS})
install(TARGETS juce_lv2_helper EXPORT LV2_HELPER DESTINATION "bin/JUCE-${JUCE_VERSION}")

+ 71
- 0
modules/juce_audio_plugin_client/LV2/juce_LV2TurtleDumpProgram.cpp View File

@@ -0,0 +1,71 @@
/*
==============================================================================
This file is part of the JUCE 7 technical preview.
Copyright (c) 2022 - Raw Material Software Limited
You may use this code under the terms of the GPL v3
(see www.gnu.org/licenses).
For the technical preview this file cannot be licensed commercially.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#ifdef _WIN32
#include <windows.h>
HMODULE dlopen (const char* filename, int) { return LoadLibrary (filename); }
FARPROC dlsym (HMODULE handle, const char* name) { return GetProcAddress (handle, name); }
enum { RTLD_LAZY = 0 };
#else
#include <dlfcn.h>
#endif
#include <cstdint>
// Replicating some of the LV2 header here so that we don't have to set up any
// custom include paths for this file.
// Normally this would be a bad idea, but the LV2 API has to keep these definitions
// in order to remain backwards-compatible.
extern "C"
{
typedef struct LV2_Descriptor
{
const void* a;
const void* b;
const void* c;
const void* d;
const void* e;
const void* f;
const void* g;
const void* (*extension_data)(const char* uri);
} LV2_Descriptor;
}
int main (int argc, const char** argv)
{
if (argc != 2)
return 1;
const auto* libraryPath = argv[1];
struct RecallFeature
{
int (*doRecall) (const char*);
};
if (auto* handle = dlopen (libraryPath, RTLD_LAZY))
if (auto* getDescriptor = reinterpret_cast<const LV2_Descriptor* (*) (uint32_t)> (dlsym (handle, "lv2_descriptor")))
if (auto* descriptor = getDescriptor (0))
if (auto* extensionData = descriptor->extension_data)
if (auto* recallFeature = reinterpret_cast<const RecallFeature*> (extensionData ("https://lv2-extensions.juce.com/turtle_recall")))
if (auto* doRecall = recallFeature->doRecall)
return doRecall (libraryPath);
return 1;
}

Loading…
Cancel
Save