Browse Source

Carla: Cleanup, bridges-related work

tags/v0.9.0
falkTX 13 years ago
parent
commit
ab2dbfa218
16 changed files with 846 additions and 953 deletions
  1. +3
    -2
      .gitignore
  2. +2
    -2
      c++/carla-backend/carla_backend.h
  3. +209
    -48
      c++/carla-backend/carla_engine.cpp
  4. +30
    -29
      c++/carla-backend/carla_engine.h
  5. +52
    -41
      c++/carla-backend/carla_plugin.h
  6. +1
    -1
      c++/carla-backend/carla_shared.cpp
  7. +12
    -6
      c++/carla-backend/carla_threads.cpp
  8. +3
    -3
      c++/carla-backend/dssi.cpp
  9. +3
    -3
      c++/carla-backend/lv2.cpp
  10. +60
    -25
      c++/carla-backend/vst.cpp
  11. +34
    -6
      c++/carla-bridge/Makefile
  12. +4
    -179
      c++/carla-bridge/carla_bridge_osc.cpp
  13. +257
    -456
      c++/carla-bridge/carla_bridge_plugin.cpp
  14. +168
    -145
      c++/carla-discovery/carla-discovery.cpp
  15. +4
    -3
      c++/carla-includes/carla_vst.h
  16. +4
    -4
      src/carla.py

+ 3
- 2
.gitignore View File

@@ -30,10 +30,11 @@ carla-bridge-vst-x11

carla-discovery-qtcreator
carla-discovery-native
carla-discovery-unix32
carla-discovery-unix64
carla-discovery-posix32
carla-discovery-posix64

c++/carla-backend/doxygen/
c++/carla-bridge/doxygen/
c++/carla-includes/vst/
c++/jackmeter/cadence_jackmeter
c++/xycontroller/cadence_xycontroller


+ 2
- 2
c++/carla-backend/carla_backend.h View File

@@ -499,8 +499,8 @@ struct ParameterRanges {

ParameterRanges()
: def(0.0),
min(0.0),
max(1.0),
//min(0.0),
//max(1.0),
step(0.01),
stepSmall(0.0001),
stepLarge(0.1) {}


+ 209
- 48
c++/carla-backend/carla_engine.cpp View File

@@ -113,8 +113,8 @@ bool CarlaEngine::close()

m_checkThread.stopNow();

#ifndef BUILD_BRIDGE
m_oscData = nullptr;
#ifndef BUILD_BRIDGE
m_osc.close();
#endif

@@ -418,14 +418,14 @@ const char* CarlaEngine::getName() const

double CarlaEngine::getSampleRate() const
{
Q_ASSERT(sampleRate != 0.0);
//Q_ASSERT(sampleRate != 0.0);

return sampleRate;
}

uint32_t CarlaEngine::getBufferSize() const
{
Q_ASSERT(bufferSize != 0);
//Q_ASSERT(bufferSize != 0);

return bufferSize;
}
@@ -515,16 +515,12 @@ void CarlaEngine::midiUnlock()
// -----------------------------------------------------------------------
// OSC Stuff

#ifndef BUILD_BRIDGE
bool CarlaEngine::isOscControllerRegisted() const
{
#ifdef BUILD_BRIDGE
return (bool)m_oscData;
#else
return m_osc.isControllerRegistered();
#endif
}

#ifndef BUILD_BRIDGE
const char* CarlaEngine::getOscServerPath() const
{
return m_osc.getServerPath();
@@ -1107,7 +1103,7 @@ void CarlaEngineMidiPort::writeEvent(uint32_t time, const uint8_t* data, uint8_t
// Carla Engine OSC stuff

#ifndef BUILD_BRIDGE
void CarlaEngine::osc_send_add_plugin(const int32_t pluginId, const char* const pluginName)
void CarlaEngine::osc_send_control_add_plugin(const int32_t pluginId, const char* const pluginName)
{
qDebug("CarlaEngine::osc_send_add_plugin(%i, \"%s\")", pluginId, pluginName);
Q_ASSERT(m_oscData);
@@ -1123,7 +1119,7 @@ void CarlaEngine::osc_send_add_plugin(const int32_t pluginId, const char* const
}
}

void CarlaEngine::osc_send_remove_plugin(const int32_t pluginId)
void CarlaEngine::osc_send_control_remove_plugin(const int32_t pluginId)
{
qDebug("CarlaEngine::osc_send_remove_plugin(%i)", pluginId);
Q_ASSERT(m_oscData);
@@ -1137,7 +1133,7 @@ void CarlaEngine::osc_send_remove_plugin(const int32_t pluginId)
}
}

void CarlaEngine::osc_send_set_plugin_data(const int32_t pluginId, const int32_t type, const int32_t category, const int32_t hints, const char* const realName, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId)
void CarlaEngine::osc_send_control_set_plugin_data(const int32_t pluginId, const int32_t type, const int32_t category, const int32_t hints, const char* const realName, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId)
{
qDebug("CarlaEngine::osc_send_set_plugin_data(%i, %i, %i, %i, \"%s\", \"%s\", \"%s\", \"%s\", %li)", pluginId, type, category, hints, realName, label, maker, copyright, uniqueId);
Q_ASSERT(m_oscData);
@@ -1153,7 +1149,7 @@ void CarlaEngine::osc_send_set_plugin_data(const int32_t pluginId, const int32_t
}
}

void CarlaEngine::osc_send_set_plugin_ports(const int32_t pluginId, const int32_t audioIns, const int32_t audioOuts, const int32_t midiIns, const int32_t midiOuts, const int32_t cIns, const int32_t cOuts, const int32_t cTotals)
void CarlaEngine::osc_send_control_set_plugin_ports(const int32_t pluginId, const int32_t audioIns, const int32_t audioOuts, const int32_t midiIns, const int32_t midiOuts, const int32_t cIns, const int32_t cOuts, const int32_t cTotals)
{
qDebug("CarlaEngine::osc_send_set_plugin_ports(%i, %i, %i, %i, %i, %i, %i, %i)", pluginId, audioIns, audioOuts, midiIns, midiOuts, cIns, cOuts, cTotals);
Q_ASSERT(m_oscData);
@@ -1168,7 +1164,7 @@ void CarlaEngine::osc_send_set_plugin_ports(const int32_t pluginId, const int32_
}
}

void CarlaEngine::osc_send_set_parameter_data(const int32_t pluginId, const int32_t index, const int32_t type, const int32_t hints, const char* const name, const char* const label, const double current)
void CarlaEngine::osc_send_control_set_parameter_data(const int32_t pluginId, const int32_t index, const int32_t type, const int32_t hints, const char* const name, const char* const label, const double current)
{
qDebug("CarlaEngine::osc_send_set_parameter_data(%i, %i, %i, %i, \"%s\", \"%s\", %g)", pluginId, index, type, hints, name, label, current);
Q_ASSERT(m_oscData);
@@ -1185,7 +1181,7 @@ void CarlaEngine::osc_send_set_parameter_data(const int32_t pluginId, const int3
}
}

void CarlaEngine::osc_send_set_parameter_ranges(const int32_t pluginId, const int32_t index, const double min, const double max, const double def, const double step, const double stepSmall, const double stepLarge)
void CarlaEngine::osc_send_control_set_parameter_ranges(const int32_t pluginId, const int32_t index, const double min, const double max, const double def, const double step, const double stepSmall, const double stepLarge)
{
qDebug("CarlaEngine::osc_send_set_parameter_ranges(%i, %i, %g, %g, %g, %g, %g, %g)", pluginId, index, min, max, def, step, stepSmall, stepLarge);
Q_ASSERT(m_oscData);
@@ -1202,7 +1198,7 @@ void CarlaEngine::osc_send_set_parameter_ranges(const int32_t pluginId, const in
}
}

void CarlaEngine::osc_send_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc)
void CarlaEngine::osc_send_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc)
{
qDebug("CarlaEngine::osc_send_set_parameter_midi_cc(%i, %i, %i)", pluginId, index, cc);
Q_ASSERT(m_oscData);
@@ -1218,7 +1214,7 @@ void CarlaEngine::osc_send_set_parameter_midi_cc(const int32_t pluginId, const i
}
}

void CarlaEngine::osc_send_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel)
void CarlaEngine::osc_send_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel)
{
qDebug("CarlaEngine::osc_send_set_parameter_midi_channel(%i, %i, %i)", pluginId, index, channel);
Q_ASSERT(m_oscData);
@@ -1235,7 +1231,7 @@ void CarlaEngine::osc_send_set_parameter_midi_channel(const int32_t pluginId, co
}
}

void CarlaEngine::osc_send_set_parameter_value(const int32_t pluginId, const int32_t index, const double value)
void CarlaEngine::osc_send_control_set_parameter_value(const int32_t pluginId, const int32_t index, const double value)
{
#if DEBUG
if (index < 0)
@@ -1255,7 +1251,7 @@ void CarlaEngine::osc_send_set_parameter_value(const int32_t pluginId, const int
}
}

void CarlaEngine::osc_send_set_default_value(const int32_t pluginId, const int32_t index, const double value)
void CarlaEngine::osc_send_control_set_default_value(const int32_t pluginId, const int32_t index, const double value)
{
qDebug("CarlaEngine::osc_send_set_default_value(%i, %i, %g)", pluginId, index, value);
Q_ASSERT(m_oscData);
@@ -1271,7 +1267,7 @@ void CarlaEngine::osc_send_set_default_value(const int32_t pluginId, const int32
}
}

void CarlaEngine::osc_send_set_program(const int32_t pluginId, const int32_t index)
void CarlaEngine::osc_send_control_set_program(const int32_t pluginId, const int32_t index)
{
qDebug("CarlaEngine::osc_send_set_program(%i, %i)", pluginId, index);
Q_ASSERT(m_oscData);
@@ -1286,7 +1282,7 @@ void CarlaEngine::osc_send_set_program(const int32_t pluginId, const int32_t ind
}
}

void CarlaEngine::osc_send_set_program_count(const int32_t pluginId, const int32_t count)
void CarlaEngine::osc_send_control_set_program_count(const int32_t pluginId, const int32_t count)
{
qDebug("CarlaEngine::osc_send_set_program_count(%i, %i)", pluginId, count);
Q_ASSERT(m_oscData);
@@ -1302,7 +1298,7 @@ void CarlaEngine::osc_send_set_program_count(const int32_t pluginId, const int32
}
}

void CarlaEngine::osc_send_set_program_name(const int32_t pluginId, const int32_t index, const char* const name)
void CarlaEngine::osc_send_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name)
{
qDebug("CarlaEngine::osc_send_set_program_name(%i, %i, %s)", pluginId, index, name);
Q_ASSERT(m_oscData);
@@ -1319,7 +1315,7 @@ void CarlaEngine::osc_send_set_program_name(const int32_t pluginId, const int32_
}
}

void CarlaEngine::osc_send_set_midi_program(const int32_t pluginId, const int32_t index)
void CarlaEngine::osc_send_control_set_midi_program(const int32_t pluginId, const int32_t index)
{
qDebug("CarlaEngine::osc_send_set_midi_program(%i, %i)", pluginId, index);
Q_ASSERT(m_oscData);
@@ -1334,7 +1330,7 @@ void CarlaEngine::osc_send_set_midi_program(const int32_t pluginId, const int32_
}
}

void CarlaEngine::osc_send_set_midi_program_count(const int32_t pluginId, const int32_t count)
void CarlaEngine::osc_send_control_set_midi_program_count(const int32_t pluginId, const int32_t count)
{
qDebug("CarlaEngine::osc_send_set_midi_program_count(%i, %i)", pluginId, count);
Q_ASSERT(m_oscData);
@@ -1350,7 +1346,7 @@ void CarlaEngine::osc_send_set_midi_program_count(const int32_t pluginId, const
}
}

void CarlaEngine::osc_send_set_midi_program_data(const int32_t pluginId, const int32_t index, const int32_t bank, const int32_t program, const char* const name)
void CarlaEngine::osc_send_control_set_midi_program_data(const int32_t pluginId, const int32_t index, const int32_t bank, const int32_t program, const char* const name)
{
qDebug("CarlaEngine::osc_send_set_midi_program_data(%i, %i, %i, %i, %s)", pluginId, index, bank, program, name);
Q_ASSERT(m_oscData);
@@ -1369,7 +1365,42 @@ void CarlaEngine::osc_send_set_midi_program_data(const int32_t pluginId, const i
}
}

void CarlaEngine::osc_send_set_input_peak_value(const int32_t pluginId, const int32_t portId, const double value)
void CarlaEngine::osc_send_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo)
{
qDebug("CarlaEngine::osc_send_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
Q_ASSERT(m_oscData);
Q_ASSERT(pluginId >= 0 && pluginId < maxPluginNumber);
Q_ASSERT(channel >= 0 && channel < 16);
Q_ASSERT(note >= 0 && note < 128);
Q_ASSERT(velo > 0 && velo < 128);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+9];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/note_on");
lo_send(m_oscData->target, target_path, "iiii", pluginId, channel, note, velo);
}
}

void CarlaEngine::osc_send_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note)
{
qDebug("CarlaEngine::osc_send_note_off(%i, %i, %i)", pluginId, channel, note);
Q_ASSERT(m_oscData);
Q_ASSERT(pluginId >= 0 && pluginId < maxPluginNumber);
Q_ASSERT(channel >= 0 && channel < 16);
Q_ASSERT(note >= 0 && note < 128);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+10];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/note_off");
lo_send(m_oscData->target, target_path, "iii", pluginId, channel, note);
}
}

void CarlaEngine::osc_send_control_set_input_peak_value(const int32_t pluginId, const int32_t portId, const double value)
{
qDebug("CarlaEngine::osc_send_set_input_peak_value(%i, %i, %g)", pluginId, portId, value);
Q_ASSERT(m_oscData);
@@ -1385,7 +1416,7 @@ void CarlaEngine::osc_send_set_input_peak_value(const int32_t pluginId, const in
}
}

void CarlaEngine::osc_send_set_output_peak_value(const int32_t pluginId, const int32_t portId, const double value)
void CarlaEngine::osc_send_control_set_output_peak_value(const int32_t pluginId, const int32_t portId, const double value)
{
qDebug("CarlaEngine::osc_send_set_output_peak_value(%i, %i, %g)", pluginId, portId, value);
Q_ASSERT(m_oscData);
@@ -1401,52 +1432,182 @@ void CarlaEngine::osc_send_set_output_peak_value(const int32_t pluginId, const i
}
}

void CarlaEngine::osc_send_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo)
void CarlaEngine::osc_send_control_exit()
{
qDebug("CarlaEngine::osc_send_note_on(%i, %i, %i, %i)", pluginId, channel, note, velo);
qDebug("CarlaEngine::osc_send_exit()");
Q_ASSERT(m_oscData);
Q_ASSERT(pluginId >= 0 && pluginId < maxPluginNumber);
Q_ASSERT(channel >= 0 && channel < 16);
Q_ASSERT(note >= 0 && note < 128);
Q_ASSERT(velo >= 0 && velo < 128);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+9];
char target_path[strlen(m_oscData->path)+6];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/note_on");
lo_send(m_oscData->target, target_path, "iiii", pluginId, channel, note, velo);
strcat(target_path, "/exit");
lo_send(m_oscData->target, target_path, "");
}
}
#else
void CarlaEngine::osc_send_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total)
{
qDebug("CarlaEngine::osc_send_bridge_audio_count(%i, %i, %i)", ins, outs, total);
Q_ASSERT(m_oscData);
Q_ASSERT(total >= 0 && total >= ins + outs);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+20];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/bridge_audio_count");
lo_send(m_oscData->target, target_path, "iii", ins, outs, total);
}
}

void CarlaEngine::osc_send_note_off(const int32_t pluginId, const int32_t channel, const int32_t note)
void CarlaEngine::osc_send_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total)
{
qDebug("CarlaEngine::osc_send_note_off(%i, %i, %i)", pluginId, channel, note);
qDebug("CarlaEngine::osc_send_bridge_midi_count(%i, %i, %i)", ins, outs, total);
Q_ASSERT(m_oscData);
Q_ASSERT(pluginId >= 0 && pluginId < maxPluginNumber);
Q_ASSERT(channel >= 0 && channel < 16);
Q_ASSERT(note >= 0 && note < 128);
Q_ASSERT(total >= 0 && total >= ins + outs);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+10];
char target_path[strlen(m_oscData->path)+19];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/note_off");
lo_send(m_oscData->target, target_path, "iii", pluginId, channel, note);
strcat(target_path, "/bridge_midi_count");
lo_send(m_oscData->target, target_path, "iii", ins, outs, total);
}
}

void CarlaEngine::osc_send_exit()
void CarlaEngine::osc_send_bridge_param_count(const int32_t ins, const int32_t outs, const int32_t total)
{
qDebug("CarlaEngine::osc_send_exit()");
qDebug("CarlaEngine::osc_send_bridge_param_count(%i, %i, %i)", ins, outs, total);
Q_ASSERT(m_oscData);
Q_ASSERT(total >= 0 && total >= ins + outs);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+6];
char target_path[strlen(m_oscData->path)+20];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/exit");
lo_send(m_oscData->target, target_path, "");
strcat(target_path, "/bridge_param_count");
lo_send(m_oscData->target, target_path, "iii", ins, outs, total);
}
}

void CarlaEngine::osc_send_bridge_program_count(const int32_t count)
{
qDebug("CarlaEngine::osc_send_bridge_program_count(%i)", count);
Q_ASSERT(m_oscData);
Q_ASSERT(count >= 0);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+22];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/bridge_program_count");
lo_send(m_oscData->target, target_path, "i", count);
}
}

void CarlaEngine::osc_send_bridge_midi_program_count(const int32_t count)
{
qDebug("CarlaEngine::osc_send_bridge_midi_program_count(%i)", count);
Q_ASSERT(m_oscData);
Q_ASSERT(count >= 0);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+27];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/bridge_midi_program_count");
lo_send(m_oscData->target, target_path, "i", count);
}
}

void CarlaEngine::osc_send_bridge_plugin_info(const int32_t category, const int32_t hints, const char* const name, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId)
{
qDebug("CarlaEngine::osc_send_bridge_plugin_info(%i, %i, \"%s\", \"%s\", \"%s\", \"%s\", %li)", category, hints, name, label, maker, copyright, uniqueId);
Q_ASSERT(m_oscData);
Q_ASSERT(name);
Q_ASSERT(label);
Q_ASSERT(maker);
Q_ASSERT(copyright);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+27];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/bridge_plugin_info");
lo_send(m_oscData->target, target_path, "iissssh", category, hints, name, label, maker, copyright, uniqueId);
}
}

void CarlaEngine::osc_send_bridge_param_info(const int32_t index, const char* const name, const char* const unit)
{
qDebug("CarlaEngine::osc_send_bridge_param_info(%i, \"%s\", \"%s\")", index, name, unit);
Q_ASSERT(m_oscData);
Q_ASSERT(name);
Q_ASSERT(unit);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+27];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/bridge_param_info");
lo_send(m_oscData->target, target_path, "iss", index, name, unit);
}
}

void CarlaEngine::osc_send_bridge_param_data(const int32_t index, const int32_t type, const int32_t rindex, const int32_t hints, const int32_t midiChannel, const int32_t midiCC)
{
qDebug("CarlaEngine::osc_send_bridge_param_data(%i, %i, %i, %i, %i, %i)", index, type, rindex, hints, midiChannel, midiCC);
Q_ASSERT(m_oscData);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+27];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/bridge_param_data");
lo_send(m_oscData->target, target_path, "iiiiii", index, type, rindex, hints, midiChannel, midiCC);
}
}

void CarlaEngine::osc_send_bridge_param_ranges(const int32_t index, const double def, const double min, const double max, const double step, const double stepSmall, const double stepLarge)
{
qDebug("CarlaEngine::osc_send_bridge_param_ranges(%i, %g, %g, %g, %g, %g, %g)", index, def, min, max, step, stepSmall, stepLarge);
Q_ASSERT(m_oscData);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+27];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/bridge_param_ranges");
lo_send(m_oscData->target, target_path, "idddddd", index, def, min, max, step, stepSmall, stepLarge);
}
}

void CarlaEngine::osc_send_bridge_program_info(const int32_t index, const char* const name)
{
//qDebug("CarlaEngine::osc_send_bridge_program_info(%i, \"%s\")", index, name);
Q_ASSERT(m_oscData);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+27];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/bridge_midi_program_info");
lo_send(m_oscData->target, target_path, "is", index, name);
}
}

void CarlaEngine::osc_send_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label)
{
qDebug("CarlaEngine::osc_send_bridge_midi_program_info(%i, %i, %i, \"%s\")", index, bank, program, label);
Q_ASSERT(m_oscData);

if (m_oscData && m_oscData->target)
{
char target_path[strlen(m_oscData->path)+27];
strcpy(target_path, m_oscData->path);
strcat(target_path, "/bridge_midi_program_info");
lo_send(m_oscData->target, target_path, "iiis", index, bank, program, label);
}
}
#endif


+ 30
- 29
c++/carla-backend/carla_engine.h View File

@@ -258,51 +258,52 @@ public:
// -------------------------------------------------------------------
// OSC Stuff

bool isOscControllerRegisted() const;
#ifndef BUILD_BRIDGE
bool isOscControllerRegisted() const;
const char* getOscServerPath() const;
#else
void setOscBridgeData(const CarlaOscData* const oscData);
#endif

void osc_send_set_default_value(const int32_t pluginId, const int32_t index, const double value);
void osc_send_set_parameter_value(const int32_t pluginId, const int32_t index, const double value);
void osc_send_set_program(const int32_t pluginId, const int32_t index);
void osc_send_set_midi_program(const int32_t pluginId, const int32_t index);
void osc_send_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo);
void osc_send_note_off(const int32_t pluginId, const int32_t channel, const int32_t note);
void osc_send_set_input_peak_value(const int32_t pluginId, const int32_t portId, const double value);
void osc_send_set_output_peak_value(const int32_t pluginId, const int32_t portId, const double value);

#ifndef BUILD_BRIDGE
void osc_send_add_plugin(const int32_t pluginId, const char* const pluginName);
void osc_send_remove_plugin(const int32_t pluginId);
void osc_send_set_plugin_data(const int32_t pluginId, const int32_t type, const int32_t category, const int32_t hints, const char* const realName, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId);
void osc_send_set_plugin_ports(const int32_t pluginId, const int32_t audioIns, const int32_t audioOuts, const int32_t midiIns, const int32_t midiOuts, const int32_t cIns, const int32_t cOuts, const int32_t cTotals);
void osc_send_set_parameter_data(const int32_t pluginId, const int32_t index, const int32_t type, const int32_t hints, const char* const name, const char* const label, const double current);
void osc_send_set_parameter_ranges(const int32_t pluginId, const int32_t index, const double min, const double max, const double def, const double step, const double stepSmall, const double stepLarge);
void osc_send_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc);
void osc_send_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel);
void osc_send_set_program_count(const int32_t pluginId, const int32_t count);
void osc_send_set_program_name(const int32_t pluginId, const int32_t index, const char* const name);
void osc_send_set_midi_program_count(const int32_t pluginId, const int32_t count);
void osc_send_set_midi_program_data(const int32_t pluginId, const int32_t index, const int32_t bank, const int32_t program, const char* const name);
void osc_send_exit();
#else
#ifdef BUILD_BRIDGE
void osc_send_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total);
void osc_send_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total);
void osc_send_bridge_param_count(const int32_t ins, const int32_t outs, const int32_t total);
void osc_send_bridge_program_count(const int32_t count);
void osc_send_bridge_midi_program_count(const int32_t count);
void osc_send_bridge_plugin_info(const int32_t category, const int32_t hints, const char* const name, const char* const label, const char* const maker, const char* const copyright, const long uniqueId);
void osc_send_bridge_plugin_info(const int32_t category, const int32_t hints, const char* const name, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId);
void osc_send_bridge_param_info(const int32_t index, const char* const name, const char* const unit);
void osc_send_bridge_param_data(const int32_t index, const int32_t type, const int32_t rindex, const int32_t hints, const int32_t midiChannel, const int32_t midiCC);
void osc_send_bridge_param_ranges(const int32_t index, const double def, const double min, const double max, const double step, const double stepSmall, const double stepLarge);
void osc_send_bridge_program_info(const int32_t index, const char* const name);
void osc_send_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label);
void osc_send_bridge_custom_data(const char* const stype, const char* const key, const char* const value);
void osc_send_bridge_chunk_data(const char* const stringData);
void osc_send_bridge_update();
//void osc_send_bridge_program(const int32_t index);
//void osc_send_bridge_midi_program(const int32_t index);
//void osc_send_bridge_custom_data(const char* const stype, const char* const key, const char* const value);
//void osc_send_bridge_chunk_data(const char* const stringData);
//void osc_send_bridge_update();
#else
void osc_send_control_add_plugin(const int32_t pluginId, const char* const pluginName);
void osc_send_control_remove_plugin(const int32_t pluginId);
void osc_send_control_set_plugin_data(const int32_t pluginId, const int32_t type, const int32_t category, const int32_t hints, const char* const realName, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId);
void osc_send_control_set_plugin_ports(const int32_t pluginId, const int32_t audioIns, const int32_t audioOuts, const int32_t midiIns, const int32_t midiOuts, const int32_t cIns, const int32_t cOuts, const int32_t cTotals);
void osc_send_control_set_parameter_data(const int32_t pluginId, const int32_t index, const int32_t type, const int32_t hints, const char* const name, const char* const label, const double current);
void osc_send_control_set_parameter_ranges(const int32_t pluginId, const int32_t index, const double min, const double max, const double def, const double step, const double stepSmall, const double stepLarge);
void osc_send_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc);
void osc_send_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel);
void osc_send_control_set_parameter_value(const int32_t pluginId, const int32_t index, const double value);
void osc_send_control_set_default_value(const int32_t pluginId, const int32_t index, const double value);
void osc_send_control_set_program(const int32_t pluginId, const int32_t index);
void osc_send_control_set_program_count(const int32_t pluginId, const int32_t count);
void osc_send_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name);
void osc_send_control_set_midi_program(const int32_t pluginId, const int32_t index);
void osc_send_control_set_midi_program_count(const int32_t pluginId, const int32_t count);
void osc_send_control_set_midi_program_data(const int32_t pluginId, const int32_t index, const int32_t bank, const int32_t program, const char* const name);
void osc_send_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo);
void osc_send_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note);
void osc_send_control_set_input_peak_value(const int32_t pluginId, const int32_t portId, const double value);
void osc_send_control_set_output_peak_value(const int32_t pluginId, const int32_t portId, const double value);
void osc_send_control_exit();
#endif

#ifndef BUILD_BRIDGE


+ 52
- 41
c++/carla-backend/carla_plugin.h View File

@@ -788,7 +788,7 @@ public:
#ifndef BUILD_BRIDGE
if (sendOsc)
{
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_ACTIVE, value);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_ACTIVE, value);

if (m_hints & PLUGIN_IS_BRIDGE)
osc_send_control(&osc.data, PARAMETER_ACTIVE, value);
@@ -822,7 +822,7 @@ public:
#ifndef BUILD_BRIDGE
if (sendOsc)
{
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_DRYWET, value);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_DRYWET, value);

if (m_hints & PLUGIN_IS_BRIDGE)
osc_send_control(&osc.data, PARAMETER_DRYWET, value);
@@ -856,7 +856,7 @@ public:
#ifndef BUILD_BRIDGE
if (sendOsc)
{
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_VOLUME, value);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_VOLUME, value);

if (m_hints & PLUGIN_IS_BRIDGE)
osc_send_control(&osc.data, PARAMETER_VOLUME, value);
@@ -890,7 +890,7 @@ public:
#ifndef BUILD_BRIDGE
if (sendOsc)
{
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_BALANCE_LEFT, value);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_BALANCE_LEFT, value);

if (m_hints & PLUGIN_IS_BRIDGE)
osc_send_control(&osc.data, PARAMETER_BALANCE_LEFT, value);
@@ -924,7 +924,7 @@ public:
#ifndef BUILD_BRIDGE
if (sendOsc)
{
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_BALANCE_RIGHT, value);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_BALANCE_RIGHT, value);

if (m_hints & PLUGIN_IS_BRIDGE)
osc_send_control(&osc.data, PARAMETER_BALANCE_RIGHT, value);
@@ -973,7 +973,7 @@ public:
#ifndef BUILD_BRIDGE
if (sendOsc)
{
x_engine->osc_send_set_parameter_value(m_id, parameterId, value);
x_engine->osc_send_control_set_parameter_value(m_id, parameterId, value);

if (m_hints & PLUGIN_IS_BRIDGE)
osc_send_control(&osc.data, parameterId, value);
@@ -1034,7 +1034,7 @@ public:

#ifndef BUILD_BRIDGE
if (sendOsc)
x_engine->osc_send_set_parameter_midi_channel(m_id, parameterId, channel);
x_engine->osc_send_control_set_parameter_midi_channel(m_id, parameterId, channel);
#else
Q_UNUSED(sendOsc);
#endif
@@ -1058,7 +1058,7 @@ public:

#ifndef BUILD_BRIDGE
if (sendOsc)
x_engine->osc_send_set_parameter_midi_cc(m_id, parameterId, cc);
x_engine->osc_send_control_set_parameter_midi_cc(m_id, parameterId, cc);
#else
Q_UNUSED(sendOsc);
#endif
@@ -1175,7 +1175,7 @@ public:
#ifndef BUILD_BRIDGE
if (sendOsc)
{
x_engine->osc_send_set_program(m_id, index);
x_engine->osc_send_control_set_program(m_id, index);

if (m_hints & PLUGIN_IS_BRIDGE)
osc_send_program(&osc.data, index);
@@ -1193,7 +1193,7 @@ public:

#ifndef BUILD_BRIDGE
if (sendOsc)
x_engine->osc_send_set_default_value(m_id, i, param.ranges[i].def);
x_engine->osc_send_control_set_default_value(m_id, i, param.ranges[i].def);
#endif
}
}
@@ -1233,7 +1233,7 @@ public:
#ifndef BUILD_BRIDGE
if (sendOsc)
{
x_engine->osc_send_set_midi_program(m_id, index);
x_engine->osc_send_control_set_midi_program(m_id, index);

if (m_hints & PLUGIN_IS_BRIDGE)
osc_send_midi_program(&osc.data, index);
@@ -1251,7 +1251,7 @@ public:

#ifndef BUILD_BRIDGE
if (sendOsc)
x_engine->osc_send_set_default_value(m_id, i, param.ranges[i].def);
x_engine->osc_send_control_set_default_value(m_id, i, param.ranges[i].def);
#endif
}
}
@@ -1315,13 +1315,13 @@ public:
if (m_hints & PLUGIN_USES_SINGLE_THREAD)
{
// Process postponed events
postEventsRun();
//postEventsRun();

// Update parameter outputs
for (uint32_t i=0; i < param.count; i++)
{
if (param.data[i].type == PARAMETER_OUTPUT)
uiParameterChange(i, getParameterValue(i));
//if (param.data[i].type == PARAMETER_OUTPUT)
// uiParameterChange(i, getParameterValue(i));
}
}
}
@@ -1420,11 +1420,12 @@ public:
*/
void registerToOsc()
{
return;
#ifndef BUILD_BRIDGE
if (! x_engine->isOscControllerRegisted())
return;

x_engine->osc_send_add_plugin(m_id, m_name);
x_engine->osc_send_control_add_plugin(m_id, m_name);
#endif

// Base data
@@ -1441,7 +1442,7 @@ public:
#ifdef BUILD_BRIDGE
x_engine->osc_send_bridge_plugin_info(category(), m_hints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId());
#else
x_engine->osc_send_set_plugin_data(m_id, m_type, category(), m_hints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId());
x_engine->osc_send_control_set_plugin_data(m_id, m_type, category(), m_hints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId());
#endif
}

@@ -1455,18 +1456,18 @@ public:
x_engine->osc_send_bridge_midi_count(midiInCount(), midiOutCount(), midiInCount() + midiOutCount());
x_engine->osc_send_bridge_param_count(cIns, cOuts, cTotals);
#else
x_engine->osc_send_set_plugin_ports(m_id, audioInCount(), audioOutCount(), midiInCount(), midiOutCount(), cIns, cOuts, cTotals);
x_engine->osc_send_control_set_plugin_ports(m_id, audioInCount(), audioOutCount(), midiInCount(), midiOutCount(), cIns, cOuts, cTotals);
#endif
}

// Internal Parameters
{
#ifndef BUILD_BRIDGE
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_ACTIVE, m_active ? 1.0 : 0.0);
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_DRYWET, x_dryWet);
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_VOLUME, x_volume);
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_BALANCE_LEFT, x_balanceLeft);
x_engine->osc_send_set_parameter_value(m_id, PARAMETER_BALANCE_RIGHT, x_balanceRight);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_ACTIVE, m_active ? 1.0 : 0.0);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_DRYWET, x_dryWet);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_VOLUME, x_volume);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_BALANCE_LEFT, x_balanceLeft);
x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_BALANCE_RIGHT, x_balanceRight);
#endif
}

@@ -1491,8 +1492,8 @@ public:
x_engine->osc_send_bridge_param_ranges(i, param.ranges[i].def, param.ranges[i].min, param.ranges[i].max, param.ranges[i].step, param.ranges[i].stepSmall, param.ranges[i].stepLarge);
setParameterValue(i, param.ranges[i].def, false, false, true); // FIXME?
#else
x_engine->osc_send_set_parameter_data(m_id, i, param.data[i].type, param.data[i].hints, bufName, bufUnit, getParameterValue(i));
x_engine->osc_send_set_parameter_ranges(m_id, i, param.ranges[i].min, param.ranges[i].max, param.ranges[i].def, param.ranges[i].step, param.ranges[i].stepSmall, param.ranges[i].stepLarge);
x_engine->osc_send_control_set_parameter_data(m_id, i, param.data[i].type, param.data[i].hints, bufName, bufUnit, getParameterValue(i));
x_engine->osc_send_control_set_parameter_ranges(m_id, i, param.ranges[i].min, param.ranges[i].max, param.ranges[i].def, param.ranges[i].step, param.ranges[i].stepSmall, param.ranges[i].stepLarge);
#endif
}
}
@@ -1507,12 +1508,12 @@ public:

//x_engine->osc_send_program(prog.current);
#else
x_engine->osc_send_set_program_count(m_id, prog.count);
x_engine->osc_send_control_set_program_count(m_id, prog.count);

for (uint32_t i=0; i < prog.count; i++)
x_engine->osc_send_set_program_name(m_id, i, prog.names[i]);
x_engine->osc_send_control_set_program_name(m_id, i, prog.names[i]);

x_engine->osc_send_set_program(m_id, prog.current);
x_engine->osc_send_control_set_program(m_id, prog.current);
#endif
}

@@ -1526,12 +1527,12 @@ public:

//x_engine->osc_send_midi_program(midiprog.current);
#else
x_engine->osc_send_set_midi_program_count(m_id, midiprog.count);
x_engine->osc_send_control_set_midi_program_count(m_id, midiprog.count);

for (uint32_t i=0; i < midiprog.count; i++)
x_engine->osc_send_set_midi_program_data(m_id, i, midiprog.data[i].bank, midiprog.data[i].program, midiprog.data[i].name);
x_engine->osc_send_control_set_midi_program_data(m_id, i, midiprog.data[i].bank, midiprog.data[i].program, midiprog.data[i].name);

x_engine->osc_send_set_midi_program(m_id, midiprog.current);
x_engine->osc_send_control_set_midi_program(m_id, midiprog.current);
#endif
}
}
@@ -1662,9 +1663,9 @@ public:
if (sendOsc)
{
if (velo)
x_engine->osc_send_note_on(m_id, channel, note, velo);
x_engine->osc_send_control_note_on(m_id, channel, note, velo);
else
x_engine->osc_send_note_off(m_id, channel, note);
x_engine->osc_send_control_note_off(m_id, channel, note);

if (m_hints & PLUGIN_IS_BRIDGE)
{
@@ -1783,8 +1784,10 @@ public:
if (event->value1 >= 0)
uiParameterChange(event->value1, event->value3);

#ifndef BUILD_BRIDGE
// Update OSC control client
x_engine->osc_send_set_parameter_value(m_id, event->value1, event->value3);
x_engine->osc_send_control_set_parameter_value(m_id, event->value1, event->value3);
#endif

// Update Host
x_engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, m_id, event->value1, 0, event->value3);
@@ -1795,11 +1798,13 @@ public:
if (event->value1 >= 0)
uiProgramChange(event->value1);

#ifndef BUILD_BRIDGE
// Update OSC control client
x_engine->osc_send_set_program(m_id, event->value1);
x_engine->osc_send_control_set_program(m_id, event->value1);

for (uint32_t j=0; j < param.count; j++)
x_engine->osc_send_set_default_value(m_id, j, param.ranges[j].def);
x_engine->osc_send_control_set_default_value(m_id, j, param.ranges[j].def);
#endif

// Update Host
x_engine->callback(CALLBACK_PROGRAM_CHANGED, m_id, event->value1, 0, 0.0);
@@ -1810,11 +1815,13 @@ public:
if (event->value1 >= 0)
uiMidiProgramChange(event->value1);

#ifndef BUILD_BRIDGE
// Update OSC control client
x_engine->osc_send_set_midi_program(m_id, event->value1);
x_engine->osc_send_control_set_midi_program(m_id, event->value1);

for (uint32_t j=0; j < param.count; j++)
x_engine->osc_send_set_default_value(m_id, j, param.ranges[j].def);
x_engine->osc_send_control_set_default_value(m_id, j, param.ranges[j].def);
#endif

// Update Host
x_engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, m_id, event->value1, 0, 0.0);
@@ -1824,8 +1831,10 @@ public:
// Update UI
uiNoteOn(event->value1, event->value2, rint(event->value3));

#ifndef BUILD_BRIDGE
// Update OSC control client
x_engine->osc_send_note_on(m_id, event->value1, event->value2, event->value3);
x_engine->osc_send_control_note_on(m_id, event->value1, event->value2, rint(event->value3));
#endif

// Update Host
x_engine->callback(CALLBACK_NOTE_ON, m_id, event->value1, event->value2, event->value3);
@@ -1835,8 +1844,10 @@ public:
// Update UI
uiNoteOff(event->value1, event->value2);

#ifndef BUILD_BRIDGE
// Update OSC control client
x_engine->osc_send_note_off(m_id, event->value1, event->value2);
x_engine->osc_send_control_note_off(m_id, event->value1, event->value2);
#endif

// Update Host
x_engine->callback(CALLBACK_NOTE_OFF, m_id, event->value1, event->value2, 0.0);
@@ -1880,7 +1891,7 @@ public:
{
Q_ASSERT(channel < 16);
Q_ASSERT(note < 128);
Q_ASSERT(velo < 128);
Q_ASSERT(velo > 0 && velo < 128);

Q_UNUSED(channel);
Q_UNUSED(note);


+ 1
- 1
c++/carla-backend/carla_shared.cpp View File

@@ -384,7 +384,7 @@ const char* getBinaryBidgePath(const BinaryType type)
void* getPointer(const quintptr addr)
{
Q_ASSERT(addr != 0);
qDebug("CarlaBackend::getPointer(" P_UINTPTR ")", addr);
//qDebug("CarlaBackend::getPointer(" P_UINTPTR ")", addr);

quintptr* const ptr = (quintptr*)addr;
return (void*)ptr;


+ 12
- 6
c++/carla-backend/carla_threads.cpp View File

@@ -63,7 +63,7 @@ void CarlaCheckThread::run()
{
qDebug("CarlaCheckThread::run()");

bool oscControllerRegisted, usesSingleThread;
bool usesSingleThread, oscControllerRegisted = false;
unsigned short id;
double value;

@@ -72,7 +72,9 @@ void CarlaCheckThread::run()
while (engine->isRunning() && ! m_stopNow)
{
const ScopedLocker m(this);
#ifndef BUILD_BRIDGE
oscControllerRegisted = engine->isOscControllerRegisted();
#endif

for (unsigned short i=0; i < maxPluginNumber; i++)
{
@@ -104,13 +106,16 @@ void CarlaCheckThread::run()
if (! usesSingleThread)
plugin->uiParameterChange(i, value);

#ifndef BUILD_BRIDGE
// Update OSC control client
if (oscControllerRegisted)
engine->osc_send_set_parameter_value(id, i, value);
engine->osc_send_control_set_parameter_value(id, i, value);
#endif
}
}
}

#ifndef BUILD_BRIDGE
// -------------------------------------------------------
// Update OSC control client

@@ -119,15 +124,16 @@ void CarlaCheckThread::run()
// Peak values
if (plugin->audioInCount() > 0)
{
engine->osc_send_set_input_peak_value(id, 1, engine->getInputPeak(id, 0));
engine->osc_send_set_input_peak_value(id, 2, engine->getInputPeak(id, 1));
engine->osc_send_control_set_input_peak_value(id, 1, engine->getInputPeak(id, 0));
engine->osc_send_control_set_input_peak_value(id, 2, engine->getInputPeak(id, 1));
}
if (plugin->audioOutCount() > 0)
{
engine->osc_send_set_output_peak_value(id, 1, engine->getOutputPeak(id, 0));
engine->osc_send_set_output_peak_value(id, 2, engine->getOutputPeak(id, 1));
engine->osc_send_control_set_output_peak_value(id, 1, engine->getOutputPeak(id, 0));
engine->osc_send_control_set_output_peak_value(id, 2, engine->getOutputPeak(id, 1));
}
}
#endif
}
}



+ 3
- 3
c++/carla-backend/dssi.cpp View File

@@ -742,10 +742,10 @@ public:

#ifndef BUILD_BRIDGE
// Update OSC Names
x_engine->osc_send_set_midi_program_count(m_id, midiprog.count);
x_engine->osc_send_control_set_midi_program_count(m_id, midiprog.count);

for (i=0; i < midiprog.count; i++)
x_engine->osc_send_set_midi_program_data(m_id, i, midiprog.data[i].bank, midiprog.data[i].program, midiprog.data[i].name);
x_engine->osc_send_control_set_midi_program_data(m_id, i, midiprog.data[i].bank, midiprog.data[i].program, midiprog.data[i].name);
#endif

if (init)
@@ -1367,7 +1367,7 @@ public:
{
Q_ASSERT(channel < 16);
Q_ASSERT(note < 128);
Q_ASSERT(velo < 128);
Q_ASSERT(velo > 0 && velo < 128);

if (! osc.data.target)
return;


+ 3
- 3
c++/carla-backend/lv2.cpp View File

@@ -1706,10 +1706,10 @@ public:

#ifndef BUILD_BRIDGE
// Update OSC Names
x_engine->osc_send_set_midi_program_count(m_id, midiprog.count);
x_engine->osc_send_control_set_midi_program_count(m_id, midiprog.count);

for (i=0; i < midiprog.count; i++)
x_engine->osc_send_set_midi_program_data(m_id, i, midiprog.data[i].bank, midiprog.data[i].program, midiprog.data[i].name);
x_engine->osc_send_control_set_midi_program_data(m_id, i, midiprog.data[i].bank, midiprog.data[i].program, midiprog.data[i].name);
#endif

if (init)
@@ -2574,7 +2574,7 @@ public:
{
Q_ASSERT(channel < 16);
Q_ASSERT(note < 128);
Q_ASSERT(velo < 128);
Q_ASSERT(velo > 0 && velo < 128);

#ifndef BUILD_BRIDGE
if (gui.type == GUI_EXTERNAL_OSC)


+ 60
- 25
c++/carla-backend/vst.cpp View File

@@ -331,6 +331,9 @@ public:

void setGuiData(const int data, const GuiDataHandle handle)
{
qDebug("VstPlugin::setGuiData(%i, %p)", data, handle);
Q_ASSERT(handle);

if (gui.type == GUI_EXTERNAL_OSC)
return;

@@ -343,14 +346,16 @@ public:
{
ERect* vstRect = nullptr;

if (effect->dispatcher(effect, effEditGetRect, 0, 0, &vstRect, 0.0f) && vstRect)
effect->dispatcher(effect, effEditGetRect, 0, 0, &vstRect, 0.0f);

if (vstRect)
{
int width = vstRect->right - vstRect->left;
int height = vstRect->bottom - vstRect->top;

if (width <= 0 || height <= 0)
{
qCritical("Failed to get proper Plugin Window size");
qCritical("VstPlugin::setGuiData(%i, %p) - failed to get proper window size", data, handle);
return;
}

@@ -358,7 +363,7 @@ public:
gui.height = height;
}
else
qCritical("Failed to get Plugin Window size");
qCritical("VstPlugin::setGuiData(%i, %p) - failed to get plugin window size", data, handle);
}
else
{
@@ -412,13 +417,15 @@ public:

void idleGui()
{
//effect->dispatcher(effect, effIdle, 0, 0, nullptr, 0.0f);
qDebug("VstPlugin::idleGui()");

effect->dispatcher(effect, effIdle, 0, 0, nullptr, 0.0f);

// FIXME
if (gui.type != GUI_EXTERNAL_OSC && gui.visible)
//if (gui.type != GUI_EXTERNAL_OSC && gui.visible)
effect->dispatcher(effect, effEditIdle, 0, 0, nullptr, 0.0f);

CarlaPlugin::idleGui();
//CarlaPlugin::idleGui();
}

// -------------------------------------------------------------------
@@ -448,10 +455,10 @@ public:
aOuts = effect->numOutputs;
params = effect->numParams;

if (VstPluginCanDo(effect, "receiveVstEvents") || VstPluginCanDo(effect, "receiveVstMidiEvent") || (effect->flags & effFlagsIsSynth) > 0 || (m_hints & PLUGIN_WANTS_MIDI_INPUT))
if (vstPluginCanDo(effect, "receiveVstEvents") || vstPluginCanDo(effect, "receiveVstMidiEvent") || (effect->flags & effFlagsIsSynth) > 0 || (m_hints & PLUGIN_WANTS_MIDI_INPUT))
mIns = 1;

if (VstPluginCanDo(effect, "sendVstEvents") || VstPluginCanDo(effect, "sendVstMidiEvent"))
if (vstPluginCanDo(effect, "sendVstEvents") || vstPluginCanDo(effect, "sendVstMidiEvent"))
mOuts = 1;

if (aIns > 0)
@@ -734,10 +741,10 @@ public:

#ifndef BUILD_BRIDGE
// Update OSC Names
x_engine->osc_send_set_program_count(m_id, prog.count);
x_engine->osc_send_control_set_program_count(m_id, prog.count);

for (i=0; i < prog.count; i++)
x_engine->osc_send_set_program_name(m_id, i, prog.names[i]);
x_engine->osc_send_control_set_program_name(m_id, i, prog.names[i]);
#endif

if (init)
@@ -1348,7 +1355,7 @@ public:
{
Q_ASSERT(channel < 16);
Q_ASSERT(note < 128);
Q_ASSERT(velo < 128);
Q_ASSERT(velo > 0 && velo < 128);

if (gui.type == GUI_EXTERNAL_OSC && osc.data.target)
{
@@ -1570,9 +1577,11 @@ public:
m_hints |= PLUGIN_WANTS_MIDI_INPUT;
}

static intptr_t handleAudioMasterCanDo(const char* const feature)
// -------------------------------------------------------------------

static intptr_t hostCanDo(const char* const feature)
{
qDebug("VstPlugin::handleAudioMasterCanDo(\"%s\")", feature);
qDebug("VstPlugin::hostCanDo(\"%s\")", feature);

if (strcmp(feature, "supplyIdle") == 0)
return 1;
@@ -1610,18 +1619,18 @@ public:
return -1;

// unimplemented
qWarning("VstPlugin::handleAudioMasterCanDo(\"%s\") - unknown feature", feature);
qWarning("VstPlugin::hostCanDo(\"%s\") - unknown feature", feature);
return 0;
}

// -------------------------------------------------------------------

static intptr_t VstHostCallback(AEffect* effect, int32_t opcode, int32_t index, intptr_t value, void* ptr, float opt)
static intptr_t VSTCALLBACK hostCallback(AEffect* const effect, const int32_t opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt)
{
#ifdef DEBUG
qDebug("VstHostCallback(%p, opcode: %s, index: %i, value: " P_INTPTR ", opt: %f", effect, VstMasterOpcode2str(opcode), index, value, opt);
if (opcode != audioMasterGetTime)
qDebug("VstPlugin::hostCallback(%p, %s, %i, " P_INTPTR ", %p, %f", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
#endif

#if 0
// Cockos VST extensions
if (/*effect &&*/ ptr && (uint32_t)opcode == 0xdeadbeef && (uint32_t)index == 0xdeadf00d)
{
@@ -1652,6 +1661,7 @@ public:
if (strcmp(func, "Audio_IsRunning") == 0)
return 0;
}
#endif

// Check if 'resvd1' points to this plugin
VstPlugin* self = nullptr;
@@ -1663,10 +1673,11 @@ public:
#else
if (effect && effect->resvd1)
{
self = (VstPlugin*)getPointer(effect->resvd1);
//self = (VstPlugin*)getPointer(effect->resvd1);
//self = (VstPlugin*)effect->resvd1;
#endif
if (self->unique1 != self->unique2)
self = nullptr;
//if (self->unique1 != self->unique2)
// self = nullptr;
}

intptr_t ret = 0;
@@ -1706,7 +1717,26 @@ public:

case audioMasterGetTime:
if (self)
{
ret = (intptr_t)self->handleAudioMasterGetTime();
}
else
{
static VstTimeInfo_R timeInfo;
memset(&timeInfo, 0, sizeof(VstTimeInfo_R));
timeInfo.sampleRate = 44100.0;

// Tempo
timeInfo.tempo = 120.0;
timeInfo.flags |= kVstTempoValid;

// Time Signature
timeInfo.timeSigNumerator = 4;
timeInfo.timeSigDenominator = 4;
timeInfo.flags |= kVstTimeSigValid;

ret = (intptr_t)&timeInfo;
}
break;

case audioMasterProcessEvents:
@@ -1760,11 +1790,15 @@ public:
case audioMasterGetSampleRate:
if (self)
ret = self->handleAudioMasterGetSampleRate();
else
ret = 44100;
break;

case audioMasterGetBlockSize:
if (self)
ret = self->handleAudioMasterGetBlockSize();
else
ret = 512;
break;

case audioMasterGetInputLatency:
@@ -1836,7 +1870,7 @@ public:
break;

case audioMasterGetVendorVersion:
ret = 0x05; // 0.5
ret = 0x050; // 0.5.0
break;

case audioMasterVendorSpecific:
@@ -1851,7 +1885,7 @@ public:

case audioMasterCanDo:
if (ptr)
ret = handleAudioMasterCanDo((const char*)ptr);
ret = hostCanDo((const char*)ptr);
break;

case audioMasterGetLanguage:
@@ -1904,7 +1938,7 @@ public:

default:
#ifdef DEBUG
qDebug("VstHostCallback(%p, opcode: %s, index: %i, value: " P_INTPTR ", opt: %f", effect, VstMasterOpcode2str(opcode), index, value, opt);
qDebug("VstPlugin::hostCallback(%p, %s, %i, " P_INTPTR ", %p, %f", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
#endif
break;
}
@@ -1944,7 +1978,7 @@ public:
// ---------------------------------------------------------------
// initialize plugin

effect = vstFn(VstHostCallback);
effect = vstFn(hostCallback);

if ((! effect) || effect->magic != kEffectMagic)
{
@@ -2033,6 +2067,7 @@ public:
else
#endif
{
m_hints |= PLUGIN_USES_SINGLE_THREAD;
#if defined(Q_OS_WIN)
gui.type = GUI_INTERNAL_HWND;
#elif defined(Q_OS_MACOS)


+ 34
- 6
c++/carla-bridge/Makefile View File

@@ -21,7 +21,7 @@ LINK_FLAGS = $(shell pkg-config --libs liblo QtCore) $(LDFLAGS)

# --------------------------------------------------------------

BUILD_PLUGIN_FLAGS = $(BUILD_FLAGS) -DBUILD_BRIDGE_PLUGIN -DCARLA_ENGINE_JACK $(shell pkg-config --cflags jack)
BUILD_PLUGIN_FLAGS = $(BUILD_FLAGS) -DBUILD_BRIDGE_PLUGIN -DCARLA_ENGINE_JACK -I../carla-backend $(shell pkg-config --cflags jack)
LINK_PLUGIN_FLAGS = $(LINK_FLAGS) $(shell pkg-config --libs jack)

POSIX_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS) $(shell pkg-config --cflags QtGui)
@@ -34,7 +34,7 @@ WIN_32BIT_FLAGS = $(32BIT_FLAGS)
WIN_64BIT_FLAGS = $(64BIT_FLAGS)
WIN_LINK_FLAGS = $(LINK_PLUGIN_FLAGS) $(shell pkg-config --libs QtGui) -static

WINE_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS) # -fpermissive
WINE_BUILD_FLAGS = $(BUILD_PLUGIN_FLAGS) -DQTCREATOR_TEST # -fpermissive
WINE_32BIT_FLAGS = $(32BIT_FLAGS) -L/usr/lib32/wine -L/usr/lib/i386-linux-gnu/wine
WINE_64BIT_FLAGS = $(64BIT_FLAGS) -L/usr/lib64/wine -L/usr/lib/x86_64-linux-gnu/wine
WINE_LINK_FLAGS = $(LINK_PLUGIN_FLAGS) -ldl
@@ -188,7 +188,8 @@ carla_bridge_osc__vst-x11.o: carla_bridge_osc.cpp

OBJS_POSIX32 = \
carla_bridge_plugin__posix32.o carla_bridge_osc__posix32.o \
carla_engine_jack__posix32.o carla_shared__posix32.o ladspa__posix32.o dssi__posix32.o lv2__posix32.o vst__posix32.o ../carla-lilv/carla_lilv_32bit.a
carla_engine__posix32.o carla_engine_jack__posix32.o carla_shared__posix32.o carla_threads__posix32.o \
ladspa__posix32.o dssi__posix32.o lv2__posix32.o vst__posix32.o ../carla-lilv/carla_lilv_32bit.a

carla-bridge-posix32: $(OBJS_POSIX32)
$(CXX) $^ $(POSIX_LINK_FLAGS) $(POSIX_32BIT_FLAGS) -o $@ && $(STRIP) $@
@@ -199,12 +200,18 @@ carla_bridge_plugin__posix32.o: carla_bridge_plugin.cpp
carla_bridge_osc__posix32.o: carla_bridge_osc.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_32BIT_FLAGS) -c -o $@

carla_engine__posix32.o: ../carla-backend/carla_engine.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_32BIT_FLAGS) -c -o $@

carla_engine_jack__posix32.o: ../carla-backend/carla_engine_jack.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_32BIT_FLAGS) -c -o $@

carla_shared__posix32.o: ../carla-backend/carla_shared.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_32BIT_FLAGS) -c -o $@

carla_threads__posix32.o: ../carla-backend/carla_threads.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_32BIT_FLAGS) -c -o $@

ladspa__posix32.o: ../carla-backend/ladspa.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_32BIT_FLAGS) -c -o $@

@@ -222,7 +229,8 @@ vst__posix32.o: ../carla-backend/vst.cpp

OBJS_POSIX64 = \
carla_bridge_plugin__posix64.o carla_bridge_osc__posix64.o \
carla_engine_jack__posix64.o carla_shared__posix64.o ladspa__posix64.o dssi__posix64.o lv2__posix64.o vst__posix64.o ../carla-lilv/carla_lilv_64bit.a
carla_engine__posix64.o carla_engine_jack__posix64.o carla_shared__posix64.o carla_threads__posix64.o \
ladspa__posix64.o dssi__posix64.o lv2__posix64.o vst__posix64.o ../carla-lilv/carla_lilv_64bit.a

carla-bridge-posix64: $(OBJS_POSIX64)
$(CXX) $^ $(POSIX_LINK_FLAGS) $(POSIX_64BIT_FLAGS) -o $@ && $(STRIP) $@
@@ -233,12 +241,18 @@ carla_bridge_plugin__posix64.o: carla_bridge_plugin.cpp
carla_bridge_osc__posix64.o: carla_bridge_osc.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_64BIT_FLAGS) -c -o $@

carla_engine__posix64.o: ../carla-backend/carla_engine.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_64BIT_FLAGS) -c -o $@

carla_engine_jack__posix64.o: ../carla-backend/carla_engine_jack.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_64BIT_FLAGS) -c -o $@

carla_shared__posix64.o: ../carla-backend/carla_shared.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_64BIT_FLAGS) -c -o $@

carla_threads__posix64.o: ../carla-backend/carla_threads.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_64BIT_FLAGS) -c -o $@

ladspa__posix64.o: ../carla-backend/ladspa.cpp
$(CXX) $< $(POSIX_BUILD_FLAGS) $(POSIX_64BIT_FLAGS) -c -o $@

@@ -256,7 +270,8 @@ vst__posix64.o: ../carla-backend/vst.cpp

OBJS_WINE32 = \
carla_bridge_plugin__wine32.o carla_bridge_osc__wine32.o \
carla_engine_jack__wine32.o carla_shared__wine32.o ladspa__wine32.o dssi__wine32.o lv2__wine32.o vst__wine32.o ../carla-lilv/carla_lilv_32bit.a
carla_engine__wine32.o carla_engine_jack__wine32.o carla_shared__wine32.o carla_threads__wine32.o \
ladspa__wine32.o dssi__wine32.o lv2__wine32.o vst__wine32.o ../carla-lilv/carla_lilv_32bit.a

carla-bridge-win32.exe.so: $(OBJS_WINE32)
$(WINECXX) $^ $(WINE_LINK_FLAGS) $(WINE_32BIT_FLAGS) -o carla-bridge-win32 && $(STRIP) $@
@@ -267,12 +282,18 @@ carla_bridge_plugin__wine32.o: carla_bridge_plugin.cpp
carla_bridge_osc__wine32.o: carla_bridge_osc.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_32BIT_FLAGS) -c -o $@

carla_engine__wine32.o: ../carla-backend/carla_engine.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_32BIT_FLAGS) -c -o $@

carla_engine_jack__wine32.o: ../carla-backend/carla_engine_jack.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_32BIT_FLAGS) -c -o $@

carla_shared__wine32.o: ../carla-backend/carla_shared.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_32BIT_FLAGS) -c -o $@

carla_threads__wine32.o: ../carla-backend/carla_threads.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_32BIT_FLAGS) -c -o $@

ladspa__wine32.o: ../carla-backend/ladspa.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_32BIT_FLAGS) -c -o $@

@@ -290,7 +311,8 @@ vst__wine32.o: ../carla-backend/vst.cpp

OBJS_WINE64 = \
carla_bridge_plugin__wine64.o carla_bridge_osc__wine64.o \
carla_engine_jack__wine64.o carla_shared__wine64.o ladspa__wine64.o dssi__wine64.o lv2__wine64.o vst__wine64.o ../carla-lilv/carla_lilv_64bit.a
carla_engine__wine64.o carla_engine_jack__wine64.o carla_shared__wine64.o carla_threads__wine64.o \
ladspa__wine64.o dssi__wine64.o lv2__wine64.o vst__wine64.o ../carla-lilv/carla_lilv_64bit.a

carla-bridge-win64.exe.so: $(OBJS_WINE64)
$(WINECXX) $^ $(WINE_LINK_FLAGS) $(WINE_64BIT_FLAGS) -o carla-bridge-win64 && $(STRIP) $@
@@ -301,12 +323,18 @@ carla_bridge_plugin__wine64.o: carla_bridge_plugin.cpp
carla_bridge_osc__wine64.o: carla_bridge_osc.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_64BIT_FLAGS) -c -o $@

carla_engine__wine64.o: ../carla-backend/carla_engine.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_64BIT_FLAGS) -c -o $@

carla_engine_jack__wine64.o: ../carla-backend/carla_engine_jack.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_64BIT_FLAGS) -c -o $@

carla_shared__wine64.o: ../carla-backend/carla_shared.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_64BIT_FLAGS) -c -o $@

carla_threads__wine64.o: ../carla-backend/carla_threads.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_64BIT_FLAGS) -c -o $@

ladspa__wine64.o: ../carla-backend/ladspa.cpp
$(WINECXX) $< $(WINE_BUILD_FLAGS) $(WINE_64BIT_FLAGS) -c -o $@



+ 4
- 179
c++/carla-bridge/carla_bridge_osc.cpp View File

@@ -19,6 +19,10 @@
#include "carla_bridge_client.h"
#include "carla_midi.h"

#ifdef BUILD_BRIDGE_PLUGIN
#include "carla_plugin.h" // FIXME - put msg defines somewhere else
#endif

#include <QtCore/QString>
#include <QtCore/QStringList>

@@ -319,183 +323,4 @@ int CarlaOsc::handleMsgQuit()
return 0;
}

#if 0 //def BUILD_BRIDGE_PLUGIN
void osc_send_bridge_ains_peak(int index, double value)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+18];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_ains_peak");
lo_send(global_osc_data.target, target_path, "if", index, value);
}
}

void osc_send_bridge_aouts_peak(int index, double value)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+19];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_aouts_peak");
lo_send(global_osc_data.target, target_path, "if", index, value);
}
}

void osc_send_bridge_audio_count(int ins, int outs, int total)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+20];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_audio_count");
lo_send(global_osc_data.target, target_path, "iii", ins, outs, total);
}
}

void osc_send_bridge_midi_count(int ins, int outs, int total)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+19];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_midi_count");
lo_send(global_osc_data.target, target_path, "iii", ins, outs, total);
}
}

void osc_send_bridge_param_count(int ins, int outs, int total)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+20];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_param_count");
lo_send(global_osc_data.target, target_path, "iii", ins, outs, total);
}
}

void osc_send_bridge_program_count(int count)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+22];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_program_count");
lo_send(global_osc_data.target, target_path, "i", count);
}
}

void osc_send_bridge_midi_program_count(int count)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+27];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_midi_program_count");
lo_send(global_osc_data.target, target_path, "i", count);
}
}

void osc_send_bridge_plugin_info(int category, int hints, const char* name, const char* label, const char* maker, const char* copyright, long uniqueId)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+20];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_plugin_info");
lo_send(global_osc_data.target, target_path, "iissssi", category, hints, name, label, maker, copyright, uniqueId);
// FIXME - should be long type
}
}

void osc_send_bridge_param_info(int index, const char* name, const char* unit)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+19];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_param_info");
lo_send(global_osc_data.target, target_path, "iss", index, name, unit);
}
}

void osc_send_bridge_param_data(int index, int type, int rindex, int hints, int midi_channel, int midi_cc)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+19];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_param_data");
lo_send(global_osc_data.target, target_path, "iiiiii", index, type, rindex, hints, midi_channel, midi_cc);
}
}

void osc_send_bridge_param_ranges(int index, double def, double min, double max, double step, double step_small, double step_large)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+21];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_param_ranges");
lo_send(global_osc_data.target, target_path, "iffffff", index, def, min, max, step, step_small, step_large);
}
}

void osc_send_bridge_program_info(int index, const char* name)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+21];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_program_info");
lo_send(global_osc_data.target, target_path, "is", index, name);
}
}

void osc_send_bridge_midi_program_info(int index, int bank, int program, const char* label)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+26];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_midi_program_info");
lo_send(global_osc_data.target, target_path, "iiis", index, bank, program, label);
}
}

void osc_send_bridge_custom_data(const char* stype, const char* key, const char* value)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+20];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_custom_data");
lo_send(global_osc_data.target, target_path, "sss", stype, key, value);
}
}

void osc_send_bridge_chunk_data(const char* string_data)
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+19];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_chunk_data");
lo_send(global_osc_data.target, target_path, "s", string_data);
}
}

void osc_send_bridge_update()
{
if (global_osc_data.target)
{
char target_path[strlen(global_osc_data.path)+15];
strcpy(target_path, global_osc_data.path);
strcat(target_path, "/bridge_update");
lo_send(global_osc_data.target, target_path, "");
}
}
#endif

CARLA_BRIDGE_END_NAMESPACE

+ 257
- 456
c++/carla-bridge/carla_bridge_plugin.cpp View File

@@ -18,32 +18,34 @@
#include "carla_bridge_client.h"
#include "carla_plugin.h"

//#include "carla_plugin.h"
#include <windows.h>

#include <QtCore/QFile>

//#ifndef __WINE__
#ifndef __WINE__
//#include <QtCore/QTimer>
//#include <QtGui/QApplication>
# include <QtGui/QApplication>
//#include <QtGui/QDialog>
//#endif
#endif

static HINSTANCE hInstG = nullptr;

CARLA_BRIDGE_START_NAMESPACE

// -------------------------------------------------------------------------
// client

class CarlaBridgePluginClient : public CarlaClient
class CarlaPluginClient : public CarlaClient
{
public:
CarlaBridgePluginClient(CarlaToolkit* const toolkit)
CarlaPluginClient(CarlaToolkit* const toolkit)
: CarlaClient(toolkit)
{
engine = nullptr;
plugin = nullptr;
engine = nullptr;
plugin = nullptr;
}

~CarlaBridgePluginClient()
~CarlaPluginClient()
{
}

@@ -91,7 +93,7 @@ public:
void noteOn(const uint8_t channel, const uint8_t note, const uint8_t velo)
{
Q_ASSERT(plugin);
Q_ASSERT(velo != 0);
Q_ASSERT(velo > 0);

if (! plugin)
return;
@@ -172,6 +174,8 @@ public:
if (! plugin)
return;

Q_UNUSED(filePath);

#if 0
nextChunkFilePath = strdup(filePath);

@@ -181,7 +185,20 @@ public:
}

// ---------------------------------------------------------------------
// ...
// idle

void idle()
{
Q_ASSERT(plugin);

if (! plugin)
return;

plugin->idleGui();
}

// ---------------------------------------------------------------------
// callback

void handleCallback(const CarlaBackend::CallbackType action, const int value1, const int value2, const double value3)
{
@@ -210,11 +227,12 @@ public:
}
case CarlaBackend::CALLBACK_SHOW_GUI:
//if (value1 == 0)
// osc_send_configure(CARLA_BRIDGE_MSG_HIDE_GUI, "");
//sendOscConfigure(CarlaBackend::CARLA_BRIDGE_MSG_HIDE_GUI, "");
//quequeMessage(MESSAGE_QUIT, 0, 0, 0.0);
break;
case CarlaBackend::CALLBACK_RESIZE_GUI:
//if (client)
// client->queque_message(BRIDGE_MESSAGE_RESIZE_GUI, value1, value2, 0.0);
//quequeMessage(MESSAGE_RESIZE_GUI, value1, value2, 0.0);
//m_toolkit->resize(value1, value2);
break;
case CarlaBackend::CALLBACK_RELOAD_PARAMETERS:
//if (CARLA_PLUGIN)
@@ -226,9 +244,14 @@ public:
//}
break;
case CarlaBackend::CALLBACK_QUIT:
quequeMessage(MESSAGE_QUIT, 0, 0, 0.0);
//quequeMessage(MESSAGE_QUIT, 0, 0, 0.0);
break;
default:
break;
}
Q_UNUSED(value1);
Q_UNUSED(value2);
Q_UNUSED(value3);
}

// ---------------------------------------------------------------------
@@ -240,7 +263,7 @@ public:
if (! ptr)
return;

CarlaBridgePluginClient* const client = (CarlaBridgePluginClient*)ptr;
CarlaPluginClient* const client = (CarlaPluginClient*)ptr;
client->handleCallback(action, value1, value2, value3);
}

@@ -252,388 +275,238 @@ private:
// -------------------------------------------------------------------------
// toolkit

class CarlaBridgeToolkitPlugin : public CarlaToolkit
class CarlaToolkitPlugin : public CarlaToolkit
{
public:
CarlaBridgeToolkitPlugin(const char* const title)
: CarlaToolkit(title)
CarlaToolkitPlugin()
: CarlaToolkit("carla-bridge-plugin")
{
qDebug("CarlaBridgeToolkitPlugin::CarlaBridgeToolkitPlugin(%s)", title);
}
qDebug("CarlaToolkitPlugin::CarlaToolkitPlugin()");

~CarlaBridgeToolkitPlugin()
{
qDebug("CarlaBridgeToolkitPlugin::~CarlaBridgeToolkitPlugin()");
#ifdef __WINE__
closeNow = false;
hwnd = nullptr;
#else
app = nullptr;
dialog = nullptr;
#endif
}

void init()
~CarlaToolkitPlugin()
{
qDebug("CarlaToolkitPlugin::~CarlaToolkitPlugin()");
}

void exec(CarlaClient* const client)
void init()
{
m_client = client;
}
qDebug("CarlaToolkitPlugin::init()");
#ifdef __WINE__
Q_ASSERT(! closeNow);

WNDCLASSEXA wc;
wc.cbSize = sizeof(WNDCLASSEXA);
wc.style = 0;
wc.lpfnWndProc = windowProcA;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstG; //nullptr;
wc.hIcon = LoadIconA(nullptr, IDI_APPLICATION);
wc.hCursor = LoadCursorA(nullptr, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
wc.lpszMenuName = "MENU_CARLA_BRIDGE";
wc.lpszClassName = "CLASS_CARLA_BRIDGE";
wc.hIconSm = nullptr;
RegisterClassExA(&wc);
#else
Q_ASSERT(! app);

void quit()
{
static int argc = 0;
static char* argv[] = { nullptr };
app = new QApplication(argc, argv, true);
#endif
}

void show()
void exec(CarlaClient* const client)
{
}
qDebug("CarlaToolkitPlugin::exec(%p)", client);
Q_ASSERT(client);

void hide()
{
}
m_client = client;

void resize(int width, int height)
{
}
};
#ifdef QTCREATOR_TEST
show();
#endif

CarlaToolkit* CarlaToolkit::createNew(const char* const title)
{
return new CarlaBridgeToolkitPlugin(title);
}
#ifdef __WINE__
Q_ASSERT(! closeNow);

CARLA_BRIDGE_END_NAMESPACE
MSG msg;
CarlaPluginClient* const pluginClient = (CarlaPluginClient*)client;

int main(int argc, char* argv[])
{
if (argc != 6)
{
qWarning("%s :: bad arguments", argv[0]);
return 1;
}
while (! closeNow)
{
//pluginClient->runMessages();
//pluginClient->idle();

const char* const oscUrl = argv[1];
const char* const stype = argv[2];
const char* const filename = argv[3];
const char* name = argv[4];
const char* const label = argv[5];
//if (closeNow)
// break;

if (strcmp(name, "(none)") == 0)
name = nullptr;
while (GetMessageA(&msg, hwnd, 0, 0) > 0)
{
//if (PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE))
//{
//TranslateMessage(&msg);
DispatchMessageA(&msg);

CarlaBackend::PluginType itype;
pluginClient->runMessages();
pluginClient->idle();
}

if (strcmp(stype, "LADSPA") == 0)
itype = CarlaBackend::PLUGIN_LADSPA;
else if (strcmp(stype, "DSSI") == 0)
itype = CarlaBackend::PLUGIN_DSSI;
else if (strcmp(stype, "LV2") == 0)
itype = CarlaBackend::PLUGIN_LV2;
else if (strcmp(stype, "VST") == 0)
itype = CarlaBackend::PLUGIN_VST;
else
{
itype = CarlaBackend::PLUGIN_NONE;
qWarning("Invalid plugin type '%s'", stype);
return 1;
}
//if (closeNow)
// break;

// Init toolkit
CarlaBridge::CarlaBridgeToolkitPlugin toolkit(name);
toolkit.init();

// Init client
CarlaBridge::CarlaBridgePluginClient client(&toolkit);
//carla_msleep(50);
}
#else
Q_ASSERT(app);

// Init OSC
if (! client.oscInit(oscUrl))
{
toolkit.quit();
return -1;
app->exec();
#endif
}

// Init backend engine
CarlaBackend::CarlaEngineJack engine;
engine.setCallback(client.callback, &client);

// bridge client <-> engine
client.registerOscEngine(&engine);

/// Init plugin
short id = engine.addPlugin(itype, filename, name, label);

if (id >= 0 && id < CarlaBackend::MAX_PLUGINS)
{
CarlaBackend::CarlaPlugin* const plugin = engine.getPlugin(id);
client.setStuff(&engine, plugin);
}
else
void quit()
{
qWarning("Plugin failed to load, error was:\n%s", CarlaBackend::getLastError());
return 1;
}

// Init engine
//QString engName = QString("%1 (master)").arg(label);
//engName.truncate(CarlaEngine::maxClientNameSize());

//CarlaEngine engine;
//engine.init(engName.toUtf8().constData());

// Init toolkit
//toolkit_init();

// Init plugin client
//client = new PluginData;

// Init OSC
//osc_init(osc_url);
//osc_send_update();

toolkit.exec(&client);

// Close OSC
client.sendOscExiting();
client.oscClose();

// Close client
//client.close();

// Close toolkit
toolkit.quit();

return 0;
}

#if 0
#define CARLA_PLUGIN CarlaBackend::CarlaPlugins[0]

void toolkit_plugin_idle();

ClientData* client = nullptr;

// -------------------------------------------------------------------------
// backend stuff

// -------------------------------------------------------------------------
// toolkit classes
qDebug("CarlaToolkitPlugin::quit()");

#ifdef __WINE__
LRESULT WINAPI MainProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CLOSE:
if (client)
client->queque_message(BRIDGE_MESSAGE_SHOW_GUI, 0, 0, 0.0);
osc_send_configure(CARLA_BRIDGE_MSG_HIDE_GUI, "");
return TRUE;
}
if (closeNow && hwnd)
{
DestroyWindow(hwnd);
hwnd = nullptr;
}

return DefWindowProc(hWnd, msg, wParam, lParam);
}
static bool close_now = false;
static HINSTANCE hInst = nullptr;
static HWND gui = nullptr;
closeNow = true;
#else
class PluginIdleTimer : public QTimer
{
public:
PluginIdleTimer() {}
Q_ASSERT(app);

void timerEvent(QTimerEvent*)
{
if (client)
client->run_messages();

toolkit_plugin_idle();
}

Q_SLOT void guiClosed()
{
//if (client)
// client->queque_message(BRIDGE_MESSAGE_SHOW_GUI, 0, 0, 0.0);
osc_send_configure(CARLA_BRIDGE_MSG_HIDE_GUI, "");
}
};
static QApplication* app = nullptr;
static QDialog* gui = nullptr;
#endif
if (app && dialog)
{
delete dialog;
dialog = nullptr;
}

#define nextShowMsgNULL 0
#define nextShowMsgFALSE 1
#define nextShowMsgTRUE 2
static int nextShowMsg = nextShowMsgNULL;
static const char* nextChunkFilePath = nullptr;
if (! app)
return;

// -------------------------------------------------------------------------
// toolkit calls
if (! app->closingDown())
app->quit();

void toolkit_init()
{
#ifdef __WINE__
#else
static int argc = 0;
static char* argv[] = { nullptr };
app = new QApplication(argc, argv, true);
delete app;
#endif
}
}

void toolkit_plugin_idle()
{
if (nextShowMsg)
void show()
{
bool yesno = nextShowMsg - 1;
qDebug("CarlaToolkitPlugin::show()");

CARLA_PLUGIN->showGui(yesno);

if (gui)
{
#ifdef __WINE__
ShowWindow(gui, yesno ? SW_SHOWNORMAL : SW_HIDE);
UpdateWindow(gui);
#else
gui->setVisible(yesno);
#endif
}

nextShowMsg = nextShowMsgNULL;
ShowWindow(hwnd, SW_SHOWNORMAL);
UpdateWindow(hwnd);
}

if (nextChunkFilePath)
void hide()
{
QFile file(nextChunkFilePath);

free((void*)nextChunkFilePath);
nextChunkFilePath = nullptr;
qDebug("CarlaToolkitPlugin::hide()");

if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QString stringData = file.readAll();
file.remove();

CARLA_PLUGIN->setChunkData(stringData.toUtf8().constData());
}
ShowWindow(hwnd, SW_HIDE);
}

CARLA_PLUGIN->idleGui();

static PluginPostEvent postEvents[MAX_POST_EVENTS];
CARLA_PLUGIN->postEventsCopy(postEvents);

for (uint32_t i=0; i < MAX_POST_EVENTS; i++)
void resize(int width, int height)
{
if (postEvents[i].type == PluginPostEventNull)
break;
qDebug("CarlaToolkitPlugin::resize(%i, %i)", width, height);

switch (postEvents[i].type)
{
case PluginPostEventParameterChange:
callback_action(CALLBACK_PARAMETER_CHANGED, 0, postEvents[i].index, 0, postEvents[i].value);
break;
case PluginPostEventProgramChange:
callback_action(CALLBACK_PROGRAM_CHANGED, 0, postEvents[i].index, 0, 0.0);
break;
case PluginPostEventMidiProgramChange:
callback_action(CALLBACK_MIDI_PROGRAM_CHANGED, 0, postEvents[i].index, 0, 0.0);
break;
case PluginPostEventNoteOn:
callback_action(CALLBACK_NOTE_ON, 0, postEvents[i].index, postEvents[i].value, 0.0);
break;
case PluginPostEventNoteOff:
callback_action(CALLBACK_NOTE_OFF, 0, postEvents[i].index, 0, 0.0);
break;
default:
break;
}
SetWindowPos(hwnd, 0, 0, 0, width + 6, height + 25, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
}

const ParameterData* paramData;

for (uint32_t i=0; i < CARLA_PLUGIN->parameterCount(); i++)
void createWindow(const char* const pluginName)
{
paramData = CARLA_PLUGIN->parameterData(i);
#ifdef __WINE__
hwnd = CreateWindowA("CLASS_CARLA_BRIDGE", pluginName, WS_OVERLAPPEDWINDOW &~ WS_THICKFRAME &~ WS_MAXIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
HWND_DESKTOP, nullptr, hInstG, nullptr);

if (paramData->type == PARAMETER_OUTPUT && (paramData->hints & PARAMETER_IS_AUTOMABLE) > 0)
osc_send_control(paramData->rindex, CARLA_PLUGIN->getParameterValue(i));
}
if (! hwnd)
return;

if (CARLA_PLUGIN->audioInCount() > 0)
{
osc_send_bridge_ains_peak(1, ains_peak[0]);
osc_send_bridge_ains_peak(2, ains_peak[1]);
SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)this);
SetWindowPos(hwnd, 0, 0, 0, 1100 + 6, 600 + 25, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
#else
dialog = new QDialog(nullptr);
dialog->resize(10, 10);
dialog->setWindowTitle(pluginName);
#endif
}

if (CARLA_PLUGIN->audioOutCount() > 0)
CarlaBackend::GuiDataHandle getWindowHandle() const
{
osc_send_bridge_aouts_peak(1, aouts_peak[0]);
osc_send_bridge_aouts_peak(2, aouts_peak[1]);
#ifdef __WINE__
return hwnd;
#else
return dialog;
#endif
}
}

void toolkit_loop()
{
private:
#ifdef __WINE__
MSG msg;
bool closeNow;
HWND hwnd;

while (! close_now)
void handleWindowCloseMessageA()
{
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
DispatchMessage(&msg);

client->run_messages();
//m_client->quequeMessage(MESSAGE_QUIT, 0, 0, 0.0);
//m_client->quequeMessage(MESSAGE_SHOW_GUI, 0, 0, 0.0);
closeNow = true;
m_client->sendOscConfigure(CarlaBackend::CARLA_BRIDGE_MSG_HIDE_GUI, "");
}

toolkit_plugin_idle();

carla_msleep(50);
}
#else
PluginIdleTimer timer;
timer.start(50);
static LRESULT CALLBACK windowProcA(HWND _hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
qDebug("windowProcA(%p, %i, %li, %li)", _hwnd, message, wParam, lParam);

if (gui)
timer.connect(gui, SIGNAL(finished(int)), &timer, SLOT(guiClosed()));
if (message == WM_CLOSE || message == WM_DESTROY)
{
CarlaToolkitPlugin* const toolkit = (CarlaToolkitPlugin*)GetWindowLongPtrA(_hwnd, GWLP_USERDATA);
Q_ASSERT(toolkit);

app->setQuitOnLastWindowClosed(false);
app->exec();
#endif
}
if (toolkit)
{
toolkit->handleWindowCloseMessageA();
return TRUE;
}
}

void toolkit_quit()
{
#ifdef __WINE__
close_now = true;
return DefWindowProcA(_hwnd, message, wParam, lParam);
}
#else
if (app)
app->quit();
QApplication* app;
QDialog* dialog;
#endif
}

void toolkit_window_show()
{
nextShowMsg = nextShowMsgTRUE;
}

void toolkit_window_hide()
{
nextShowMsg = nextShowMsgFALSE;
}
};

void toolkit_window_resize(int width, int height)
CarlaToolkit* CarlaToolkit::createNew(const char* const)
{
if (gui)
{
#ifdef __WINE__
SetWindowPos(gui, 0, 0, 0, width + 6, height + 25, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
#else
gui->setFixedSize(width, height);
#endif
}
return new CarlaToolkitPlugin;
}

// -------------------------------------------------------------------------

// -------------------------------------------------------------------------
CARLA_BRIDGE_END_NAMESPACE

#ifdef __WINE__
int WINAPI WinMain(HINSTANCE hInstX, HINSTANCE, LPSTR, int)
{
hInst = hInstX;
hInstG = hInstX;
qWarning("test %li %p", hInstG, hInstG);

#define MAXCMDTOKENS 128
int argc;
@@ -683,183 +556,111 @@ int WINAPI WinMain(HINSTANCE hInstX, HINSTANCE, LPSTR, int)

if (strlen(argv[0]) == 0)
{
GetModuleFileName(hInst, command, sizeof(command)-1);
GetModuleFileName(hInstG, command, sizeof(command)-1);
argv[0] = command;
}
#else
int main(int argc, char* argv[])
{
#endif
if (argc != 6)
{
qWarning("%s :: bad arguments", argv[0]);
return 1;
}

const char* const osc_url = argv[1];
const char* const stype = argv[2];
const char* const filename = argv[3];
const char* name = argv[4];
const char* const label = argv[5];
//if (argc != 6)
//{
//qWarning("%s :: bad arguments", argv[0]);
//return 1;
//}

//const char* const oscUrl = argv[1];
//const char* const stype = argv[2];
//const char* const filename = argv[3];
//const char* name = argv[4];
//const char* const label = argv[5];

const char* const oscUrl = "osc.udp://null";
const char* const stype = "VST";
const char* const filename = "/home/falktx/.wine/drive_c/Program Files (x86)/VstPlugins/IL Harmless.dll";
const char* name = "(none)";
const char* const label = "DemoBuild";

if (strcmp(name, "(none)") == 0)
name = nullptr;

short id;
PluginType itype;
CarlaBackend::PluginType itype;

if (strcmp(stype, "LADSPA") == 0)
itype = PLUGIN_LADSPA;
itype = CarlaBackend::PLUGIN_LADSPA;
else if (strcmp(stype, "DSSI") == 0)
itype = PLUGIN_DSSI;
itype = CarlaBackend::PLUGIN_DSSI;
else if (strcmp(stype, "LV2") == 0)
itype = PLUGIN_LV2;
itype = CarlaBackend::PLUGIN_LV2;
else if (strcmp(stype, "VST") == 0)
itype = PLUGIN_VST;
itype = CarlaBackend::PLUGIN_VST;
else
{
itype = PLUGIN_NONE;
itype = CarlaBackend::PLUGIN_NONE;
qWarning("Invalid plugin type '%s'", stype);
return 1;
}

// Init backend
set_callback_function(plugin_bridge_callback);
set_last_error("no error");

// Init engine
QString engName = QString("%1 (master)").arg(label);
engName.truncate(CarlaEngine::maxClientNameSize());

CarlaEngine engine;
engine.init(engName.toUtf8().constData());

// Init toolkit
toolkit_init();
CarlaBridge::CarlaToolkitPlugin toolkit;
toolkit.init();

// Init plugin client
client = new PluginData;
// Init client
CarlaBridge::CarlaPluginClient client(&toolkit);

// Init OSC
osc_init(osc_url);
osc_send_update();

// Get plugin type
switch (itype)
{
case PLUGIN_LADSPA:
id = add_plugin_ladspa(filename, name, label, nullptr);
break;
case PLUGIN_DSSI:
id = add_plugin_dssi(filename, name, label, nullptr);
break;
case PLUGIN_LV2:
id = add_plugin_lv2(filename, name, label);
break;
case PLUGIN_VST:
id = add_plugin_vst(filename, name, label);
break;
default:
id = -1;
break;
}

// Init plugin
if (id == 0 && CARLA_PLUGIN)
{
// Create gui if needed
GuiInfo guiInfo;
CARLA_PLUGIN->getGuiInfo(&guiInfo);

QString guiTitle = QString("%1 (GUI)").arg(CARLA_PLUGIN->name());

#ifdef __WINE__
if (guiInfo.type == GUI_INTERNAL_HWND)
{
WNDCLASSEX wclass;
wclass.cbSize = sizeof(WNDCLASSEX);
wclass.style = 0;
wclass.lpfnWndProc = MainProc;
wclass.cbClsExtra = 0;
wclass.cbWndExtra = 0;
wclass.hInstance = hInst;
wclass.hIcon = LoadIcon(hInst, "carla");
wclass.hCursor = LoadCursor(0, IDI_APPLICATION);
wclass.lpszMenuName = "MENU_CARLA_BRIDGE";
wclass.lpszClassName = "CLASS_CARLA_BRIDGE";
wclass.hIconSm = 0;

if (! RegisterClassEx(&wclass))
{
qCritical("Failed to register Wine application");
return 1;
}

gui = CreateWindow("CLASS_CARLA_BRIDGE", guiTitle.toUtf8().constData(),
WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, hInst, 0);
SetWindowPos(gui, 0, 0, 0, 6, 25, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
if (! client.oscInit(oscUrl))
{
toolkit.quit();
return -1;
}

qDebug("Wine GUI created");
#else
if (guiInfo.type == GUI_INTERNAL_QT4 || guiInfo.type == GUI_INTERNAL_X11)
{
gui = new QDialog(nullptr);
gui->resize(10, 10);
gui->setWindowTitle(guiTitle);
#endif
CARLA_PLUGIN->setGuiData(0, gui);
}
// Init backend engine
CarlaBackend::CarlaEngineJack engine;
engine.setCallback(client.callback, &client);

// Report OK to backend
osc_send_bridge_update();
// bridge client <-> engine
client.registerOscEngine(&engine);

// Main loop
toolkit_loop();
// Init engine
QString engName = QString("%1 (master)").arg(label);
engName.truncate(engine.maxClientNameSize());
engine.init(engName.toUtf8().constData());

// Remove & delete plugin
carla_proc_lock();
CARLA_PLUGIN->setEnabled(false);
carla_proc_unlock();
/// Init plugin
short id = engine.addPlugin(itype, filename, name, label);

delete CARLA_PLUGIN;
if (id >= 0 && id < CarlaBackend::MAX_PLUGINS)
{
CarlaBackend::CarlaPlugin* const plugin = engine.getPlugin(id);
client.setStuff(&engine, plugin);
plugin->setEnabled(true);
plugin->setActive(true, false, false);

// Cleanup
#ifndef __WINE__
if (gui)
{
gui->close();
delete gui;
}
delete app;
#endif
toolkit.createWindow(plugin->name());
plugin->setGuiData(0, toolkit.getWindowHandle());
plugin->showGui(true);
}
else
{
qWarning("Plugin failed to load, error was:\n%s", get_last_error());
qWarning("Plugin failed to load, error was:\n%s", CarlaBackend::getLastError());
return 1;
}

// delete old data
if (nextChunkFilePath)
{
free((void*)nextChunkFilePath);
nextChunkFilePath = nullptr;
}

// Close plugin client
delete client;
client = nullptr;
toolkit.exec(&client);

// Close engine
engine.removeAllPlugins();
engine.close();

// Close OSC
osc_send_exiting();
osc_close();
client.sendOscExiting();
client.oscClose();

// Close client
//client.close();

// Close toolkit
toolkit.quit();

return 0;
}

#endif

+ 168
- 145
c++/carla-discovery/carla-discovery.cpp View File

@@ -27,22 +27,22 @@
#include <QtCore/QFileInfo>
#include <QtCore/QUrl>

#include "carla_backend.h"

#include "carla_ladspa.h"
#include "carla_dssi.h"
#include "carla_lv2.h"
#include "carla_vst.h"

#ifdef BUILD_NATIVE
# ifdef WANT_FLUIDSYNTH
# include "carla_fluidsynth.h"
# endif
# ifdef WANT_LINUXSAMPLER
# include "carla_linuxsampler.h"
# endif
#ifdef WANT_FLUIDSYNTH
#include "carla_fluidsynth.h"
#endif
#ifdef WANT_LINUXSAMPLER
#include "carla_linuxsampler.h"
#endif
#endif

#include "carla_backend.h"

#define DISCOVERY_OUT(x, y) std::cout << "\ncarla-discovery::" << x << "::" << y << std::endl;

// fake values to test plugins with
@@ -61,12 +61,56 @@ using namespace CarlaBackend;

// ------------------------------ VST Stuff ------------------------------

intptr_t VstCurrentUniqueId = 0;
intptr_t vstCurrentUniqueId = 0;

intptr_t VstHostCallback(AEffect* const effect, const int32_t opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt)
intptr_t vstHostCanDo(const char* const feature)
{
qDebug("vstHostCanDo(\"%s\")", feature);

if (strcmp(feature, "supplyIdle") == 0)
return 1;
if (strcmp(feature, "sendVstEvents") == 0)
return 1;
if (strcmp(feature, "sendVstMidiEvent") == 0)
return 1;
if (strcmp(feature, "sendVstMidiEventFlagIsRealtime") == 0)
return -1;
if (strcmp(feature, "sendVstTimeInfo") == 0)
return 1;
if (strcmp(feature, "receiveVstEvents") == 0)
return 1;
if (strcmp(feature, "receiveVstMidiEvent") == 0)
return 1;
if (strcmp(feature, "receiveVstTimeInfo") == 0)
return -1;
if (strcmp(feature, "reportConnectionChanges") == 0)
return -1;
if (strcmp(feature, "acceptIOChanges") == 0)
return 1;
if (strcmp(feature, "sizeWindow") == 0)
return 1;
if (strcmp(feature, "offline") == 0)
return -1;
if (strcmp(feature, "openFileSelector") == 0)
return -1;
if (strcmp(feature, "closeFileSelector") == 0)
return -1;
if (strcmp(feature, "startStopProcess") == 0)
return 1;
if (strcmp(feature, "supportShell") == 0)
return 1;
if (strcmp(feature, "shellCategory") == 0)
return 1;

// unimplemented
qWarning("vstHostCanDo(\"%s\") - unknown feature", feature);
return 0;
}

intptr_t VSTCALLBACK vstHostCallback(AEffect* const effect, const int32_t opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt)
{
#if DEBUG
qDebug("VstHostCallback(%p, opcode: %s, index: %i, value: " P_INTPTR ", opt: %f", effect, VstMasterOpcode2str(opcode), index, value, opt);
qDebug("vstHostCallback(%p, %s, %i, " P_INTPTR ", %p, %f", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
#endif

intptr_t ret = 0;
@@ -83,7 +127,7 @@ intptr_t VstHostCallback(AEffect* const effect, const int32_t opcode, const int3
break;

case audioMasterCurrentId:
ret = VstCurrentUniqueId;
ret = vstCurrentUniqueId;
break;

case audioMasterGetTime:
@@ -108,6 +152,10 @@ intptr_t VstHostCallback(AEffect* const effect, const int32_t opcode, const int3
ret = 120 * 10000;
break;

case audioMasterGetNumAutomatableParameters:
ret = MAX_PARAMETERS;
break;

case audioMasterGetSampleRate:
ret = sampleRate;
break;
@@ -116,6 +164,10 @@ intptr_t VstHostCallback(AEffect* const effect, const int32_t opcode, const int3
ret = bufferSize;
break;

case audioMasterGetCurrentProcessLevel:
ret = kVstProcessLevelUser;
break;

case audioMasterGetVendorString:
if (ptr)
strcpy((char*)ptr, "Cadence");
@@ -127,56 +179,12 @@ intptr_t VstHostCallback(AEffect* const effect, const int32_t opcode, const int3
break;

case audioMasterGetVendorVersion:
ret = 0x05; // 0.5
ret = 0x050; // 0.5.0
break;

case audioMasterCanDo:
#if DEBUG
qDebug("VstHostCallback:audioMasterCanDo - %s", (char*)ptr);
#endif

if (! ptr)
ret = 0;
else if (strcmp((char*)ptr, "supplyIdle") == 0)
ret = 1;
else if (strcmp((char*)ptr, "sendVstEvents") == 0)
ret = 1;
else if (strcmp((char*)ptr, "sendVstMidiEvent") == 0)
ret = 1;
else if (strcmp((char*)ptr, "sendVstMidiEventFlagIsRealtime") == 0)
ret = -1;
else if (strcmp((char*)ptr, "sendVstTimeInfo") == 0)
ret = 1;
else if (strcmp((char*)ptr, "receiveVstEvents") == 0)
ret = 1;
else if (strcmp((char*)ptr, "receiveVstMidiEvent") == 0)
ret = 1;
else if (strcmp((char*)ptr, "receiveVstTimeInfo") == 0)
ret = -1;
else if (strcmp((char*)ptr, "reportConnectionChanges") == 0)
ret = 1;
else if (strcmp((char*)ptr, "acceptIOChanges") == 0)
ret = -1;
else if (strcmp((char*)ptr, "sizeWindow") == 0)
ret = 1;
else if (strcmp((char*)ptr, "offline") == 0)
ret = -1;
else if (strcmp((char*)ptr, "openFileSelector") == 0)
ret = -1;
else if (strcmp((char*)ptr, "closeFileSelector") == 0)
ret = -1;
else if (strcmp((char*)ptr, "startStopProcess") == 0)
ret = 1;
else if (strcmp((char*)ptr, "supportShell") == 0)
ret = 1;
else if (strcmp((char*)ptr, "shellCategory") == 0)
ret = 1;
else
{
// unimplemented
qWarning("VstHostCallback:audioMasterCanDo - Got unknown feature request '%s'", (char*)ptr);
ret = 0;
}
if (ptr)
ret = vstHostCanDo((const char*)ptr);
break;

case audioMasterGetLanguage:
@@ -184,7 +192,7 @@ intptr_t VstHostCallback(AEffect* const effect, const int32_t opcode, const int3
break;

default:
qDebug("VstHostCallback(%p, opcode: %s, index: %i, value: " P_INTPTR ", opt: %f", effect, VstMasterOpcode2str(opcode), index, value, opt);
qDebug("vstHostCallback(%p, %s, %i, " P_INTPTR ", %p, %f", effect, vstMasterOpcode2str(opcode), index, value, ptr, opt);
break;
}

@@ -193,11 +201,11 @@ intptr_t VstHostCallback(AEffect* const effect, const int32_t opcode, const int3

// ------------------------------ Plugin Checks -----------------------------

void do_ladspa_check(void* const lib_handle, const bool init)
void do_ladspa_check(void* const libHandle, const bool init)
{
const LADSPA_Descriptor_Function descfn = (LADSPA_Descriptor_Function)lib_symbol(lib_handle, "ladspa_descriptor");
const LADSPA_Descriptor_Function descFn = (LADSPA_Descriptor_Function)lib_symbol(libHandle, "ladspa_descriptor");

if (! descfn)
if (! descFn)
{
DISCOVERY_OUT("error", "Not a LADSPA plugin");
return;
@@ -206,8 +214,10 @@ void do_ladspa_check(void* const lib_handle, const bool init)
unsigned long i = 0;
const LADSPA_Descriptor* descriptor;

while ((descriptor = descfn(i++)))
while ((descriptor = descFn(i++)))
{
Q_ASSERT(descriptor->run);

int hints = 0;
int audioIns = 0;
int audioOuts = 0;
@@ -218,21 +228,21 @@ void do_ladspa_check(void* const lib_handle, const bool init)

for (unsigned long j=0; j < descriptor->PortCount; j++)
{
const LADSPA_PortDescriptor PortDescriptor = descriptor->PortDescriptors[j];
const LADSPA_PortDescriptor portDescriptor = descriptor->PortDescriptors[j];

if (LADSPA_IS_PORT_AUDIO(PortDescriptor))
if (LADSPA_IS_PORT_AUDIO(portDescriptor))
{
if (LADSPA_IS_PORT_INPUT(PortDescriptor))
if (LADSPA_IS_PORT_INPUT(portDescriptor))
audioIns += 1;
else if (LADSPA_IS_PORT_OUTPUT(PortDescriptor))
else if (LADSPA_IS_PORT_OUTPUT(portDescriptor))
audioOuts += 1;
audioTotal += 1;
}
else if (LADSPA_IS_PORT_CONTROL(PortDescriptor))
else if (LADSPA_IS_PORT_CONTROL(portDescriptor))
{
if (LADSPA_IS_PORT_INPUT(PortDescriptor))
if (LADSPA_IS_PORT_INPUT(portDescriptor))
parametersIns += 1;
else if (LADSPA_IS_PORT_OUTPUT(PortDescriptor) && strcmp(descriptor->PortNames[j], "latency") && strcmp(descriptor->PortNames[j], "_latency") && strcmp(descriptor->PortNames[j], "_sample-rate"))
else if (LADSPA_IS_PORT_OUTPUT(portDescriptor) && strcmp(descriptor->PortNames[j], "latency") && strcmp(descriptor->PortNames[j], "_latency") && strcmp(descriptor->PortNames[j], "_sample-rate"))
parametersOuts += 1;
parametersTotal += 1;
}
@@ -261,24 +271,24 @@ void do_ladspa_check(void* const lib_handle, const bool init)

for (unsigned long j=0, iA=0, iP=0; j < descriptor->PortCount; j++)
{
const LADSPA_PortDescriptor PortType = descriptor->PortDescriptors[j];
const LADSPA_PortRangeHint PortHint = descriptor->PortRangeHints[j];
const LADSPA_PortDescriptor portType = descriptor->PortDescriptors[j];
const LADSPA_PortRangeHint portHints = descriptor->PortRangeHints[j];

if (LADSPA_IS_PORT_AUDIO(PortType))
if (LADSPA_IS_PORT_AUDIO(portType))
{
descriptor->connect_port(handle, j, bufferAudio[iA++]);
}
else if (LADSPA_IS_PORT_CONTROL(PortType))
else if (LADSPA_IS_PORT_CONTROL(portType))
{
// min value
if (LADSPA_IS_HINT_BOUNDED_BELOW(PortHint.HintDescriptor))
min = PortHint.LowerBound;
if (LADSPA_IS_HINT_BOUNDED_BELOW(portHints.HintDescriptor))
min = portHints.LowerBound;
else
min = 0.0f;

// max value
if (LADSPA_IS_HINT_BOUNDED_ABOVE(PortHint.HintDescriptor))
max = PortHint.UpperBound;
if (LADSPA_IS_HINT_BOUNDED_ABOVE(portHints.HintDescriptor))
max = portHints.UpperBound;
else
max = 1.0f;

@@ -294,21 +304,21 @@ void do_ladspa_check(void* const lib_handle, const bool init)
}

// default value
def = get_default_ladspa_port_value(PortHint.HintDescriptor, min, max);
def = get_default_ladspa_port_value(portHints.HintDescriptor, min, max);

if (def < min)
def = min;
else if (def > max)
def = max;

if (LADSPA_IS_HINT_SAMPLE_RATE(PortHint.HintDescriptor))
if (LADSPA_IS_HINT_SAMPLE_RATE(portHints.HintDescriptor))
{
min *= sampleRate;
max *= sampleRate;
def *= sampleRate;
}

if (LADSPA_IS_PORT_OUTPUT(PortType) && (strcmp(descriptor->PortNames[j], "latency") == 0 || strcmp(descriptor->PortNames[j], "_latency") == 0))
if (LADSPA_IS_PORT_OUTPUT(portType) && (strcmp(descriptor->PortNames[j], "latency") == 0 || strcmp(descriptor->PortNames[j], "_latency") == 0))
{
// latency parameter
min = 0.0f;
@@ -355,11 +365,11 @@ void do_ladspa_check(void* const lib_handle, const bool init)
}
}

void do_dssi_check(void* const lib_handle, const bool init)
void do_dssi_check(void* const libHandle, const bool init)
{
const DSSI_Descriptor_Function descfn = (DSSI_Descriptor_Function)lib_symbol(lib_handle, "dssi_descriptor");
const DSSI_Descriptor_Function descFn = (DSSI_Descriptor_Function)lib_symbol(libHandle, "dssi_descriptor");

if (! descfn)
if (! descFn)
{
DISCOVERY_OUT("error", "Not a DSSI plugin");
return;
@@ -368,9 +378,11 @@ void do_dssi_check(void* const lib_handle, const bool init)
unsigned long i = 0;
const DSSI_Descriptor* descriptor;

while ((descriptor = descfn(i++)))
while ((descriptor = descFn(i++)))
{
const LADSPA_Descriptor* const ldescriptor = descriptor->LADSPA_Plugin;
Q_ASSERT(ldescriptor);
Q_ASSERT(ldescriptor->run || descriptor->run_synth || descriptor->run_multiple_synths);

int hints = 0;
int audioIns = 0;
@@ -385,21 +397,21 @@ void do_dssi_check(void* const lib_handle, const bool init)

for (unsigned long j=0; j < ldescriptor->PortCount; j++)
{
const LADSPA_PortDescriptor PortDescriptor = ldescriptor->PortDescriptors[j];
const LADSPA_PortDescriptor portDescriptor = ldescriptor->PortDescriptors[j];

if (LADSPA_IS_PORT_AUDIO(PortDescriptor))
if (LADSPA_IS_PORT_AUDIO(portDescriptor))
{
if (LADSPA_IS_PORT_INPUT(PortDescriptor))
if (LADSPA_IS_PORT_INPUT(portDescriptor))
audioIns += 1;
else if (LADSPA_IS_PORT_OUTPUT(PortDescriptor))
else if (LADSPA_IS_PORT_OUTPUT(portDescriptor))
audioOuts += 1;
audioTotal += 1;
}
else if (LADSPA_IS_PORT_CONTROL(PortDescriptor))
else if (LADSPA_IS_PORT_CONTROL(portDescriptor))
{
if (LADSPA_IS_PORT_INPUT(PortDescriptor))
if (LADSPA_IS_PORT_INPUT(portDescriptor))
parametersIns += 1;
else if (LADSPA_IS_PORT_OUTPUT(PortDescriptor) && strcmp(ldescriptor->PortNames[j], "latency") && strcmp(ldescriptor->PortNames[j], "_latency") && strcmp(ldescriptor->PortNames[j], "_sample-rate"))
else if (LADSPA_IS_PORT_OUTPUT(portDescriptor) && strcmp(ldescriptor->PortNames[j], "latency") && strcmp(ldescriptor->PortNames[j], "_latency") && strcmp(ldescriptor->PortNames[j], "_sample-rate"))
parametersOuts += 1;
parametersTotal += 1;
}
@@ -441,24 +453,24 @@ void do_dssi_check(void* const lib_handle, const bool init)

for (unsigned long j=0, iA=0, iP=0; j < ldescriptor->PortCount; j++)
{
const LADSPA_PortDescriptor PortType = ldescriptor->PortDescriptors[j];
const LADSPA_PortRangeHint PortHint = ldescriptor->PortRangeHints[j];
const LADSPA_PortDescriptor portType = ldescriptor->PortDescriptors[j];
const LADSPA_PortRangeHint portHints = ldescriptor->PortRangeHints[j];

if (LADSPA_IS_PORT_AUDIO(PortType))
if (LADSPA_IS_PORT_AUDIO(portType))
{
ldescriptor->connect_port(handle, j, bufferAudio[iA++]);
}
else if (LADSPA_IS_PORT_CONTROL(PortType))
else if (LADSPA_IS_PORT_CONTROL(portType))
{
// min value
if (LADSPA_IS_HINT_BOUNDED_BELOW(PortHint.HintDescriptor))
min = PortHint.LowerBound;
if (LADSPA_IS_HINT_BOUNDED_BELOW(portHints.HintDescriptor))
min = portHints.LowerBound;
else
min = 0.0f;

// max value
if (LADSPA_IS_HINT_BOUNDED_ABOVE(PortHint.HintDescriptor))
max = PortHint.UpperBound;
if (LADSPA_IS_HINT_BOUNDED_ABOVE(portHints.HintDescriptor))
max = portHints.UpperBound;
else
max = 1.0f;

@@ -474,21 +486,21 @@ void do_dssi_check(void* const lib_handle, const bool init)
}

// default value
def = get_default_ladspa_port_value(PortHint.HintDescriptor, min, max);
def = get_default_ladspa_port_value(portHints.HintDescriptor, min, max);

if (def < min)
def = min;
else if (def > max)
def = max;

if (LADSPA_IS_HINT_SAMPLE_RATE(PortHint.HintDescriptor))
if (LADSPA_IS_HINT_SAMPLE_RATE(portHints.HintDescriptor))
{
min *= sampleRate;
max *= sampleRate;
def *= sampleRate;
}

if (LADSPA_IS_PORT_OUTPUT(PortType) && (strcmp(ldescriptor->PortNames[j], "latency") == 0 || strcmp(ldescriptor->PortNames[j], "_latency") == 0))
if (LADSPA_IS_PORT_OUTPUT(portType) && (strcmp(ldescriptor->PortNames[j], "latency") == 0 || strcmp(ldescriptor->PortNames[j], "_latency") == 0))
{
// latency parameter
min = 0.0f;
@@ -592,31 +604,32 @@ void do_lv2_check(const char* const bundle, const bool init)
for (int i=0; i < URIs.count(); i++)
{
const LV2_RDF_Descriptor* const rdf_descriptor = lv2_rdf_new(URIs.at(i).toUtf8().constData());
Q_ASSERT(rdf_descriptor && rdf_descriptor->URI);

if (init)
{
// test if DLL is loadable
void* const lib_handle = lib_open(rdf_descriptor->Binary);
void* const libHandle = lib_open(rdf_descriptor->Binary);

if (! lib_handle)
if (! libHandle)
{
print_lib_error(rdf_descriptor->Binary);
continue;
}

lib_close(lib_handle);
lib_close(libHandle);

// test if we support all required ports and features
bool supported = true;

for (uint32_t j=0; j < rdf_descriptor->PortCount; j++)
{
const LV2_RDF_Port* const Port = &rdf_descriptor->Ports[j];
bool validPort = (LV2_IS_PORT_CONTROL(Port->Type) || LV2_IS_PORT_AUDIO(Port->Type) || LV2_IS_PORT_ATOM_SEQUENCE(Port->Type) /*|| LV2_IS_PORT_CV(Port->Type)*/ || LV2_IS_PORT_EVENT(Port->Type) || LV2_IS_PORT_MIDI_LL(Port->Type));
const LV2_RDF_Port* const port = &rdf_descriptor->Ports[j];
bool validPort = (LV2_IS_PORT_CONTROL(port->Type) || LV2_IS_PORT_AUDIO(port->Type) || LV2_IS_PORT_ATOM_SEQUENCE(port->Type) /*|| LV2_IS_PORT_CV(port->Type)*/ || LV2_IS_PORT_EVENT(port->Type) || LV2_IS_PORT_MIDI_LL(port->Type));

if (! (validPort || LV2_IS_PORT_OPTIONAL(Port->Properties)))
if (! (validPort || LV2_IS_PORT_OPTIONAL(port->Properties)))
{
DISCOVERY_OUT("error", "plugin requires a non-supported port type, port-name: " << Port->Name);
DISCOVERY_OUT("error", "plugin requires a non-supported port type, port-name: " << port->Name);
supported = false;
break;
}
@@ -624,11 +637,11 @@ void do_lv2_check(const char* const bundle, const bool init)

for (uint32_t j=0; j < rdf_descriptor->FeatureCount && supported; j++)
{
const LV2_RDF_Feature* const Feature = &rdf_descriptor->Features[j];
const LV2_RDF_Feature* const feature = &rdf_descriptor->Features[j];

if (LV2_IS_FEATURE_REQUIRED(Feature->Type) && ! is_lv2_feature_supported(Feature->URI))
if (LV2_IS_FEATURE_REQUIRED(feature->Type) && ! is_lv2_feature_supported(feature->URI))
{
DISCOVERY_OUT("error", "plugin requires a non-supported feature " << Feature->URI);
DISCOVERY_OUT("error", "plugin requires a non-supported feature " << feature->URI);
supported = false;
break;
}
@@ -651,37 +664,37 @@ void do_lv2_check(const char* const bundle, const bool init)

for (uint32_t j=0; j < rdf_descriptor->PortCount; j++)
{
const LV2_RDF_Port* const Port = &rdf_descriptor->Ports[j];
const LV2_RDF_Port* const port = &rdf_descriptor->Ports[j];

if (LV2_IS_PORT_AUDIO(Port->Type))
if (LV2_IS_PORT_AUDIO(port->Type))
{
if (LV2_IS_PORT_INPUT(Port->Type))
if (LV2_IS_PORT_INPUT(port->Type))
audioIns += 1;
else if (LV2_IS_PORT_OUTPUT(Port->Type))
else if (LV2_IS_PORT_OUTPUT(port->Type))
audioOuts += 1;
audioTotal += 1;
}
else if (LV2_IS_PORT_CONTROL(Port->Type))
else if (LV2_IS_PORT_CONTROL(port->Type))
{
if (LV2_IS_PORT_DESIGNATION_LATENCY(Port->Designation) || LV2_IS_PORT_DESIGNATION_SAMPLE_RATE(Port->Designation) ||
LV2_IS_PORT_DESIGNATION_FREEWHEELING(Port->Designation) || LV2_IS_PORT_DESIGNATION_TIME(Port->Designation))
if (LV2_IS_PORT_DESIGNATION_LATENCY(port->Designation) || LV2_IS_PORT_DESIGNATION_SAMPLE_RATE(port->Designation) ||
LV2_IS_PORT_DESIGNATION_FREEWHEELING(port->Designation) || LV2_IS_PORT_DESIGNATION_TIME(port->Designation))
{
pass();
}
else
{
if (LV2_IS_PORT_INPUT(Port->Type))
if (LV2_IS_PORT_INPUT(port->Type))
parametersIns += 1;
else if (LV2_IS_PORT_OUTPUT(Port->Type))
else if (LV2_IS_PORT_OUTPUT(port->Type))
parametersOuts += 1;
parametersTotal += 1;
}
}
else if (Port->Type & LV2_PORT_SUPPORTS_MIDI_EVENT)
else if (port->Type & LV2_PORT_SUPPORTS_MIDI_EVENT)
{
if (LV2_IS_PORT_INPUT(Port->Type))
if (LV2_IS_PORT_INPUT(port->Type))
midiIns += 1;
else if (LV2_IS_PORT_OUTPUT(Port->Type))
else if (LV2_IS_PORT_OUTPUT(port->Type))
midiOuts += 1;
midiTotal += 1;
}
@@ -717,20 +730,20 @@ void do_lv2_check(const char* const bundle, const bool init)
}
}

void do_vst_check(void* const lib_handle, const bool init)
void do_vst_check(void* const libHandle, const bool init)
{
VST_Function vstfn = (VST_Function)lib_symbol(lib_handle, "VSTPluginMain");
VST_Function vstFn = (VST_Function)lib_symbol(libHandle, "VSTPluginMain");

if (! vstfn)
vstfn = (VST_Function)lib_symbol(lib_handle, "main");
if (! vstFn)
vstFn = (VST_Function)lib_symbol(libHandle, "main");

if (! vstfn)
if (! vstFn)
{
DISCOVERY_OUT("error", "Not a VST plugin");
return;
}

AEffect* const effect = vstfn(VstHostCallback);
AEffect* const effect = vstFn(vstHostCallback);

if (! (effect && effect->magic == kEffectMagic))
{
@@ -754,11 +767,11 @@ void do_vst_check(void* const lib_handle, const bool init)
effect->dispatcher(effect, effGetVendorString, 0, 0, strBuf, 0.0f);
cVendor = strdup((strBuf[0] != 0) ? strBuf : "");

VstCurrentUniqueId = effect->uniqueID;
intptr_t VstCategory = effect->dispatcher(effect, effGetPlugCategory, 0, 0, nullptr, 0.0f);
vstCurrentUniqueId = effect->uniqueID;
intptr_t vstCategory = effect->dispatcher(effect, effGetPlugCategory, 0, 0, nullptr, 0.0f);

// only init if required
if (init || VstCategory == kPlugCategShell)
if (init || vstCategory == kPlugCategShell)
effect->dispatcher(effect, effOpen, 0, 0, nullptr, 0.0f);

while (true)
@@ -780,10 +793,10 @@ void do_vst_check(void* const lib_handle, const bool init)
if (effect->flags & effFlagsIsSynth)
hints |= PLUGIN_IS_SYNTH;

if (VstPluginCanDo(effect, "receiveVstEvents") || VstPluginCanDo(effect, "receiveVstMidiEvent") || (effect->flags & effFlagsIsSynth) > 0)
if (vstPluginCanDo(effect, "receiveVstEvents") || vstPluginCanDo(effect, "receiveVstMidiEvent") || (effect->flags & effFlagsIsSynth) > 0)
midiIns = 1;

if (VstPluginCanDo(effect, "sendVstEvents") || VstPluginCanDo(effect, "sendVstMidiEvent"))
if (vstPluginCanDo(effect, "sendVstEvents") || vstPluginCanDo(effect, "sendVstMidiEvent"))
midiOuts = 1;

midiTotal = midiIns + midiOuts;
@@ -845,7 +858,7 @@ void do_vst_check(void* const lib_handle, const bool init)
if (midiIns > 0)
effect->dispatcher(effect, effProcessEvents, 0, 0, &events, 0.0f);

if (effect->processReplacing != effect->process && (effect->flags & effFlagsCanReplacing) > 0)
if ((effect->flags & effFlagsCanReplacing) > 0 && effect->processReplacing != effect->process)
effect->processReplacing(effect, bufferAudioIn, bufferAudioOut, bufferSize);
#if ! VST_FORCE_DEPRECATED
else
@@ -871,7 +884,7 @@ void do_vst_check(void* const lib_handle, const bool init)
DISCOVERY_OUT("label", cProduct);
DISCOVERY_OUT("maker", cVendor);
DISCOVERY_OUT("copyright", cVendor);
DISCOVERY_OUT("unique_id", VstCurrentUniqueId);
DISCOVERY_OUT("unique_id", vstCurrentUniqueId);
DISCOVERY_OUT("hints", hints);
DISCOVERY_OUT("audio.ins", audioIns);
DISCOVERY_OUT("audio.outs", audioOuts);
@@ -885,13 +898,13 @@ void do_vst_check(void* const lib_handle, const bool init)
DISCOVERY_OUT("build", BINARY_NATIVE);
DISCOVERY_OUT("end", "------------");

if (VstCategory != kPlugCategShell)
if (vstCategory != kPlugCategShell)
break;

strBuf[0] = 0;
VstCurrentUniqueId = effect->dispatcher(effect, effShellGetNextPlugin, 0, 0, strBuf, 0.0f);
vstCurrentUniqueId = effect->dispatcher(effect, effShellGetNextPlugin, 0, 0, strBuf, 0.0f);

if (VstCurrentUniqueId != 0)
if (vstCurrentUniqueId != 0)
{
free((void*)cName);
cName = strdup((strBuf[0] != 0) ? strBuf : "");
@@ -901,7 +914,7 @@ void do_vst_check(void* const lib_handle, const bool init)
}

// only close if required
if (init || VstCategory == kPlugCategShell)
if (init || vstCategory == kPlugCategShell)
effect->dispatcher(effect, effClose, 0, 0, nullptr, 0.0f);

free((void*)cName);
@@ -997,6 +1010,8 @@ void do_linuxsampler_check(const char* const filename, const char* const stype,
public:
LinuxSamplerScopedEngine(const char* const filename, const char* const stype)
{
engine = nullptr;

try {
engine = EngineFactory::Create(stype);
}
@@ -1006,6 +1021,9 @@ void do_linuxsampler_check(const char* const filename, const char* const stype,
return;
}

if (! engine)
return;

ins = engine->GetInstrumentManager();

if (! ins)
@@ -1038,7 +1056,7 @@ void do_linuxsampler_check(const char* const filename, const char* const stype,
EngineFactory::Destroy(engine);
}

static void outputInfo(InstrumentManager::instrument_info_t* const info, const int programs)
static void outputInfo(InstrumentManager::instrument_info_t* const info, const int programs, const char* const basename = nullptr)
{
DISCOVERY_OUT("init", "-----------");

@@ -1049,6 +1067,11 @@ void do_linuxsampler_check(const char* const filename, const char* const stype,
DISCOVERY_OUT("maker", info->Artists);
DISCOVERY_OUT("copyright", info->Artists);
}
else
{
DISCOVERY_OUT("name", basename);
DISCOVERY_OUT("label", basename);
}

DISCOVERY_OUT("hints", PLUGIN_IS_SYNTH);
DISCOVERY_OUT("audio.outs", 2);
@@ -1071,7 +1094,7 @@ void do_linuxsampler_check(const char* const filename, const char* const stype,
if (init)
const LinuxSamplerScopedEngine engine(filename, stype);
else
LinuxSamplerScopedEngine::outputInfo(nullptr, 0);
LinuxSamplerScopedEngine::outputInfo(nullptr, 0, file.baseName().toUtf8().constData());

#else
DISCOVERY_OUT("error", stype << " support not available");


+ 4
- 3
c++/carla-includes/carla_vst.h View File

@@ -100,6 +100,7 @@
#define kVstProcessPrecision32 0
#define kVstTransportChanged 1
#define kVstVersion 2400
#define VSTCALLBACK
struct ERect {
short top, left, bottom, right;
};
@@ -115,13 +116,13 @@ typedef VstTimeInfo VstTimeInfo_R;
typedef AEffect* (*VST_Function)(audioMasterCallback);

static inline
bool VstPluginCanDo(AEffect* const effect, const char* const feature)
bool vstPluginCanDo(AEffect* const effect, const char* const feature)
{
return (effect->dispatcher(effect, effCanDo, 0, 0, (void*)feature, 0.0f) == 1);
}

static inline
const char* VstEffectOpcode2str(const int32_t opcode)
const char* vstEffectOpcode2str(const int32_t opcode)
{
switch (opcode)
{
@@ -307,7 +308,7 @@ const char* VstEffectOpcode2str(const int32_t opcode)
}

static inline
const char* VstMasterOpcode2str(const int32_t opcode)
const char* vstMasterOpcode2str(const int32_t opcode)
{
switch (opcode)
{


+ 4
- 4
src/carla.py View File

@@ -889,10 +889,10 @@ class PluginDatabaseW(QDialog, ui_carla_database.Ui_PluginDatabaseW):
hide_other = not self.ch_other.isChecked()

hide_ladspa = not self.ch_ladspa.isChecked()
hide_dssi = not self.ch_dssi.isChecked()
hide_lv2 = not self.ch_lv2.isChecked()
hide_vst = not self.ch_vst.isChecked()
hide_kits = not self.ch_kits.isChecked()
hide_dssi = not self.ch_dssi.isChecked()
hide_lv2 = not self.ch_lv2.isChecked()
hide_vst = not self.ch_vst.isChecked()
hide_kits = not self.ch_kits.isChecked()

hide_native = not self.ch_native.isChecked()
hide_bridged = not self.ch_bridged.isChecked()


Loading…
Cancel
Save