rt-vamp-plugin-sdk  0.3.1
Real-time Vamp plugin SDK for C++20
Plugin.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <complex>
4 #include <cstdint>
5 #include <filesystem>
6 #include <optional>
7 #include <span>
8 #include <string_view>
9 #include <variant>
10 #include <vector>
11 
12 namespace rtvamp::hostsdk {
13 
14 class Plugin {
15 public:
16  explicit Plugin(float inputSampleRate) : inputSampleRate_(inputSampleRate) {}
17  virtual ~Plugin() = default;
18 
20  enum class InputDomain { Time, Frequency };
21 
23  std::string_view identifier;
24  std::string_view name;
25  std::string_view description;
26  std::string_view unit;
27  float defaultValue;
28  float minValue;
29  float maxValue;
30  std::optional<float> quantizeStep;
31  std::vector<std::string_view> valueNames;
32  };
33 
35  std::string identifier;
36  std::string name;
37  std::string description;
38  std::string unit;
39  uint32_t binCount;
40  std::vector<std::string> binNames;
42  float minValue;
43  float maxValue;
44  std::optional<float> quantizeStep;
45  };
46 
47  using ParameterList = std::span<const ParameterDescriptor>;
48  using ProgramList = std::span<const std::string_view>;
49  using CurrentProgram = std::optional<std::string_view>;
50  using OutputList = std::vector<OutputDescriptor>;
51  using TimeDomainBuffer = std::span<const float>;
52  using FrequencyDomainBuffer = std::span<const std::complex<float>>;
53  using InputBuffer = std::variant<TimeDomainBuffer, FrequencyDomainBuffer>;
54  using Feature = std::vector<float>;
55  using FeatureSet = std::span<const Feature>;
56 
57  virtual std::filesystem::path getLibraryPath() const noexcept = 0;
58 
59  virtual uint32_t getVampApiVersion() const noexcept = 0;
60 
61  virtual std::string_view getIdentifier( ) const noexcept = 0;
62  virtual std::string_view getName() const noexcept = 0;
63  virtual std::string_view getDescription() const noexcept = 0;
64  virtual std::string_view getMaker() const noexcept = 0;
65  virtual std::string_view getCopyright() const noexcept = 0;
66  virtual int getPluginVersion() const noexcept = 0;
67  virtual InputDomain getInputDomain() const noexcept = 0;
68 
69  virtual ParameterList getParameterDescriptors() const noexcept = 0;
70  virtual std::optional<float> getParameter(std::string_view id) const = 0;
71  virtual bool setParameter(std::string_view id, float value) = 0;
72 
73  virtual ProgramList getPrograms() const noexcept = 0;
74  virtual CurrentProgram getCurrentProgram() const = 0;
75  virtual bool selectProgram(std::string_view name) = 0;
76 
77  virtual uint32_t getPreferredStepSize() const = 0;
78  virtual uint32_t getPreferredBlockSize() const = 0;
79 
80  virtual uint32_t getOutputCount() const = 0;
81  virtual OutputList getOutputDescriptors() const = 0;
82 
83  virtual bool initialise(uint32_t stepSize, uint32_t blockSize) = 0;
84  virtual void reset() = 0;
85  virtual FeatureSet process(InputBuffer buffer, uint64_t nsec) = 0;
86 
87  float getInputSampleRate() const noexcept { return inputSampleRate_; };
88 
89 private:
90  const float inputSampleRate_;
91 };
92 
93 } // namespace rtvamp::hostsdk
rtvamp::hostsdk::Plugin::CurrentProgram
std::optional< std::string_view > CurrentProgram
Current program (if programs avaiable)
Definition: Plugin.hpp:49
rtvamp::hostsdk::Plugin::ParameterDescriptor::name
std::string_view name
Definition: Plugin.hpp:24
rtvamp::hostsdk::Plugin::Feature
std::vector< float > Feature
Feature with one or more values (defined by OutputDescriptor::binCount)
Definition: Plugin.hpp:54
rtvamp::hostsdk::Plugin::OutputDescriptor::identifier
std::string identifier
Definition: Plugin.hpp:35
rtvamp::hostsdk::Plugin::getPreferredStepSize
virtual uint32_t getPreferredStepSize() const =0
rtvamp::hostsdk::Plugin::OutputDescriptor::binCount
uint32_t binCount
Definition: Plugin.hpp:39
rtvamp::hostsdk::Plugin::OutputDescriptor::maxValue
float maxValue
Definition: Plugin.hpp:43
rtvamp::hostsdk::Plugin::reset
virtual void reset()=0
rtvamp::hostsdk::Plugin::ParameterDescriptor::description
std::string_view description
Definition: Plugin.hpp:25
rtvamp::hostsdk::Plugin::Plugin
Plugin(float inputSampleRate)
Definition: Plugin.hpp:16
rtvamp::hostsdk::Plugin::OutputDescriptor::unit
std::string unit
Definition: Plugin.hpp:38
rtvamp::hostsdk::Plugin::OutputDescriptor
Definition: Plugin.hpp:34
rtvamp::hostsdk::Plugin::ParameterDescriptor
Definition: Plugin.hpp:22
rtvamp::hostsdk::Plugin::OutputDescriptor::name
std::string name
Definition: Plugin.hpp:36
rtvamp::hostsdk::Plugin::OutputDescriptor::quantizeStep
std::optional< float > quantizeStep
Definition: Plugin.hpp:44
rtvamp::hostsdk::Plugin::initialise
virtual bool initialise(uint32_t stepSize, uint32_t blockSize)=0
rtvamp::hostsdk::Plugin::getPreferredBlockSize
virtual uint32_t getPreferredBlockSize() const =0
rtvamp::hostsdk::Plugin::OutputDescriptor::binNames
std::vector< std::string > binNames
Definition: Plugin.hpp:40
rtvamp::hostsdk::Plugin::getMaker
virtual std::string_view getMaker() const noexcept=0
rtvamp::hostsdk::Plugin::ParameterDescriptor::defaultValue
float defaultValue
Definition: Plugin.hpp:27
rtvamp::hostsdk::Plugin::process
virtual FeatureSet process(InputBuffer buffer, uint64_t nsec)=0
rtvamp::hostsdk::Plugin::ProgramList
std::span< const std::string_view > ProgramList
List of programs.
Definition: Plugin.hpp:48
rtvamp::hostsdk::Plugin::InputDomain::Time
@ Time
rtvamp::hostsdk::Plugin::getParameter
virtual std::optional< float > getParameter(std::string_view id) const =0
rtvamp::hostsdk::Plugin::getLibraryPath
virtual std::filesystem::path getLibraryPath() const noexcept=0
rtvamp::hostsdk::Plugin::InputDomain::Frequency
@ Frequency
rtvamp::hostsdk::Plugin::InputBuffer
std::variant< TimeDomainBuffer, FrequencyDomainBuffer > InputBuffer
Input buffer variant.
Definition: Plugin.hpp:53
rtvamp::hostsdk::Plugin::getName
virtual std::string_view getName() const noexcept=0
rtvamp::hostsdk::Plugin::getParameterDescriptors
virtual ParameterList getParameterDescriptors() const noexcept=0
rtvamp::hostsdk
Definition: Plugin.hpp:12
rtvamp::hostsdk::Plugin::OutputDescriptor::description
std::string description
Definition: Plugin.hpp:37
rtvamp::hostsdk::Plugin::getPrograms
virtual ProgramList getPrograms() const noexcept=0
rtvamp::hostsdk::Plugin::getVampApiVersion
virtual uint32_t getVampApiVersion() const noexcept=0
rtvamp::hostsdk::Plugin::getCurrentProgram
virtual CurrentProgram getCurrentProgram() const =0
rtvamp::hostsdk::Plugin
Definition: Plugin.hpp:14
rtvamp::hostsdk::Plugin::getPluginVersion
virtual int getPluginVersion() const noexcept=0
rtvamp::hostsdk::Plugin::OutputDescriptor::hasKnownExtents
bool hasKnownExtents
Definition: Plugin.hpp:41
rtvamp::hostsdk::Plugin::ParameterDescriptor::maxValue
float maxValue
Definition: Plugin.hpp:29
rtvamp::hostsdk::Plugin::TimeDomainBuffer
std::span< const float > TimeDomainBuffer
Time domain buffer.
Definition: Plugin.hpp:51
rtvamp::hostsdk::Plugin::ParameterDescriptor::identifier
std::string_view identifier
Definition: Plugin.hpp:23
rtvamp::hostsdk::Plugin::getDescription
virtual std::string_view getDescription() const noexcept=0
rtvamp::hostsdk::Plugin::~Plugin
virtual ~Plugin()=default
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::Plugin::ParameterDescriptor::unit
std::string_view unit
Definition: Plugin.hpp:26
rtvamp::hostsdk::Plugin::getCopyright
virtual std::string_view getCopyright() const noexcept=0
rtvamp::hostsdk::Plugin::getIdentifier
virtual std::string_view getIdentifier() const noexcept=0
rtvamp::hostsdk::Plugin::getInputDomain
virtual InputDomain getInputDomain() const noexcept=0
rtvamp::hostsdk::Plugin::FrequencyDomainBuffer
std::span< const std::complex< float > > FrequencyDomainBuffer
Frequency domain buffer (FFT)
Definition: Plugin.hpp:52
rtvamp::hostsdk::Plugin::selectProgram
virtual bool selectProgram(std::string_view name)=0
rtvamp::hostsdk::Plugin::ParameterDescriptor::minValue
float minValue
Definition: Plugin.hpp:28
rtvamp::hostsdk::Plugin::getOutputDescriptors
virtual OutputList getOutputDescriptors() const =0
rtvamp::hostsdk::Plugin::ParameterDescriptor::quantizeStep
std::optional< float > quantizeStep
Definition: Plugin.hpp:30
rtvamp::hostsdk::Plugin::getOutputCount
virtual uint32_t getOutputCount() const =0
rtvamp::hostsdk::Plugin::getInputSampleRate
float getInputSampleRate() const noexcept
Definition: Plugin.hpp:87
rtvamp::hostsdk::Plugin::OutputDescriptor::minValue
float minValue
Definition: Plugin.hpp:42
rtvamp::hostsdk::Plugin::FeatureSet
std::span< const Feature > FeatureSet
Computed features for each output.
Definition: Plugin.hpp:55
rtvamp::hostsdk::Plugin::setParameter
virtual bool setParameter(std::string_view id, float value)=0
rtvamp::hostsdk::Plugin::ParameterDescriptor::valueNames
std::vector< std::string_view > valueNames
Definition: Plugin.hpp:31
rtvamp::hostsdk::Plugin::ParameterList
std::span< const ParameterDescriptor > ParameterList
List of parameter descriptors.
Definition: Plugin.hpp:47