Skip to content

Commit

Permalink
[wip] Work on exposing vst3 plug-ins to OSCQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jan 1, 2024
1 parent a8d81b1 commit 0620702
Show file tree
Hide file tree
Showing 32 changed files with 676 additions and 268 deletions.
2 changes: 1 addition & 1 deletion cmake/avendish.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(AVND_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "")
find_package(Boost QUIET REQUIRED)
find_package(Threads QUIET)
find_package(fmt QUIET)

find_package(ossia QUIET)

set(AVENDISH_SOURCES
"${AVND_SOURCE_DIR}/include/avnd/concepts/all.hpp"
Expand Down
4 changes: 2 additions & 2 deletions cmake/avendish.sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function(avnd_target_setup AVND_FX_TARGET)
target_compile_options(
${AVND_FX_TARGET}
PUBLIC
-stdlib=libc++
# -stdlib=libc++
# -flto
-fno-stack-protector
-fno-ident
Expand Down Expand Up @@ -133,7 +133,7 @@ function(avnd_target_setup AVND_FX_TARGET)
)
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
target_link_libraries(${AVND_FX_TARGET} PRIVATE
-lc++
# -lc++
-Bsymbolic
# -flto
)
Expand Down
1 change: 0 additions & 1 deletion cmake/avendish.standalone.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "WAS.*")
endfunction()
return()
endif()
find_package(ossia)
find_package(GLEW QUIET)
find_package(glfw3 QUIET)
find_package(OpenGL QUIET)
Expand Down
44 changes: 43 additions & 1 deletion cmake/avendish.vst3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-non-virtual-dtor")
endif()

if(APPLE)
set(VST3_DYNAMIC_LIST "_BundleEntry\n_BundleExit\n_bundleEntry\n_bundleExit\n_GetPluginFactory")
elseif(WIN32)
set(VST3_DYNAMIC_LIST "AVND {\nlocal:*;\nglobal:InitDll;\nExitDll;\nGetPluginFactory;\n};\n")
else()
set(VST3_DYNAMIC_LIST "AVND {\n global:\n ModuleEntry;\n ModuleExit;\n GetPluginFactory;\n local:\n *;\n};\n")
endif()

file(WRITE "${CMAKE_BINARY_DIR}/vst3_symbols" "${VST3_DYNAMIC_LIST}")
add_subdirectory("${VST3_SDK_ROOT}" "${CMAKE_BINARY_DIR}/vst3_sdk")

function(avnd_make_vst3)
Expand Down Expand Up @@ -62,9 +71,42 @@ function(avnd_make_vst3)
${AVND_FX_TARGET}
PUBLIC
Avendish::Avendish_vst3
sdk_common pluginterfaces
$<LINK_GROUP:RESCAN,base,sdk_common,pluginterfaces>
DisableExceptions
)

if(UNIX AND NOT APPLE)
target_link_libraries(
${AVND_FX_TARGET}
PUBLIC
-Wl,-z,defs
)
endif()

if(APPLE)
target_link_libraries(${AVND_FX_TARGET} PRIVATE "-Wl, -exported_symbols_list ,${CMAKE_BINARY_DIR}/vst3_symbols")
elseif(WIN32)
if(NOT MSVC)
target_link_libraries(${AVND_FX_TARGET} PRIVATE "-Wl,--version-script=${CMAKE_BINARY_DIR}/vst3_symbols")
endif()
else()
target_link_libraries(${AVND_FX_TARGET} PRIVATE "-Wl,--version-script=${CMAKE_BINARY_DIR}/vst3_symbols")
endif()


if(TARGET ossia::ossia)
target_compile_definitions(
${AVND_FX_TARGET}
PUBLIC
AVND_ADD_OSCQUERY_BINDINGS=1
)
target_link_libraries(
${AVND_FX_TARGET}
PUBLIC
ossia::ossia
)
endif()

if(APPLE)
find_library(COREFOUNDATION_FK CoreFoundation)
target_link_libraries(
Expand Down
2 changes: 1 addition & 1 deletion examples/Helpers/Controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct Controls

struct range
{
halp::combo_pair<float> values[3]{{"Foo", 0.1f}, {"Bar", 0.5f}, {"Baz", 0.8f}};
halp::combo_pair<float> values[3]{{"A", 0.1f}, {"B", 0.5f}, {"C", 0.8f}};
int init{1}; // Bar
};

Expand Down
55 changes: 55 additions & 0 deletions examples/Raw/Interpolator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#pragma once

/* SPDX-License-Identifier: GPL-3.0-or-later */

#include <chrono>
#include <utility>
#include <vector>

namespace examples
{
struct ExponentialSmoothing
{
static constexpr auto name() { return "Exponential Smoothing"; }
static constexpr auto c_name() { return "avnd_expsmooth"; }
static constexpr auto uuid() { return "971739ae-14a3-4283-b0a0-96dbd367ce66"; }

struct
{
struct
{
static constexpr auto name() { return "Input"; }
double value{};
} in;

struct
{
static constexpr auto name() { return "Alpha"; }
struct range
{
double min{0.01}, max{1.}, init{0.5};
};
double value{range{}.init};
} alpha;
} inputs;

struct
{
struct
{
static constexpr auto name() { return "Output"; }
double value{};
} out;
} outputs;

double filtered{};
void operator()()
{
const double in = this->inputs.in.value;
const double a = this->inputs.alpha.value;

filtered = in * a + filtered * (1.0f - a);
outputs.out.value = filtered;
}
};
}
5 changes: 1 addition & 4 deletions include/avnd/binding/max/attributes_setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ struct attribute_register<Processor, T>

if(from_atoms{ac, av}(field.value))
{
if constexpr(requires { field.update(obj); })
{
field.update(obj);
}
if_possible(field.update(obj));
}
}
return MAX_ERR_NONE;
Expand Down
82 changes: 79 additions & 3 deletions include/avnd/binding/ossia/from_value.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <avnd/concepts/field_names.hpp>
#include <avnd/binding/ossia/ossia_to_curve.hpp>
#include <avnd/binding/ossia/value.hpp>
#include <avnd/concepts/generic.hpp>
Expand Down Expand Up @@ -1300,9 +1301,14 @@ inline void from_ossia_value(auto& field, const ossia::value& src, auto& dst)
template <avnd::enum_ish_parameter Field, typename Val>
struct enum_from_ossia_visitor
{
Val operator()(const float& v) const noexcept
{
return (*this)(int(v));
}

Val operator()(const int& v) const noexcept
{
constexpr auto range = avnd::get_range<Field>();
static constexpr auto range = avnd::get_range<Field>();
static_assert(std::size(range.values) > 0);
if constexpr(requires(Val v) { v = range.values[0].second; })
{
Expand All @@ -1323,9 +1329,10 @@ struct enum_from_ossia_visitor
return static_cast<Val>(v);
}
}

Val operator()(const std::string& v) const noexcept
{
constexpr auto range = avnd::get_range<Field>();
static constexpr auto range = avnd::get_range<Field>();
for(int i = 0; i < std::size(range.values); i++)
{
if constexpr(requires { v == range.values[i].first; })
Expand Down Expand Up @@ -1363,11 +1370,80 @@ inline void from_ossia_value(Field& field, const ossia::value& src, Val& dst)
template <avnd::curve_port Field, typename Val>
inline void from_ossia_value(Field& field, const ossia::value& src, Val& dst)
{
#if AVND_OSSIA_HAS_CURVE
auto segments = src.template target<std::vector<ossia::value>>();
if(!segments)
return;

convert_to_curve{}(dst, *segments);
#endif
}





template <typename arg_t>
static constexpr ossia::val_type type_for_arg()
{
if constexpr(std::floating_point<arg_t>)
{
return ossia::val_type::FLOAT;
}
else if constexpr(std::integral<arg_t>)
{
return ossia::val_type::INT;
}
else if constexpr(std::is_same_v<arg_t, bool>)
{
return ossia::val_type::BOOL;
}
else if constexpr(std::is_same_v<arg_t, const char*>)
{
return ossia::val_type::STRING;
}
else if constexpr(std::is_same_v<arg_t, std::string_view>)
{
return ossia::val_type::STRING;
}
else if constexpr(std::is_same_v<arg_t, std::string>)
{
return ossia::val_type::STRING;
}
else if constexpr(std::is_same_v<arg_t, std::array<float, 2>>)
{
return ossia::val_type::VEC2F;
}
else if constexpr(std::is_same_v<arg_t, std::array<float, 3>>)
{
return ossia::val_type::VEC3F;
}
else if constexpr(std::is_same_v<arg_t, std::array<float, 4>>)
{
return ossia::val_type::VEC4F;
}
else if constexpr(avnd::vector_ish<arg_t> || avnd::set_ish<arg_t>)
{
return ossia::val_type::LIST;
}
else if constexpr(avnd::map_ish<arg_t>)
{
return ossia::val_type::LIST;
}
else if constexpr(avnd::variant_ish<arg_t>)
{
return ossia::val_type::LIST;
}
else if constexpr(avnd::optional_ish<arg_t>)
{
return ossia::val_type::LIST;
}
else if constexpr(std::is_aggregate_v<arg_t>)
{
if constexpr(avnd::has_field_names<arg_t>)
return ossia::val_type::MAP;
else
return ossia::val_type::LIST;
}
return ossia::val_type::IMPULSE;
}
}
4 changes: 4 additions & 0 deletions include/avnd/binding/ossia/ossia_to_curve.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once
#include <avnd/concepts/curve.hpp>
#if __has_include(<ossia/editor/curve/curve_segment/easing.hpp>)
#define AVND_OSSIA_HAS_CURVE 1
#include <ossia/editor/curve/curve_segment/easing.hpp>
#include <ossia/editor/curve/curve_segment/easing_helpers.hpp>
#include <ossia/network/value/value.hpp>
Expand Down Expand Up @@ -259,3 +261,5 @@ struct convert_to_curve
};

}

#endif
10 changes: 2 additions & 8 deletions include/avnd/binding/ossia/port_run_preprocess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ inline void update_value(
{
if(node.from_ossia_value(field, src, dst, idx))
{
if constexpr(requires { field.update(obj); })
{
field.update(obj);
}
if_possible(field.update(obj));
}
}

Expand Down Expand Up @@ -276,10 +273,7 @@ struct process_before_run

ctrl.value = dest_vec;

if constexpr(requires { ctrl.update(impl); })
{
ctrl.update(impl);
}
if_possible(ctrl.update(impl));
}

template <typename Field, std::size_t Idx>
Expand Down
41 changes: 41 additions & 0 deletions include/avnd/binding/ossia/qt.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once
#include <ossia/network/value/value.hpp>
#include <avnd/introspection/widgets.hpp>

#include <QString>

#include <array>
#include <vector>
#include <utility>
#include <memory>
#include <string>
#include <string_view>

namespace oscr
{
template <std::size_t N>
auto to_combobox_range(const std::string_view (&val)[N])
{
std::vector<std::pair<QString, ossia::value>> vec;
for(int i = 0; i < N; i++)
vec.emplace_back(val[i].data(), i);
return vec;
}

template <std::size_t N>
auto to_combobox_range(const std::array<std::string_view, N>& val)
{
std::vector<std::pair<QString, ossia::value>> vec;
for(int i = 0; i < N; i++)
vec.emplace_back(val[i].data(), i);
return vec;
}

std::vector<std::pair<QString, ossia::value>> to_combobox_range(const auto& in)
{
std::vector<std::pair<QString, ossia::value>> vec;
for(auto& v : avnd::to_const_char_array(in))
vec.emplace_back(v.first, v.second);
return vec;
}
}
Loading

0 comments on commit 0620702

Please sign in to comment.