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