init
This commit is contained in:
145
TEMPLATE/src/YOURPLUGIN.cpp
Normal file
145
TEMPLATE/src/YOURPLUGIN.cpp
Normal file
@@ -0,0 +1,145 @@
|
||||
#include <cstddef>
|
||||
#include <lv2.h>
|
||||
|
||||
class YOURPLUGIN
|
||||
{
|
||||
private:
|
||||
|
||||
// PORTS
|
||||
float* audio_in_l_ptr;
|
||||
float* audio_in_r_ptr;
|
||||
float* audio_out_l_ptr;
|
||||
float* audio_out_r_ptr;
|
||||
float* example_ptr;
|
||||
|
||||
|
||||
double samplerate;
|
||||
|
||||
public:
|
||||
explicit YOURPLUGIN(double samplerate);
|
||||
~YOURPLUGIN();
|
||||
|
||||
void connectPort(const uint32_t port, void* data_location);
|
||||
void activate();
|
||||
void run(const uint32_t sample_count);
|
||||
void deactivate();
|
||||
};
|
||||
|
||||
|
||||
YOURPLUGIN::YOURPLUGIN(double samplerate_):
|
||||
audio_in_l_ptr(nullptr),
|
||||
audio_in_r_ptr(nullptr),
|
||||
audio_out_l_ptr(nullptr),
|
||||
audio_out_r_ptr(nullptr),
|
||||
example_ptr(nullptr),
|
||||
samplerate(samplerate_)
|
||||
{
|
||||
}
|
||||
|
||||
YOURPLUGIN::~YOURPLUGIN()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void YOURPLUGIN::connectPort(const uint32_t port, void* data_location)
|
||||
{
|
||||
switch(port)
|
||||
{
|
||||
case 0:
|
||||
audio_in_l_ptr = (float*) data_location;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
audio_in_r_ptr = (float*) data_location;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
audio_out_l_ptr = (float*) data_location;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
audio_out_r_ptr = (float*) data_location;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
example_ptr = (float*) data_location;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void YOURPLUGIN::activate()
|
||||
{
|
||||
}
|
||||
|
||||
void YOURPLUGIN::deactivate()
|
||||
{
|
||||
}
|
||||
|
||||
void YOURPLUGIN::run(const uint32_t sample_count)
|
||||
{
|
||||
}
|
||||
|
||||
/* internal core methods */
|
||||
static LV2_Handle instantiate (const struct LV2_Descriptor *descriptor, double sample_rate, const char *bundle_path, const LV2_Feature *const *features)
|
||||
{
|
||||
YOURPLUGIN* m = new YOURPLUGIN(sample_rate);
|
||||
return m;
|
||||
}
|
||||
|
||||
static void connect_port (LV2_Handle instance, uint32_t port, void *data_location)
|
||||
{
|
||||
YOURPLUGIN* m = (YOURPLUGIN*) instance;
|
||||
if (m) m->connectPort(port, data_location);
|
||||
}
|
||||
|
||||
static void activate (LV2_Handle instance)
|
||||
{
|
||||
YOURPLUGIN* m = (YOURPLUGIN*) instance;
|
||||
if (m) m->activate();
|
||||
}
|
||||
|
||||
static void run (LV2_Handle instance, uint32_t sample_count)
|
||||
{
|
||||
YOURPLUGIN* m = (YOURPLUGIN*) instance;
|
||||
if (m) m->run(sample_count);
|
||||
}
|
||||
|
||||
static void deactivate (LV2_Handle instance)
|
||||
{
|
||||
YOURPLUGIN* m = (YOURPLUGIN*) instance;
|
||||
if (m) m->deactivate();
|
||||
}
|
||||
|
||||
static void cleanup (LV2_Handle instance)
|
||||
{
|
||||
YOURPLUGIN* m = (YOURPLUGIN*) instance;
|
||||
if (m) delete m;
|
||||
}
|
||||
|
||||
static const void* extension_data (const char *uri)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* descriptor */
|
||||
static LV2_Descriptor const descriptor =
|
||||
{
|
||||
"YOURURL",
|
||||
instantiate,
|
||||
connect_port,
|
||||
activate /* or NULL */,
|
||||
run,
|
||||
deactivate /* or NULL */,
|
||||
cleanup,
|
||||
extension_data /* or NULL */
|
||||
};
|
||||
|
||||
/* interface */
|
||||
LV2_SYMBOL_EXPORT const LV2_Descriptor* lv2_descriptor (uint32_t index)
|
||||
{
|
||||
if (index == 0) return &descriptor;
|
||||
else return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user