vamp-sdk/test/main.cpp
2024-07-24 10:01:27 +03:00

209 lines
4.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "hack/logger/logger.hpp"
#include "vamp-hostsdk/PluginInputDomainAdapter.h"
#include "vamp-hostsdk/PluginBufferingAdapter.h"
#include "vamp-sdk/Plugin.h"
class MyPlugin : public Vamp::Plugin
{
public:
MyPlugin(float inputSampleRate);
virtual ~MyPlugin();
std::string getIdentifier() const;
std::string getName() const;
std::string getDescription() const;
std::string getMaker() const;
int getPluginVersion() const;
std::string getCopyright() const;
InputDomain getInputDomain() const;
size_t getPreferredBlockSize() const;
size_t getPreferredStepSize() const;
size_t getMinChannelCount() const;
size_t getMaxChannelCount() const;
ParameterList getParameterDescriptors() const;
float getParameter(std::string identifier) const;
void setParameter(std::string identifier, float value);
ProgramList getPrograms() const;
std::string getCurrentProgram() const;
void selectProgram(std::string name);
OutputList getOutputDescriptors() const;
bool initialise(size_t channels, size_t stepSize, size_t blockSize);
void reset();
FeatureSet process(const float *const *inputBuffers,
Vamp::RealTime timestamp);
FeatureSet getRemainingFeatures();
};
MyPlugin::MyPlugin(float inputSampleRate) : Plugin(inputSampleRate)
{
}
MyPlugin::~MyPlugin()
{
}
std::string MyPlugin::getIdentifier() const
{
return "myplugin";
}
std::string MyPlugin::getName() const
{
return "My Plugin";
}
std::string MyPlugin::getDescription() const
{
return "";
}
std::string MyPlugin::getMaker() const
{
return "";
}
int MyPlugin::getPluginVersion() const
{
return 1;
}
std::string MyPlugin::getCopyright() 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::ParameterList MyPlugin::getParameterDescriptors() const
{
ParameterList list;
ParameterDescriptor d;
d.identifier = "parameter";
d.name = "Some Parameter";
d.description = "";
d.unit = "";
d.minValue = 0;
d.maxValue = 10;
d.defaultValue = 5;
d.isQuantized = false;
list.push_back(d);
return list;
}
float MyPlugin::getParameter(std::string identifier) const
{
if (identifier == "parameter")
return 5;
return 0;
}
void MyPlugin::setParameter(std::string identifier, float value)
{
if (identifier == "parameter") {
}
}
MyPlugin::ProgramList MyPlugin::getPrograms() const
{
ProgramList list;
return list;
}
std::string MyPlugin::getCurrentProgram() const
{
return "";
}
void MyPlugin::selectProgram(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::RealTime timestamp)
{
return FeatureSet();
}
MyPlugin::FeatureSet MyPlugin::getRemainingFeatures()
{
return FeatureSet();
}
auto main() -> int
{
float samplerate = 10.f;
MyPlugin* ch = new MyPlugin(samplerate);
Vamp::HostExt::PluginInputDomainAdapter* ia = new Vamp::HostExt::PluginInputDomainAdapter(ch);
ia->setProcessTimestampMethod(Vamp::HostExt::PluginInputDomainAdapter::ShiftData);
Vamp::HostExt::PluginBufferingAdapter* adapter = new Vamp::HostExt::PluginBufferingAdapter(ia);
int blocksize = adapter->getPreferredBlockSize();
if (!adapter->initialise(1, blocksize, blocksize))
hack::error()("Не инициализировался адаптер");
hack::log()("is ok");
}