rt-vamp-plugin-sdk  0.3.1
Real-time Vamp plugin SDK for C++20
PluginHostAdapter.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <filesystem>
5 #include <memory>
6 #include <optional>
7 #include <string_view>
8 #include <vector>
9 
11 
12 // forward declarations
13 struct _VampPluginDescriptor;
14 typedef _VampPluginDescriptor VampPluginDescriptor;
15 typedef void* VampPluginHandle;
16 
17 namespace rtvamp::hostsdk {
18 
19 class DynamicLibrary;
20 
21 class PluginHostAdapter : public Plugin {
22 public:
24  const VampPluginDescriptor& descriptor,
25  float inputSampleRate,
26  std::shared_ptr<DynamicLibrary> library = nullptr // extend lifetime of dl handle
27  );
29 
30  std::filesystem::path getLibraryPath() const noexcept;
31 
32  uint32_t getVampApiVersion() const noexcept override;
33 
34  std::string_view getIdentifier() const noexcept override;
35  std::string_view getName() const noexcept override;
36  std::string_view getDescription() const noexcept override;
37  std::string_view getMaker() const noexcept override;
38  std::string_view getCopyright() const noexcept override;
39  int getPluginVersion() const noexcept override;
40  InputDomain getInputDomain() const noexcept override;
41 
42  ParameterList getParameterDescriptors() const noexcept override;
43  std::optional<float> getParameter(std::string_view id) const override;
44  bool setParameter(std::string_view id, float value) override;
45 
46  ProgramList getPrograms() const noexcept override;
47  CurrentProgram getCurrentProgram() const override;
48  bool selectProgram(std::string_view name) override;
49 
50  uint32_t getPreferredStepSize() const override;
51  uint32_t getPreferredBlockSize() const override;
52 
53  uint32_t getOutputCount() const override;
54  OutputList getOutputDescriptors() const override;
55 
56  bool initialise(uint32_t stepSize, uint32_t blockSize) override;
57  void reset() override;
58  FeatureSet process(InputBuffer buffer, uint64_t nsec) override;
59 
60 private:
61  void checkRequirements();
62 
63  const VampPluginDescriptor& descriptor_;
64  std::shared_ptr<DynamicLibrary> library_;
65  VampPluginHandle handle_{nullptr};
66  std::vector<ParameterDescriptor> parameters_;
67  std::vector<std::string_view> programs_;
68  std::vector<Feature> featureSet_;
69  uint32_t outputCount_{0};
70  bool initialised_{false};
71  uint32_t initialisedBlockSize_{0};
72 };
73 
74 } // namespace rtvamp::hostsdk
rtvamp::hostsdk::Plugin::CurrentProgram
std::optional< std::string_view > CurrentProgram
Current program (if programs avaiable)
Definition: Plugin.hpp:49
rtvamp::hostsdk::PluginHostAdapter::getParameter
std::optional< float > getParameter(std::string_view id) const override
rtvamp::hostsdk::PluginHostAdapter::selectProgram
bool selectProgram(std::string_view name) override
rtvamp::hostsdk::PluginHostAdapter::getLibraryPath
std::filesystem::path getLibraryPath() const noexcept
rtvamp::hostsdk::PluginHostAdapter::getParameterDescriptors
ParameterList getParameterDescriptors() const noexcept override
rtvamp::hostsdk::PluginHostAdapter::getOutputCount
uint32_t getOutputCount() const override
Plugin.hpp
rtvamp::hostsdk::PluginHostAdapter::~PluginHostAdapter
~PluginHostAdapter()
VampPluginDescriptor
_VampPluginDescriptor VampPluginDescriptor
Definition: PluginHostAdapter.hpp:13
rtvamp::hostsdk::PluginHostAdapter::process
FeatureSet process(InputBuffer buffer, uint64_t nsec) override
rtvamp::hostsdk::Plugin::ProgramList
std::span< const std::string_view > ProgramList
List of programs.
Definition: Plugin.hpp:48
rtvamp::hostsdk::PluginHostAdapter::PluginHostAdapter
PluginHostAdapter(const VampPluginDescriptor &descriptor, float inputSampleRate, std::shared_ptr< DynamicLibrary > library=nullptr)
rtvamp::hostsdk::PluginHostAdapter::getInputDomain
InputDomain getInputDomain() const noexcept override
rtvamp::hostsdk::Plugin::InputBuffer
std::variant< TimeDomainBuffer, FrequencyDomainBuffer > InputBuffer
Input buffer variant.
Definition: Plugin.hpp:53
rtvamp::hostsdk
Definition: Plugin.hpp:12
rtvamp::hostsdk::PluginHostAdapter::initialise
bool initialise(uint32_t stepSize, uint32_t blockSize) override
rtvamp::hostsdk::Plugin
Definition: Plugin.hpp:14
rtvamp::hostsdk::PluginHostAdapter::reset
void reset() override
rtvamp::hostsdk::PluginHostAdapter::getPreferredBlockSize
uint32_t getPreferredBlockSize() const override
rtvamp::hostsdk::PluginHostAdapter
Definition: PluginHostAdapter.hpp:21
rtvamp::hostsdk::PluginHostAdapter::getCopyright
std::string_view getCopyright() const noexcept override
rtvamp::hostsdk::PluginHostAdapter::getMaker
std::string_view getMaker() const noexcept override
rtvamp::hostsdk::PluginHostAdapter::setParameter
bool setParameter(std::string_view id, float value) override
rtvamp::hostsdk::PluginHostAdapter::getPluginVersion
int getPluginVersion() const noexcept override
rtvamp::hostsdk::Plugin::InputDomain
InputDomain
Input domain of the plugin.
Definition: Plugin.hpp:20
rtvamp::hostsdk::Plugin::OutputList
std::vector< OutputDescriptor > OutputList
List of output descriptors.
Definition: Plugin.hpp:50
rtvamp::hostsdk::PluginHostAdapter::getPrograms
ProgramList getPrograms() const noexcept override
rtvamp::hostsdk::PluginHostAdapter::getVampApiVersion
uint32_t getVampApiVersion() const noexcept override
rtvamp::hostsdk::PluginHostAdapter::getDescription
std::string_view getDescription() const noexcept override
rtvamp::hostsdk::PluginHostAdapter::getCurrentProgram
CurrentProgram getCurrentProgram() const override
rtvamp::hostsdk::PluginHostAdapter::getOutputDescriptors
OutputList getOutputDescriptors() const override
rtvamp::hostsdk::PluginHostAdapter::getIdentifier
std::string_view getIdentifier() const noexcept override
rtvamp::hostsdk::Plugin::FeatureSet
std::span< const Feature > FeatureSet
Computed features for each output.
Definition: Plugin.hpp:55
rtvamp::hostsdk::PluginHostAdapter::getName
std::string_view getName() const noexcept override
rtvamp::hostsdk::PluginHostAdapter::getPreferredStepSize
uint32_t getPreferredStepSize() const override
rtvamp::hostsdk::Plugin::ParameterList
std::span< const ParameterDescriptor > ParameterList
List of parameter descriptors.
Definition: Plugin.hpp:47
VampPluginHandle
void * VampPluginHandle
Definition: PluginHostAdapter.hpp:15