clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit c21ae76174119c108e50e926df0d735bef576e7e
parent 8382b2070b90dabfd833c61567d197942c2923d5
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Thu, 29 Jul 2021 15:48:33 +0200

Reorganize the code

Diffstat:
Mexamples/CMakeLists.txt | 3++-
Mexamples/gui-proxy/CMakeLists.txt | 2--
Dexamples/gui-proxy/proxy.cc | 0
Dexamples/gui-proxy/proxy.hh | 0
Mexamples/gui/CMakeLists.txt | 2+-
Aexamples/io/CMakeLists.txt | 8++++++++
Rexamples/plugins/buffer.hh -> examples/io/buffer.hh | 0
Rexamples/plugins/remote-channel.cc -> examples/io/remote-channel.cc | 0
Aexamples/io/remote-channel.hh | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mexamples/plugins/CMakeLists.txt | 5+----
Dexamples/plugins/remote-channel.hh | 81-------------------------------------------------------------------------------
11 files changed, 90 insertions(+), 89 deletions(-)

diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt @@ -7,8 +7,9 @@ if(ENABLE_CLAP_HOST) endif() if(ENABLE_CLAP_GUI OR ENABLE_CLAP_PLUGINS) + add_subdirectory(io) add_subdirectory(gui) - add_subdirectory(gui-proxy) + #add_subdirectory(gui-proxy) endif() if(ENABLE_CLAP_PLUGINS) diff --git a/examples/gui-proxy/CMakeLists.txt b/examples/gui-proxy/CMakeLists.txt @@ -1,5 +1,3 @@ add_library(clap-gui-proxy STATIC - proxy.cc - proxy.hh ) set_target_properties(clap-gui-proxy PROPERTIES POSITION_INDEPENDENT_CODE TRUE) \ No newline at end of file diff --git a/examples/gui-proxy/proxy.cc b/examples/gui-proxy/proxy.cc diff --git a/examples/gui-proxy/proxy.hh b/examples/gui-proxy/proxy.hh diff --git a/examples/gui/CMakeLists.txt b/examples/gui/CMakeLists.txt @@ -11,7 +11,7 @@ add_executable(clap-gui application.hh application.cc ) -target_link_libraries(clap-gui Qt6::Qml Qt6::Widgets Qt6::Core) +target_link_libraries(clap-gui clap-io Qt6::Qml Qt6::Widgets Qt6::Core) set_target_properties(clap-gui PROPERTIES CXX_STANDARD 17) install(TARGETS clap-gui DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") \ No newline at end of file diff --git a/examples/io/CMakeLists.txt b/examples/io/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(clap-io STATIC + remote-channel.hh + remote-channel.cc + buffer.hh +) +set_target_properties(clap-io PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +target_include_directories(clap-io INTERFACE .) +\ No newline at end of file diff --git a/examples/plugins/buffer.hh b/examples/io/buffer.hh diff --git a/examples/plugins/remote-channel.cc b/examples/io/remote-channel.cc diff --git a/examples/io/remote-channel.hh b/examples/io/remote-channel.hh @@ -0,0 +1,77 @@ +#pragma once + +#include <queue> +#include <memory> + +#include <clap/all.h> + +#include "buffer.hh" + +namespace clap { + class RemoteChannel final { + public: + class EventControl { + public: + virtual void modifyFd(clap_fd_flags flags); + }; + + class Handler { + public: + virtual ~Handler() = default; + + // GUI callbacks + virtual void defineParameter(const clap_param_info &info) {} + virtual bool attachCocoa(void *nsView) { return false; } + virtual bool attachWin32(clap_hwnd window) { return false; } + virtual bool attachX11(const char *display_name, unsigned long window) { return false; } + + virtual void size(int32_t *width, int32_t *height) {} + virtual void setScale(double scale) {} + + virtual bool show() { return false; } + virtual bool hide() { return false; } + + virtual void close() {} + + // Plugin callbacks + virtual void beginAdjust(clap_id paramId) {} + virtual void adjust(clap_id paramId, double value) {} + virtual void endAdjust(clap_id paramId) {} + }; + + RemoteChannel(Handler &handler, EventControl &evControl, clap_fd socket); + ~RemoteChannel(); + + RemoteChannel(const RemoteChannel &) = delete; + RemoteChannel(RemoteChannel &&) = delete; + RemoteChannel &operator=(const RemoteChannel &) = delete; + RemoteChannel &operator=(RemoteChannel &&) = delete; + + void defineParameter(const clap_param_info &info); + void setParameterValue(clap_id paramId, double value); + + void close(); + + // Called when there is data to be read, non-blocking + void onRead(); + + // Called when data can be written, non-blocking + void onWrite(); + + private: + using ReadBuffer = Buffer<uint8_t, 128 * 1024>; + using WriteBuffer = Buffer<uint8_t, 32 * 1024>; + + void write(const uint8_t *data, size_t size); + WriteBuffer& nextWriteBuffer(); + + void parseInput(); + + Handler &handler_; + EventControl &evControl_; + clap_fd socket_; + + ReadBuffer inputBuffer_; + std::queue<WriteBuffer> outputBuffers_; + }; +} // namespace clap +\ No newline at end of file diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt @@ -13,15 +13,12 @@ add_library( abstract-gui.hh remote-gui.hh remote-gui.cc - remote-channel.hh - remote-channel.cc - buffer.hh dc-offset/dc-offset.hh dc-offset/dc-offset.cc gain/gain.hh gain/gain.cc) -target_link_libraries(clap-plugins clap-plugin-glue Boost::serialization Boost::iostreams) +target_link_libraries(clap-plugins clap-plugin-glue clap-io Boost::serialization Boost::iostreams) target_link_libraries(clap-plugins -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/linux-clap-plugins.version) set_target_properties(clap-plugins PROPERTIES CXX_STANDARD 20 SUFFIX ".clap" PREFIX "") diff --git a/examples/plugins/remote-channel.hh b/examples/plugins/remote-channel.hh @@ -1,80 +0,0 @@ -#pragma once - -#include <queue> -#include <memory> - -#include <clap/all.h> - -#include "buffer.hh" - -namespace clap { - class RemoteChannel final { - public: - class EventControl { - public: - virtual void modifyFd(clap_fd_flags flags); - }; - - class Handler { - public: - virtual ~Handler() = default; - - // GUI callbacks - virtual void defineParameter(const clap_param_info &info) {} - virtual bool attachCocoa(void *nsView) { return false; } - virtual bool attachWin32(clap_hwnd window) { return false; } - virtual bool attachX11(const char *display_name, unsigned long window) { return false; } - - virtual void size(int32_t *width, int32_t *height) {} - virtual void setScale(double scale) {} - - virtual bool show() { return false; } - virtual bool hide() { return false; } - - virtual void close() {} - - // Plugin callbacks - virtual void beginAdjust(clap_id paramId) {} - virtual void adjust(clap_id paramId, double value) {} - virtual void endAdjust(clap_id paramId) {} - }; - - RemoteChannel(Handler &handler, EventControl &evControl, clap_fd socket); - ~RemoteChannel(); - - RemoteChannel(const RemoteChannel &) = delete; - RemoteChannel(RemoteChannel &&) = delete; - RemoteChannel &operator=(const RemoteChannel &) = delete; - RemoteChannel &operator=(RemoteChannel &&) = delete; - - void defineParameter(const clap_param_info &info); - void setParameterValue(clap_id paramId, double value); - - void close(); - - // Called when there is data to be read, non-blocking - void onRead(); - - // Called when data can be written, non-blocking - void onWrite(); - - - - - private: - using ReadBuffer = Buffer<uint8_t, 128 * 1024>; - using WriteBuffer = Buffer<uint8_t, 32 * 1024>; - - void write(const uint8_t *data, size_t size); - WriteBuffer& nextWriteBuffer(); - - void parseInput(); - - Handler &handler_; - EventControl &evControl_; - clap_fd socket_; - - ReadBuffer inputBuffer_; - std::queue<WriteBuffer> outputBuffers_; - }; -} // namespace clap -\ No newline at end of file