Commit 7b4a1f04 authored by jhammen's avatar jhammen

lv2 stub out control output ports

parent 99b11fc4
......@@ -224,6 +224,9 @@ Plugin::Plugin(const PluginType *type, LilvInstance *instance, Worker *worker)
lilv_instance_connect_port(instance, def->index(), &(newPort->value));
controlMap[def->name()] = newPort;
}
for (uint32_t i = 0; i < type->controlOutputCount(); i++) {
lilv_instance_connect_port(instance, type->controlOutput(i).index(), nullptr);
}
for (uint32_t i = 0; i < type->atomOutputCount(); i++) {
MidiOutput *midiOutput = new MidiOutput(this);
lilv_instance_connect_port(instance, type->atomOutput(i).index(),
......@@ -497,9 +500,9 @@ void Plugin::saveState(const char *dir) {
PluginFactory &cache = PluginFactory::instance();
LV2_URID_Map *map = cache.getMap();
LilvState *const state =
lilv_state_new_from_instance(plugin, instance, map, dir, dir, dir, dir, getPortValue, this,
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE, NULL);
LilvState *const state = lilv_state_new_from_instance(
type->plugin(), instance, map, dir, dir, dir, dir, getPortValue, this,
LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE, NULL);
LV2_URID_Unmap *unmap = cache.getUnmap();
LilvWorld *world = cache.getWorld();
......@@ -649,6 +652,8 @@ PluginType::PluginType(const LilvPlugin *plugin, const Constants &uris)
lilv_plugin_get_num_ports_of_class(plugin, uris.lv2AudioPort, uris.lv2OutputPort, 0)),
mcontrolInputCount(
lilv_plugin_get_num_ports_of_class(plugin, uris.lv2ControlPort, uris.lv2InputPort, 0)),
mcontrolOutputCount(
lilv_plugin_get_num_ports_of_class(plugin, uris.lv2ControlPort, uris.lv2OutputPort, 0)),
matomInputCount(
lilv_plugin_get_num_ports_of_class(plugin, uris.lv2AtomPort, uris.lv2InputPort, 0)),
matomOutputCount(
......@@ -657,6 +662,7 @@ PluginType::PluginType(const LilvPlugin *plugin, const Constants &uris)
maudioInput = new PortDef[maudioInputCount];
maudioOutput = new PortDef[maudioOutputCount];
mcontrolInput = new ControlPortDef[mcontrolInputCount];
mcontrolOutput = new ControlPortDef[mcontrolOutputCount];
matomInput = new AtomPortDef[matomInputCount];
matomOutput = new AtomPortDef[matomOutputCount];
this->mmidiInputCount = 0;
......@@ -665,6 +671,7 @@ PluginType::PluginType(const LilvPlugin *plugin, const Constants &uris)
uint32_t audioInputCounter = 0;
uint32_t audioOutputCounter = 0;
uint32_t controlInputCounter = 0;
uint32_t controlOutputCounter = 0;
uint32_t eventInputCounter = 0;
uint32_t eventOutputCounter = 0;
for (uint32_t i = 0; i < numPorts; i++) {
......@@ -675,22 +682,25 @@ PluginType::PluginType(const LilvPlugin *plugin, const Constants &uris)
} else if (lilv_port_is_a(plugin, port, uris.lv2OutputPort)) {
maudioOutput[audioOutputCounter++].index(i);
}
} else if (lilv_port_is_a(plugin, port, uris.lv2ControlPort) &&
lilv_port_is_a(plugin, port, uris.lv2InputPort)) {
ControlPortDef &newPort = mcontrolInput[controlInputCounter++];
newPort.index(i);
// get control name
const LilvNode *symbol = lilv_port_get_symbol(plugin, port);
newPort.name(lilv_node_as_string(symbol));
// get default, max/min values
LilvNode *dfault, *minimum, *maximum;
lilv_port_get_range(plugin, port, &dfault, &minimum, &maximum);
newPort.dfault = dfault ? lilv_node_as_float(dfault) : 0;
newPort.minimum = lilv_node_as_float(minimum);
newPort.maximum = lilv_node_as_float(maximum);
lilv_free(dfault);
lilv_free(minimum);
lilv_free(maximum);
} else if (lilv_port_is_a(plugin, port, uris.lv2ControlPort)) {
if (lilv_port_is_a(plugin, port, uris.lv2InputPort)) {
ControlPortDef &newPort = mcontrolInput[controlInputCounter++];
newPort.index(i);
// get control name
const LilvNode *symbol = lilv_port_get_symbol(plugin, port);
newPort.name(lilv_node_as_string(symbol));
// get default, max/min values
LilvNode *dfault, *minimum, *maximum;
lilv_port_get_range(plugin, port, &dfault, &minimum, &maximum);
newPort.dfault(dfault ? lilv_node_as_float(dfault) : 0);
newPort.minimum(lilv_node_as_float(minimum));
newPort.maximum(lilv_node_as_float(maximum));
lilv_free(dfault);
lilv_free(minimum);
lilv_free(maximum);
} else if (lilv_port_is_a(plugin, port, uris.lv2OutputPort)) {
mcontrolOutput[controlOutputCounter++].index(i);
}
} else if (lilv_port_is_a(plugin, port, uris.lv2AtomPort)) {
LilvNodes *atomBufferType = lilv_port_get_value(plugin, port, uris.lv2AtomBufferType);
LilvNodes *atomSupports = lilv_port_get_value(plugin, port, uris.lv2AtomSupports);
......
......@@ -167,14 +167,22 @@ class AtomPortDef : public PortDef {
class ControlPortDef : public PortDef {
const char *mname;
float mvalue;
float mdfault;
float mminimum;
float mmaximum;
public:
float value;
float dfault;
float minimum;
float maximum;
void name(const char *name) { mname = name; }
const char *name() const { return mname; }
void name(const char *name) { mname = name; }
float value() { return mvalue; }
void value(float value) { mvalue = value; }
float dfault() { return mdfault; }
void dfault(float dfault) { mdfault = dfault; }
float minimum() { return mminimum; }
void minimum(float minimum) { mminimum = minimum; }
float maximum() { return mmaximum; }
void maximum(float maximum) { mmaximum = maximum; }
};
class ControlPort {
......@@ -249,13 +257,15 @@ class PluginType {
const uint32_t maudioInputCount;
PortDef *maudioOutput;
const uint32_t maudioOutputCount;
ControlPortDef *mcontrolInput; // TODO: control outputs?
ControlPortDef *mcontrolInput;
const uint32_t mcontrolInputCount;
ControlPortDef *mcontrolOutput;
const uint32_t mcontrolOutputCount;
AtomPortDef *matomInput;
const uint32_t matomInputCount;
uint32_t mmidiInputCount;
AtomPortDef *matomOutput;
const uint32_t matomOutputCount;
uint32_t mmidiInputCount;
public:
PluginType(const LilvPlugin *plugin, const Constants &uris);
......@@ -263,28 +273,25 @@ class PluginType {
uint32_t audioInputCount() const { return maudioInputCount; }
uint32_t audioOutputCount() const { return maudioOutputCount; }
uint32_t controlInputCount() const { return mcontrolInputCount; }
uint32_t controlOutputCount() const { return mcontrolOutputCount; }
uint32_t atomInputCount() const { return matomInputCount; }
uint32_t midiInputCount() const { return mmidiInputCount; }
uint32_t atomOutputCount() const { return matomOutputCount; }
uint32_t midiInputCount() const { return mmidiInputCount; }
const PortDef &audioInput(uint32_t i) const { return maudioInput[i]; }
const PortDef &audioOutput(uint32_t i) const { return maudioOutput[i]; }
const ControlPortDef &controlInput(uint32_t i) const { return mcontrolInput[i]; }
const ControlPortDef &controlOutput(uint32_t i) const { return mcontrolOutput[i]; }
const AtomPortDef &atomInput(uint32_t i) const { return matomInput[i]; }
const AtomPortDef &atomOutput(uint32_t i) const { return matomOutput[i]; }
};
class Plugin : public audio::Source, public midi::Source, public midi::Sink {
const PluginType *type;
const LilvPlugin *plugin;
LilvInstance *instance;
// event inputs
List<MidiInput> midiInputList;
// event outputs
List<MidiOutput> midiOutputList;
// audio inputs
audio::AudioConnector *audioInput;
// audio outputs
audio::AudioConnection **audioOutput;
List<MidiInput> midiInputList; // event inputs
List<MidiOutput> midiOutputList; // event outputs
audio::AudioConnector *audioInput; // audio inputs
audio::AudioConnection **audioOutput; // audio outputs
// control ports
TimelineSet<ControlEvent> controlBuffer;
std::map<std::string, ControlPort *> controlMap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment