rt-vamp-plugin-sdk
0.3.1
Real-time Vamp plugin SDK for C++20
|
Go to the documentation of this file.
15 static_assert(
sizeof(
unsigned int) >=
sizeof(uint32_t),
"Size type must have at least 32 bit");
57 using InputBuffer = std::variant<TimeDomainBuffer, FrequencyDomainBuffer>;
72 template <u
int32_t NOutputs>
75 explicit constexpr
Plugin(
float inputSampleRate) : inputSampleRate_(inputSampleRate) {}
77 using OutputList = std::array<OutputDescriptor, NOutputs>;
94 static constexpr std::array<ParameterDescriptor, 0>
parameters{};
95 static constexpr std::array<const char*, 0>
programs{};
97 virtual std::optional<float>
getParameter(std::string_view
id)
const {
return {}; }
98 virtual bool setParameter(std::string_view
id,
float value) {
return false; }
108 virtual bool initialise(uint32_t stepSize, uint32_t blockSize) = 0;
109 virtual void reset() = 0;
118 const float inputSampleRate_;
124 template <u
int32_t NOutputs>
126 const auto outputs = getOutputDescriptors();
127 auto& featureSet = getFeatureSet();
128 for (
size_t i = 0; i < outputCount; ++i) {
129 featureSet[i].resize(outputs[i].binCount);
141 template <
typename T,
size_t MaxOutputCount = 32>
142 consteval
bool isPlugin() {
143 return []<std::size_t... Ns>(std::index_sequence<Ns...>) {
144 return std::disjunction<
145 std::is_base_of<Plugin<Ns>, T>...
147 }(std::make_index_sequence<MaxOutputCount>{});
150 template <
typename T>
151 concept IsPlugin = detail::isPlugin<T>();
static constexpr Meta meta
Required static plugin descriptor.
Definition: Plugin.hpp:93
std::vector< std::string > binNames
Definition: Plugin.hpp:48
virtual uint32_t getPreferredBlockSize() const
Definition: Plugin.hpp:104
Non-templated plugin base class with type definitions.
Definition: Plugin.hpp:22
const char * unit
Definition: Plugin.hpp:34
std::vector< float > Feature
Feature with one or more values (defined by OutputDescriptor::binCount)
Definition: Plugin.hpp:58
virtual uint32_t getPreferredStepSize() const
Definition: Plugin.hpp:103
virtual std::optional< float > getParameter(std::string_view id) const
Definition: Plugin.hpp:97
bool hasKnownExtents
Definition: Plugin.hpp:49
std::span< const float > TimeDomainBuffer
Time domain buffer.
Definition: Plugin.hpp:55
float minValue
Definition: Plugin.hpp:36
std::optional< float > quantizeStep
Definition: Plugin.hpp:52
virtual bool initialise(uint32_t stepSize, uint32_t blockSize)=0
float defaultValue
Definition: Plugin.hpp:35
virtual bool setParameter(std::string_view id, float value)
Definition: Plugin.hpp:98
static constexpr std::array< ParameterDescriptor, 0 > parameters
Optional parameter descriptors (default: none)
Definition: Plugin.hpp:94
std::array< OutputDescriptor, NOutputs > OutputList
List of output descriptors.
Definition: Plugin.hpp:77
virtual bool selectProgram(std::string_view name)
Definition: Plugin.hpp:101
float maxValue
Definition: Plugin.hpp:51
float getInputSampleRate() const noexcept
Definition: Plugin.hpp:113
std::optional< float > quantizeStep
Definition: Plugin.hpp:38
const char * identifier
Definition: Plugin.hpp:31
std::span< const std::complex< float > > FrequencyDomainBuffer
Frequency domain buffer (FFT)
Definition: Plugin.hpp:56
std::string name
Definition: Plugin.hpp:44
virtual ~PluginBase()=default
float maxValue
Definition: Plugin.hpp:37
Base class to implement feature extraction plugins.
Definition: Plugin.hpp:73
float minValue
Definition: Plugin.hpp:50
std::string identifier
Definition: Plugin.hpp:43
static constexpr std::array< const char *, 0 > programs
Optional program list (default: none)
Definition: Plugin.hpp:95
void initialiseFeatureSet()
Definition: Plugin.hpp:125
virtual OutputList getOutputDescriptors() const =0
InputDomain
Input domain of the plugin.
Definition: Plugin.hpp:27
FeatureSet & getFeatureSet() noexcept
Definition: Plugin.hpp:114
const char * name
Definition: Plugin.hpp:32
uint32_t binCount
Definition: Plugin.hpp:47
virtual std::string_view getCurrentProgram() const
Definition: Plugin.hpp:100
std::string unit
Definition: Plugin.hpp:46
std::string description
Definition: Plugin.hpp:45
virtual const FeatureSet & process(InputBuffer buffer, uint64_t nsec)=0
Definition: EntryPoint.hpp:8
Definition: Plugin.hpp:42
static constexpr uint32_t outputCount
Number of outputs (defined by template parameter)
Definition: Plugin.hpp:80
constexpr Plugin(float inputSampleRate)
Definition: Plugin.hpp:75
std::variant< TimeDomainBuffer, FrequencyDomainBuffer > InputBuffer
Input domain variant.
Definition: Plugin.hpp:57
const char * description
Definition: Plugin.hpp:33
Definition: Plugin.hpp:29
std::array< Feature, NOutputs > FeatureSet
Computed features for each output.
Definition: Plugin.hpp:78