2024-07-24 10:01:27 +03:00
|
|
|
|
#include "hack/logger/logger.hpp"
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
#include "vamp-sdk/Plugin.h"
|
2024-07-24 10:01:27 +03:00
|
|
|
|
#include "vamp-hostsdk/PluginInputDomainAdapter.h"
|
|
|
|
|
#include "vamp-hostsdk/PluginBufferingAdapter.h"
|
|
|
|
|
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
class MyPlugin : public vamp::plugin
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
2024-08-08 11:53:48 +03:00
|
|
|
|
public:
|
2024-07-24 10:01:27 +03:00
|
|
|
|
MyPlugin(float inputSampleRate);
|
|
|
|
|
virtual ~MyPlugin();
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
std::string get_identifier() const override;
|
|
|
|
|
std::string get_name() const override;
|
|
|
|
|
std::string get_description() const override;
|
|
|
|
|
std::string get_maker() const override;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
InputDomain getInputDomain() const override;
|
|
|
|
|
size_t getPreferredBlockSize() const override;
|
|
|
|
|
size_t getPreferredStepSize() const override;
|
|
|
|
|
size_t getMinChannelCount() const override;
|
|
|
|
|
size_t getMaxChannelCount() const override;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
parameter_descriptors get_parameter_descriptors() const override;
|
|
|
|
|
float get_parameter(std::string identifier) const override;
|
|
|
|
|
void set_parameter(std::string identifier, float value) override;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
programs get_programs() const override;
|
|
|
|
|
std::string get_current_program() const override;
|
|
|
|
|
void select_program(std::string name) override;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
OutputList getOutputDescriptors() const override;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
bool initialise(size_t channels, size_t stepSize, size_t blockSize) override;
|
|
|
|
|
void reset() override;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
FeatureSet process(const float *const *inputBuffers, vamp::real_time timestamp) override;
|
|
|
|
|
FeatureSet getRemainingFeatures() override;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
};
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
MyPlugin::MyPlugin(float inputSampleRate) : plugin(inputSampleRate)
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyPlugin::~MyPlugin()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
std::string MyPlugin::get_identifier() const
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
return "myplugin";
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
std::string MyPlugin::get_name() const
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
return "My Plugin";
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
std::string MyPlugin::get_description() const
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
std::string MyPlugin::get_maker() const
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyPlugin::InputDomain MyPlugin::getInputDomain() const
|
|
|
|
|
{
|
|
|
|
|
return TimeDomain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t MyPlugin::getPreferredBlockSize() const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t MyPlugin::getPreferredStepSize() const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t MyPlugin::getMinChannelCount() const
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t MyPlugin::getMaxChannelCount() const
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
MyPlugin::parameter_descriptors MyPlugin::get_parameter_descriptors() const
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
2024-08-08 11:53:48 +03:00
|
|
|
|
parameter_descriptors list;
|
|
|
|
|
parameter_descriptor d;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
d.identifier = "parameter";
|
|
|
|
|
d.name = "Some Parameter";
|
|
|
|
|
d.description = "";
|
|
|
|
|
d.unit = "";
|
2024-08-08 11:53:48 +03:00
|
|
|
|
d.min_value = 0;
|
|
|
|
|
d.max_value = 10;
|
|
|
|
|
d.default_value = 5;
|
|
|
|
|
d.is_quantized = false;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
list.push_back(d);
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
float MyPlugin::get_parameter(std::string identifier) const
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
if (identifier == "parameter")
|
|
|
|
|
return 5;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
void MyPlugin::set_parameter(std::string identifier, float value)
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
if (identifier == "parameter") {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
MyPlugin::programs MyPlugin::get_programs() const
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
2024-08-08 11:53:48 +03:00
|
|
|
|
programs list;
|
2024-07-24 10:01:27 +03:00
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
std::string MyPlugin::get_current_program() const
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
void MyPlugin::select_program(std::string name)
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyPlugin::OutputList MyPlugin::getOutputDescriptors() const
|
|
|
|
|
{
|
|
|
|
|
OutputList list;
|
|
|
|
|
|
|
|
|
|
OutputDescriptor d;
|
|
|
|
|
d.identifier = "output";
|
|
|
|
|
d.name = "My Output";
|
|
|
|
|
d.description = "";
|
|
|
|
|
d.unit = "";
|
|
|
|
|
d.hasFixedBinCount = true;
|
|
|
|
|
d.binCount = 1;
|
|
|
|
|
d.hasKnownExtents = false;
|
|
|
|
|
d.isQuantized = false;
|
|
|
|
|
d.sampleType = OutputDescriptor::OneSamplePerStep;
|
|
|
|
|
d.hasDuration = false;
|
|
|
|
|
list.push_back(d);
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MyPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize)
|
|
|
|
|
{
|
|
|
|
|
if (channels < getMinChannelCount() || channels > getMaxChannelCount()) return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyPlugin::reset()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
MyPlugin::FeatureSet MyPlugin::process(const float *const *inputBuffers, vamp::real_time timestamp)
|
2024-07-24 10:01:27 +03:00
|
|
|
|
{
|
|
|
|
|
return FeatureSet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyPlugin::FeatureSet MyPlugin::getRemainingFeatures()
|
|
|
|
|
{
|
|
|
|
|
return FeatureSet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto main() -> int
|
|
|
|
|
{
|
|
|
|
|
float samplerate = 10.f;
|
|
|
|
|
MyPlugin* ch = new MyPlugin(samplerate);
|
2024-08-08 11:53:48 +03:00
|
|
|
|
vamp::host::PluginInputDomainAdapter* ia = new vamp::host::PluginInputDomainAdapter(ch);
|
|
|
|
|
ia->setProcessTimestampMethod(vamp::host::PluginInputDomainAdapter::ShiftData);
|
2024-07-24 10:01:27 +03:00
|
|
|
|
|
2024-08-08 11:53:48 +03:00
|
|
|
|
vamp::host::PluginBufferingAdapter* adapter = new vamp::host::PluginBufferingAdapter(ia);
|
2024-07-24 10:01:27 +03:00
|
|
|
|
|
|
|
|
|
int blocksize = adapter->getPreferredBlockSize();
|
|
|
|
|
if (!adapter->initialise(1, blocksize, blocksize))
|
|
|
|
|
hack::error()("Не инициализировался адаптер");
|
|
|
|
|
|
|
|
|
|
hack::log()("is ok");
|
|
|
|
|
}
|