Browse Source

Misc fixing

tags/1.9.4
falkTX 11 years ago
parent
commit
6cbecccaab
9 changed files with 505 additions and 459 deletions
  1. +5
    -11
      source/backend/plugin/BridgePlugin.cpp
  2. +1
    -1
      source/backend/plugin/CarlaPlugin.cpp
  3. +5
    -8
      source/backend/plugin/DssiPlugin.cpp
  4. +335
    -327
      source/backend/plugin/FluidSynthPlugin.cpp
  5. +4
    -4
      source/backend/plugin/LadspaPlugin.cpp
  6. +137
    -76
      source/backend/plugin/LinuxSamplerPlugin.cpp
  7. +4
    -11
      source/backend/plugin/Lv2Plugin.cpp
  8. +5
    -8
      source/backend/plugin/NativePlugin.cpp
  9. +9
    -13
      source/backend/plugin/VstPlugin.cpp

+ 5
- 11
source/backend/plugin/BridgePlugin.cpp View File

@@ -576,7 +576,7 @@ public:
#endif

// -------------------------------------------------------------------
// Set gui stuff
// Set ui stuff

void showCustomUI(const bool yesNo) override
{
@@ -1676,17 +1676,11 @@ public:

bool init(const char* const filename, const char* const name, const char* const label, const char* const bridgeBinary)
{
CARLA_ASSERT(pData->engine != nullptr);
CARLA_ASSERT(pData->client == nullptr);
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

// ---------------------------------------------------------------
// first checks

if (pData->engine == nullptr)
{
return false;
}

if (pData->client != nullptr)
{
pData->engine->setLastError("Plugin client is already registered");
@@ -1696,7 +1690,7 @@ public:
// ---------------------------------------------------------------
// set info

if (name != nullptr)
if (name != nullptr && name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(name);

pData->filename = filename;
@@ -1823,9 +1817,9 @@ public:

if (pData->name == nullptr)
{
if (name != nullptr)
if (name != nullptr && name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(name);
else if (label != nullptr)
else if (label != nullptr && label[0] != '\0')
pData->name = pData->engine->getUniquePluginName(label);
else
pData->name = pData->engine->getUniquePluginName("unknown");


+ 1
- 1
source/backend/plugin/CarlaPlugin.cpp View File

@@ -1402,7 +1402,7 @@ void CarlaPlugin::setMidiProgramById(const uint32_t bank, const uint32_t program
}

// -------------------------------------------------------------------
// Set gui stuff
// Set ui stuff

void CarlaPlugin::showCustomUI(const bool yesNo)
{


+ 5
- 8
source/backend/plugin/DssiPlugin.cpp View File

@@ -355,7 +355,7 @@ public:
}

// -------------------------------------------------------------------
// Set gui stuff
// Set ui stuff

void showCustomUI(const bool yesNo) override
{
@@ -1756,14 +1756,11 @@ public:

bool init(const char* const filename, const char* const name, const char* const label)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

// ---------------------------------------------------------------
// first checks

if (pData->engine == nullptr)
{
return false;
}

if (pData->client != nullptr)
{
pData->engine->setLastError("Plugin client is already registered");
@@ -1834,9 +1831,9 @@ public:
// ---------------------------------------------------------------
// get info

if (name != nullptr)
if (name != nullptr && name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(name);
else if (fDescriptor->Name != nullptr)
else if (fDescriptor->Name != nullptr && fDescriptor->Name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(fDescriptor->Name);
else
pData->name = pData->engine->getUniquePluginName(fDescriptor->Label);


+ 335
- 327
source/backend/plugin/FluidSynthPlugin.cpp View File

@@ -356,8 +356,6 @@ public:

void prepareForSave() override
{
CARLA_SAFE_ASSERT_RETURN(fSynth != nullptr,);

char strBuf[STR_MAX+1];
std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i", fCurMidiProgs[0], fCurMidiProgs[1], fCurMidiProgs[2], fCurMidiProgs[3],
fCurMidiProgs[4], fCurMidiProgs[5], fCurMidiProgs[6], fCurMidiProgs[7],
@@ -457,6 +455,8 @@ public:
uint i = 0;
foreach (const QString& midiProg, midiProgramList)
{
CARLA_SAFE_ASSERT_BREAK(i < MAX_MIDI_CHANNELS);

bool ok;
uint index = midiProg.toUInt(&ok);

@@ -510,7 +510,7 @@ public:
}

// -------------------------------------------------------------------
// Set gui stuff
// Set ui stuff

// nothing

@@ -533,7 +533,7 @@ public:

clearBuffers();

uint32_t aOuts, params, j;
uint32_t aOuts, params;
aOuts = fUses16Outs ? 32 : 2;
params = FluidSynthParametersMax;

@@ -548,7 +548,7 @@ public:

if (fUses16Outs)
{
for (j=0; j < 32; ++j)
for (int i=0; i < 32; ++i)
{
portName.clear();

@@ -560,26 +560,26 @@ public:

portName += "out-";

if ((j+2)/2 < 9)
if ((i+2)/2 < 9)
portName += "0";

portName += CarlaString((j+2)/2);
portName += CarlaString((i+2)/2);

if (j % 2 == 0)
if (i % 2 == 0)
portName += "L";
else
portName += "R";

portName.truncate(portNameSize);

pData->audioOut.ports[j].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false);
pData->audioOut.ports[j].rindex = j;
pData->audioOut.ports[i].port = (CarlaEngineAudioPort*)pData->client->addPort(kEnginePortTypeAudio, portName, false);
pData->audioOut.ports[i].rindex = i;
}

fAudio16Buffers = new float*[aOuts];

for (j=0; j < aOuts; ++j)
fAudio16Buffers[j] = nullptr;
for (uint32_t i=0; i < aOuts; ++i)
fAudio16Buffers[i] = nullptr;
}
else
{
@@ -626,7 +626,7 @@ public:
portName += ":";
}

portName += "event-in";
portName += "events-in";
portName.truncate(portNameSize);

pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true);
@@ -644,235 +644,242 @@ public:
portName += ":";
}

portName += "event-out";
portName += "events-out";
portName.truncate(portNameSize);

pData->event.portOut = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, false);
}

// ----------------------
j = FluidSynthReverbOnOff;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/ | PARAMETER_IS_BOOLEAN;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.0f;
pData->param.ranges[j].def = 1.0f;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthReverbRoomSize;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.2f;
pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_ROOMSIZE;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthReverbDamp;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.0f;
pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_DAMP;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthReverbLevel;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = MIDI_CONTROL_REVERB_SEND_LEVEL;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.0f;
pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_LEVEL;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthReverbWidth;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 10.0f; // should be 100, but that sounds too much
pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_WIDTH;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusOnOff;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_BOOLEAN;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.0f;
pData->param.ranges[j].def = 1.0f;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusNr;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 99.0f;
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_N;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 10.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusLevel;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = 0; //MIDI_CONTROL_CHORUS_SEND_LEVEL;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 10.0f;
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_LEVEL;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusSpeedHz;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.29f;
pData->param.ranges[j].max = 5.0f;
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_SPEED;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusDepthMs;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = float(2048.0 * 1000.0 / pData->engine->getSampleRate()); // FIXME?
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_DEPTH;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusType;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER | PARAMETER_USES_SCALEPOINTS;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = FLUID_CHORUS_MOD_SINE;
pData->param.ranges[j].max = FLUID_CHORUS_MOD_TRIANGLE;
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_TYPE;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthPolyphony;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 1.0f;
pData->param.ranges[j].max = 512.0f; // max theoric is 65535
pData->param.ranges[j].def = (float)fluid_synth_get_polyphony(fSynth);
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 10.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthInterpolation;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER | PARAMETER_USES_SCALEPOINTS;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = FLUID_INTERP_NONE;
pData->param.ranges[j].max = FLUID_INTERP_HIGHEST;
pData->param.ranges[j].def = FLUID_INTERP_DEFAULT;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthVoiceCount;
pData->param.data[j].type = PARAMETER_OUTPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE | PARAMETER_IS_INTEGER;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 65535.0f;
pData->param.ranges[j].def = 0.0f;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;
// ---------------------------------------
// Parameters

{
int j;

// ----------------------
j = FluidSynthReverbOnOff;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/ | PARAMETER_IS_BOOLEAN;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.0f;
pData->param.ranges[j].def = 1.0f;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthReverbRoomSize;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.2f;
pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_ROOMSIZE;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthReverbDamp;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.0f;
pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_DAMP;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthReverbLevel;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = MIDI_CONTROL_REVERB_SEND_LEVEL;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.0f;
pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_LEVEL;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthReverbWidth;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED /*| PARAMETER_IS_AUTOMABLE*/;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 10.0f; // should be 100, but that sounds too much
pData->param.ranges[j].def = FLUID_REVERB_DEFAULT_WIDTH;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusOnOff;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_BOOLEAN;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 1.0f;
pData->param.ranges[j].def = 1.0f;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusNr;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 99.0f;
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_N;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 10.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusLevel;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = 0; //MIDI_CONTROL_CHORUS_SEND_LEVEL;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 10.0f;
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_LEVEL;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusSpeedHz;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.29f;
pData->param.ranges[j].max = 5.0f;
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_SPEED;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusDepthMs;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = float(2048.0 * 1000.0 / pData->engine->getSampleRate()); // FIXME?
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_DEPTH;
pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f;
pData->param.ranges[j].stepLarge = 0.1f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthChorusType;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER | PARAMETER_USES_SCALEPOINTS;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = FLUID_CHORUS_MOD_SINE;
pData->param.ranges[j].max = FLUID_CHORUS_MOD_TRIANGLE;
pData->param.ranges[j].def = FLUID_CHORUS_DEFAULT_TYPE;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthPolyphony;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 1.0f;
pData->param.ranges[j].max = 512.0f; // max theoric is 65535
pData->param.ranges[j].def = (float)fluid_synth_get_polyphony(fSynth);
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 10.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthInterpolation;
pData->param.data[j].type = PARAMETER_INPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_INTEGER | PARAMETER_USES_SCALEPOINTS;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = FLUID_INTERP_NONE;
pData->param.ranges[j].max = FLUID_INTERP_HIGHEST;
pData->param.ranges[j].def = FLUID_INTERP_DEFAULT;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;

// ----------------------
j = FluidSynthVoiceCount;
pData->param.data[j].type = PARAMETER_OUTPUT;
pData->param.data[j].hints = PARAMETER_IS_ENABLED | PARAMETER_IS_AUTOMABLE | PARAMETER_IS_INTEGER;
pData->param.data[j].index = j;
pData->param.data[j].rindex = j;
pData->param.data[j].midiChannel = 0;
pData->param.data[j].midiCC = -1;
pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 65535.0f;
pData->param.ranges[j].def = 0.0f;
pData->param.ranges[j].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 1.0f;
fParamBuffers[j] = pData->param.ranges[j].def;
}

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

@@ -902,54 +909,58 @@ public:
{
carla_debug("FluidSynthPlugin::reloadPrograms(%s)", bool2str(init));

// save drum info in case we have one program for it
bool hasDrums = false;
uint32_t drumIndex, drumProg;

// Delete old programs
pData->midiprog.clear();

// Query new programs
uint32_t count = 0;
fluid_sfont_t* f_sfont;
fluid_preset_t f_preset;

bool hasDrums = false;
uint32_t drumIndex, drumProg;
if (fluid_sfont_t* const f_sfont = fluid_synth_get_sfont_by_id(fSynth, fSynthId))
{
fluid_preset_t f_preset;

f_sfont = fluid_synth_get_sfont_by_id(fSynth, fSynthId);
// initial check to know how many midi-programs we have
f_sfont->iteration_start(f_sfont);
while (f_sfont->iteration_next(f_sfont, &f_preset))
++count;

// initial check to know how much midi-programs we have
f_sfont->iteration_start(f_sfont);
while (f_sfont->iteration_next(f_sfont, &f_preset))
count += 1;
// sound kits must always have at least 1 midi-program
CARLA_SAFE_ASSERT_RETURN(count > 0,);

// soundfonts must always have at least 1 midi-program
CARLA_ASSERT(count > 0);
pData->midiprog.createNew(count);

if (count == 0)
return;
// Update data
uint32_t i = 0;
f_sfont->iteration_start(f_sfont);

pData->midiprog.createNew(count);
while (f_sfont->iteration_next(f_sfont, &f_preset))
{
CARLA_SAFE_ASSERT_BREAK(i < count);

// Update data
uint32_t i = 0;
f_sfont->iteration_start(f_sfont);
pData->midiprog.data[i].bank = f_preset.get_banknum(&f_preset);
pData->midiprog.data[i].program = f_preset.get_num(&f_preset);
pData->midiprog.data[i].name = carla_strdup(f_preset.get_name(&f_preset));

while (f_sfont->iteration_next(f_sfont, &f_preset))
{
CARLA_ASSERT(i < pData->midiprog.count);
pData->midiprog.data[i].bank = f_preset.get_banknum(&f_preset);
pData->midiprog.data[i].program = f_preset.get_num(&f_preset);
pData->midiprog.data[i].name = carla_strdup(f_preset.get_name(&f_preset));
if (pData->midiprog.data[i].bank == 128 && ! hasDrums)
{
hasDrums = true;
drumIndex = i;
drumProg = pData->midiprog.data[i].program;
}

if (pData->midiprog.data[i].bank == 128 && ! hasDrums)
{
hasDrums = true;
drumIndex = i;
drumProg = pData->midiprog.data[i].program;
++i;
}

++i;
}

//f_sfont->free(f_sfont);
else
{
// failing means 0 midi-programs, it shouldn't happen!
carla_safe_assert("fluid_sfont_t* const f_sfont = fluid_synth_get_sfont_by_id(fSynth, fSynthId)", __FILE__, __LINE__);
return;
}

#ifndef BUILD_BRIDGE
// Update OSC Names
@@ -957,7 +968,7 @@ public:
{
pData->engine->oscSend_control_set_midi_program_count(pData->id, count);

for (i=0; i < count; ++i)
for (uint32_t i=0; i < count; ++i)
pData->engine->oscSend_control_set_midi_program_data(pData->id, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
}
#endif
@@ -967,7 +978,7 @@ public:
fluid_synth_program_reset(fSynth);

// select first program, or 128 for ch10
for (i=0; i < MAX_MIDI_CHANNELS && i != 9; ++i)
for (uint32_t i=0; i < MAX_MIDI_CHANNELS && i != 9; ++i)
{
#ifdef FLUIDSYNTH_VERSION_NEW_API
fluid_synth_set_channel_type(fSynth, i, CHANNEL_TYPE_MELODIC);
@@ -1009,22 +1020,14 @@ public:

void process(float** const, float** const outBuffer, const uint32_t frames) override
{
uint32_t i, k;

// --------------------------------------------------------------------------------------------------------
// Check if active

if (! pData->active)
{
// disable any output sound
for (i=0; i < pData->audioOut.count; ++i)
{
#ifdef HAVE_JUCE
FloatVectorOperations::clear(outBuffer[i], frames);
#else
#endif
}

for (uint32_t i=0; i < pData->audioOut.count; ++i)
FLOAT_CLEAR(outBuffer[i], frames);
return;
}

@@ -1035,21 +1038,21 @@ public:
{
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
for (int c=0; c < MAX_MIDI_CHANNELS; ++c)
for (int i=0; i < MAX_MIDI_CHANNELS; ++i)
{
#ifdef FLUIDSYNTH_VERSION_NEW_API
fluid_synth_all_notes_off(fSynth, c);
fluid_synth_all_sounds_off(fSynth, c);
fluid_synth_all_notes_off(fSynth, i);
fluid_synth_all_sounds_off(fSynth, i);
#else
fluid_synth_cc(fSynth, c, MIDI_CONTROL_ALL_SOUND_OFF, 0);
fluid_synth_cc(fSynth, c, MIDI_CONTROL_ALL_NOTES_OFF, 0);
fluid_synth_cc(fSynth, i, MIDI_CONTROL_ALL_SOUND_OFF, 0);
fluid_synth_cc(fSynth, i, MIDI_CONTROL_ALL_NOTES_OFF, 0);
#endif
}
}
else if (pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
{
for (k=0; k < MAX_MIDI_NOTE; ++k)
fluid_synth_noteoff(fSynth, pData->ctrlChannel, k);
for (int i=0; i < MAX_MIDI_NOTE; ++i)
fluid_synth_noteoff(fSynth, pData->ctrlChannel, i);
}

pData->needsReset = false;
@@ -1068,7 +1071,7 @@ public:
{
const ExternalMidiNote& note(pData->extNotes.data.getFirst(true));

CARLA_ASSERT(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS);
CARLA_SAFE_ASSERT_CONTINUE(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS);

if (note.velo > 0)
fluid_synth_noteon(fSynth, note.channel, note.note, note.velo);
@@ -1093,16 +1096,14 @@ public:
if (pData->midiprog.current >= 0 && pData->midiprog.count > 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
nextBankIds[pData->ctrlChannel] = pData->midiprog.data[pData->midiprog.current].bank;

for (i=0; i < nEvents; ++i)
for (uint32_t i=0; i < nEvents; ++i)
{
const EngineEvent& event(pData->event.portIn->getEvent(i));

time = event.time;

if (time >= frames)
continue;

CARLA_ASSERT_INT2(time >= timeOffset, time, timeOffset);
CARLA_SAFE_ASSERT_CONTINUE(time < frames);
CARLA_SAFE_ASSERT_BREAK(time >= timeOffset);

if (time > timeOffset)
{
@@ -1110,7 +1111,7 @@ public:
{
timeOffset = time;

if (pData->midiprog.current >= 0 && pData->midiprog.count > 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < 16)
if (pData->midiprog.current >= 0 && pData->midiprog.count > 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
nextBankIds[pData->ctrlChannel] = pData->midiprog.data[pData->midiprog.current].bank;
}
}
@@ -1182,7 +1183,7 @@ public:
#endif

// Control plugin parameters
for (k=0; k < pData->param.count; ++k)
for (uint32_t k=0; k < pData->param.count; ++k)
{
if (pData->param.data[k].midiChannel != event.channel)
continue;
@@ -1230,7 +1231,7 @@ public:
const uint32_t bankId(nextBankIds[event.channel]);
const uint32_t progId(ctrlEvent.param);

for (k=0; k < pData->midiprog.count; ++k)
for (uint32_t k=0; k < pData->midiprog.count; ++k)
{
if (pData->midiprog.data[k].bank == bankId && pData->midiprog.data[k].program == progId)
{
@@ -1328,10 +1329,11 @@ public:
}
else if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) != 0)
{
const uint8_t lsb = midiEvent.data[1];
const uint8_t msb = midiEvent.data[2];
const uint8_t lsb = midiEvent.data[1];
const uint8_t msb = midiEvent.data[2];
const int value = ((msb << 7) | lsb) - 8192;

fluid_synth_pitch_bend(fSynth, channel, (msb << 7) | lsb);
fluid_synth_pitch_bend(fSynth, channel, value);
}

break;
@@ -1352,8 +1354,8 @@ public:
// Control Output

{
k = FluidSynthVoiceCount;
fParamBuffers[k] = (float)fluid_synth_get_active_voice_count(fSynth);
uint32_t k = FluidSynthVoiceCount;
fParamBuffers[k] = float(fluid_synth_get_active_voice_count(fSynth));
pData->param.ranges[k].fixValue(fParamBuffers[k]);

if (pData->param.data[k].midiCC > 0)
@@ -1370,8 +1372,6 @@ public:
CARLA_SAFE_ASSERT_RETURN(outBuffer != nullptr, false);
CARLA_SAFE_ASSERT_RETURN(frames > 0, false);

uint32_t i, k;

// --------------------------------------------------------------------------------------------------------
// Try lock, silence otherwise

@@ -1381,9 +1381,9 @@ public:
}
else if (! pData->singleMutex.tryLock())
{
for (i=0; i < pData->audioOut.count; ++i)
for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
for (k=0; k < frames; ++k)
for (uint32_t k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = 0.0f;
}

@@ -1395,7 +1395,7 @@ public:

if (fUses16Outs)
{
for (i=0; i < pData->audioOut.count; ++i)
for (uint32_t i=0; i < pData->audioOut.count; ++i)
FLOAT_CLEAR(fAudio16Buffers[i], frames);

fluid_synth_process(fSynth, frames, 0, nullptr, pData->audioOut.count, fAudio16Buffers);
@@ -1414,7 +1414,7 @@ public:

float oldBufLeft[doBalance ? frames : 1];

for (i=0; i < pData->audioOut.count; ++i)
for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
// Balance
if (doBalance)
@@ -1425,7 +1425,7 @@ public:
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f;

for (k=0; k < frames; ++k)
for (uint32_t k=0; k < frames; ++k)
{
if (i % 2 == 0)
{
@@ -1445,12 +1445,12 @@ public:
// Volume
if (fUses16Outs)
{
for (k=0; k < frames; ++k)
for (uint32_t k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = fAudio16Buffers[i][k] * pData->postProc.volume;
}
else if (doVolume)
{
for (k=0; k < frames; ++k)
for (uint32_t k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] *= pData->postProc.volume;
}
}
@@ -1459,9 +1459,9 @@ public:
#else
if (fUses16Outs)
{
for (i=0; i < pData->audioOut.count; ++i)
for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
for (k=0; k < frames; ++k)
for (uint32_t k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = fAudio16Buffers[i][k];
}
}
@@ -1486,6 +1486,19 @@ public:
}
}

void sampleRateChanged(const double newSampleRate) override
{
CARLA_SAFE_ASSERT_RETURN(fSettings != nullptr,);

fluid_settings_setnum(fSettings, "synth.sample-rate", newSampleRate);

#ifdef FLUIDSYNTH_VERSION_NEW_API
CARLA_SAFE_ASSERT_RETURN(fSynth != nullptr,);

fluid_synth_set_sample_rate(fSynth, float(newSampleRate));
#endif
}

// -------------------------------------------------------------------
// Plugin buffers

@@ -1517,23 +1530,18 @@ public:

const void* getExtraStuff() const noexcept override
{
return fUses16Outs ? (const void*)0x1 : nullptr;
static const char xtrue[] = "true";
static const char xfalse[] = "false";
return fUses16Outs ? xtrue : xfalse;
}

bool init(const char* const filename, const char* const name, const char* const label)
{
CARLA_ASSERT(fSynth != nullptr);
CARLA_ASSERT(filename != nullptr);
CARLA_ASSERT(label != nullptr);
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

// ---------------------------------------------------------------
// first checks

if (pData->engine == nullptr)
{
return false;
}

if (pData->client != nullptr)
{
pData->engine->setLastError("Plugin client is already registered");
@@ -1546,13 +1554,13 @@ public:
return false;
}

if (filename == nullptr)
if (filename == nullptr || filename[0] == '\0')
{
pData->engine->setLastError("null filename");
return false;
}

if (label == nullptr)
if (label == nullptr || label[0] == '\0')
{
pData->engine->setLastError("null label");
return false;
@@ -1580,7 +1588,7 @@ public:
pData->filename = carla_strdup(filename);
fLabel = label2.dup();

if (name != nullptr)
if (name != nullptr && name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(name);
else
pData->name = pData->engine->getUniquePluginName(label);
@@ -1648,8 +1656,8 @@ private:
const bool fUses16Outs;

fluid_settings_t* fSettings;
fluid_synth_t* fSynth;
int fSynthId;
fluid_synth_t* fSynth;
int fSynthId;

float** fAudio16Buffers;
float fParamBuffers[FluidSynthParametersMax];


+ 4
- 4
source/backend/plugin/LadspaPlugin.cpp View File

@@ -387,7 +387,7 @@ public:
}

// -------------------------------------------------------------------
// Set gui stuff
// Set ui stuff

// nothing

@@ -1399,11 +1399,11 @@ public:
if (is_ladspa_rdf_descriptor_valid(rdfDescriptor, fDescriptor))
fRdfDescriptor = ladspa_rdf_dup(rdfDescriptor);

if (name != nullptr)
if (name != nullptr && name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(name);
else if (fRdfDescriptor != nullptr && fRdfDescriptor->Title != nullptr)
else if (fRdfDescriptor != nullptr && fRdfDescriptor->Title != nullptr && fRdfDescriptor->Title[0] != '\0')
pData->name = pData->engine->getUniquePluginName(fRdfDescriptor->Title);
else if (fDescriptor->Name != nullptr)
else if (fDescriptor->Name != nullptr && fDescriptor->Name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(fDescriptor->Name);
else
pData->name = pData->engine->getUniquePluginName(fDescriptor->Label);


+ 137
- 76
source/backend/plugin/LinuxSamplerPlugin.cpp View File

@@ -177,8 +177,11 @@ class LinuxSamplerPlugin : public CarlaPlugin
public:
LinuxSamplerPlugin(CarlaEngine* const engine, const unsigned int id, const char* const format, const bool use16Outs)
: CarlaPlugin(engine, id),
fFormat(carla_strdup(format)),
fUses16Outs(use16Outs),
fFormat(carla_strdup(format)),
fRealName(nullptr),
fLabel(nullptr),
fMaker(nullptr),
fEngine(nullptr),
fMidiInputDevice(nullptr),
fMidiInputPort(nullptr),
@@ -261,6 +264,24 @@ public:
fFormat = nullptr;
}

if (fRealName != nullptr)
{
delete[] fRealName;
fRealName = nullptr;
}

if (fLabel != nullptr)
{
delete[] fLabel;
fLabel = nullptr;
}

if (fMaker != nullptr)
{
delete[] fMaker;
fMaker = nullptr;
}

clearBuffers();
}

@@ -296,6 +317,7 @@ public:

options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES;
options |= PLUGIN_OPTION_SEND_CONTROL_CHANGES;
options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE;
options |= PLUGIN_OPTION_SEND_PITCHBEND;
options |= PLUGIN_OPTION_SEND_ALL_SOUND_OFF;

@@ -304,12 +326,18 @@ public:

void getLabel(char* const strBuf) const override
{
std::strncpy(strBuf, (const char*)fLabel, STR_MAX);
if (fLabel != nullptr)
std::strncpy(strBuf, fLabel, STR_MAX);
else
CarlaPlugin::getLabel(strBuf);
}

void getMaker(char* const strBuf) const override
{
std::strncpy(strBuf, (const char*)fMaker, STR_MAX);
if (fMaker != nullptr)
std::strncpy(strBuf, fMaker, STR_MAX);
else
CarlaPlugin::getMaker(strBuf);
}

void getCopyright(char* const strBuf) const override
@@ -319,7 +347,10 @@ public:

void getRealName(char* const strBuf) const override
{
std::strncpy(strBuf, (const char*)fRealName, STR_MAX);
if (fRealName != nullptr)
std::strncpy(strBuf, fRealName, STR_MAX);
else
CarlaPlugin::getRealName(strBuf);
}

// -------------------------------------------------------------------
@@ -355,7 +386,7 @@ public:
CARLA_SAFE_ASSERT_RETURN(type != nullptr && type[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(value != nullptr && value[0] != '\0',);
carla_debug("DssiPlugin::setCustomData(%s, \"%s\", \"%s\", %s)", type, key, value, bool2str(sendGui));
carla_debug("LinuxSamplerPlugin::setCustomData(%s, \"%s\", \"%s\", %s)", type, key, value, bool2str(sendGui));

if (std::strcmp(type, CUSTOM_DATA_TYPE_STRING) != 0)
return carla_stderr2("LinuxSamplerPlugin::setCustomData(\"%s\", \"%s\", \"%s\", %s) - type is not string", type, key, value, bool2str(sendGui));
@@ -373,6 +404,8 @@ public:
uint i = 0;
foreach (const QString& midiProg, midiProgramList)
{
CARLA_SAFE_ASSERT_BREAK(i < MAX_MIDI_CHANNELS);

bool ok;
uint index = midiProg.toUInt(&ok);

@@ -426,7 +459,7 @@ public:
const uint32_t program = pData->midiprog.data[index].program;
const uint32_t rIndex = bank*128 + program;

LinuxSampler::EngineChannel* const engineChannel(fUses16Outs ? fEngineChannels[pData->ctrlChannel] : fEngineChannels[0]);
LinuxSampler::EngineChannel* const engineChannel(fEngineChannels[pData->ctrlChannel]);

const ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback));

@@ -446,6 +479,11 @@ public:
CarlaPlugin::setMidiProgram(index, sendGui, sendOsc, sendCallback);
}

// -------------------------------------------------------------------
// Set ui stuff

// nothing

// -------------------------------------------------------------------
// Plugin state

@@ -470,7 +508,7 @@ public:

pData->audioOut.createNew(aOuts);

const int portNameSize = pData->engine->getMaxPortNameSize();
const int portNameSize(pData->engine->getMaxPortNameSize());
CarlaString portName;

// ---------------------------------------
@@ -478,7 +516,7 @@ public:

if (fUses16Outs)
{
for (uint32_t i=0; i < 32; ++i)
for (int i=0; i < 32; ++i)
{
portName.clear();

@@ -551,7 +589,7 @@ public:
portName += ":";
}

portName += "event-in";
portName += "events-in";
portName.truncate(portNameSize);

pData->event.portIn = (CarlaEngineEventPort*)pData->client->addPort(kEnginePortTypeEvent, portName, true);
@@ -589,16 +627,17 @@ public:
pData->midiprog.clear();

// Query new programs
uint32_t i, count = (uint32_t)fInstrumentIds.size();
uint32_t count = uint32_t(fInstrumentIds.size());

// sound kits must always have at least 1 midi-program
CARLA_SAFE_ASSERT_RETURN(count > 0,);

pData->midiprog.createNew(count);

// Update data
LinuxSampler::InstrumentManager::instrument_info_t info;

for (i=0; i < pData->midiprog.count; ++i)
for (uint32_t i=0; i < pData->midiprog.count; ++i)
{
pData->midiprog.data[i].bank = i / 128;
pData->midiprog.data[i].program = i % 128;
@@ -620,7 +659,7 @@ public:
{
pData->engine->oscSend_control_set_midi_program_count(pData->id, count);

for (i=0; i < count; ++i)
for (uint32_t i=0; i < count; ++i)
pData->engine->oscSend_control_set_midi_program_data(pData->id, i, pData->midiprog.data[i].bank, pData->midiprog.data[i].program, pData->midiprog.data[i].name);
}
#endif
@@ -647,6 +686,7 @@ public:
// -------------------------------------------------------------------
// Plugin processing

#if 0
void activate() override
{
for (int i=0; i < 16; ++i)
@@ -664,18 +704,17 @@ public:
fAudioOutputDevices[i]->Stop();
}
}
#endif

void process(float** const, float** const outBuffer, const uint32_t frames) override
{
uint32_t i, k;

// --------------------------------------------------------------------------------------------------------
// Check if active

if (! pData->active)
{
// disable any output sound
for (i=0; i < pData->audioOut.count; ++i)
for (uint32_t i=0; i < pData->audioOut.count; ++i)
FLOAT_CLEAR(outBuffer[i], frames);
return;
}
@@ -687,16 +726,16 @@ public:
{
if (pData->options & PLUGIN_OPTION_SEND_ALL_SOUND_OFF)
{
for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; ++k)
for (uint i=0; i < MAX_MIDI_CHANNELS; ++i)
{
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_NOTES_OFF, 0, k);
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, k);
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_NOTES_OFF, 0, i);
fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, i);
}
}
else if (pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
{
for (uint8_t i=0; i < MAX_MIDI_NOTE; ++i)
fMidiInputPort->DispatchNoteOff(i, 0, (uint)pData->ctrlChannel);
fMidiInputPort->DispatchNoteOff(i, 0, uint(pData->ctrlChannel));
}

pData->needsReset = false;
@@ -715,12 +754,12 @@ public:
{
const ExternalMidiNote& note(pData->extNotes.data.getFirst(true));

CARLA_ASSERT(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS);
CARLA_SAFE_ASSERT_CONTINUE(note.channel >= 0 && note.channel < MAX_MIDI_CHANNELS);

if (note.velo > 0)
fMidiInputPort->DispatchNoteOn(note.note, note.velo, note.channel, 0);
fMidiInputPort->DispatchNoteOn(note.note, note.velo, note.channel);
else
fMidiInputPort->DispatchNoteOff(note.note, note.velo, note.channel, 0);
fMidiInputPort->DispatchNoteOff(note.note, note.velo, note.channel);
}

pData->extNotes.mutex.unlock();
@@ -736,21 +775,20 @@ public:
uint32_t time, nEvents = pData->event.portIn->getEventCount();
uint32_t startTime = 0;
uint32_t timeOffset = 0;
uint32_t nextBankId = 0;

if (pData->midiprog.current >= 0 && pData->midiprog.count > 0)
nextBankId = pData->midiprog.data[pData->midiprog.current].bank;
uint32_t nextBankIds[MAX_MIDI_CHANNELS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0 };

if (pData->midiprog.current >= 0 && pData->midiprog.count > 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
nextBankIds[pData->ctrlChannel] = pData->midiprog.data[pData->midiprog.current].bank;

for (i=0; i < nEvents; ++i)
for (uint32_t i=0; i < nEvents; ++i)
{
const EngineEvent& event(pData->event.portIn->getEvent(i));

time = event.time;

if (time >= frames)
continue;

CARLA_ASSERT_INT2(time >= timeOffset, time, timeOffset);
CARLA_SAFE_ASSERT_CONTINUE(time < frames);
CARLA_SAFE_ASSERT_BREAK(time >= timeOffset);

if (time > timeOffset && sampleAccurate)
{
@@ -759,10 +797,8 @@ public:
startTime = 0;
timeOffset = time;

if (pData->midiprog.current >= 0 && pData->midiprog.count > 0)
nextBankId = pData->midiprog.data[pData->midiprog.current].bank;
else
nextBankId = 0;
if (pData->midiprog.current >= 0 && pData->midiprog.count > 0 && pData->ctrlChannel >= 0 && pData->ctrlChannel < MAX_MIDI_CHANNELS)
nextBankIds[pData->ctrlChannel] = pData->midiprog.data[pData->midiprog.current].bank;
}
else
startTime += timeOffset;
@@ -835,7 +871,7 @@ public:
#endif

// Control plugin parameters
for (k=0; k < pData->param.count; ++k)
for (uint32_t k=0; k < pData->param.count; ++k)
{
if (pData->param.data[k].midiChannel != event.channel)
continue;
@@ -873,21 +909,38 @@ public:
}

case kEngineControlEventTypeMidiBank:
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
nextBankId = ctrlEvent.param;
if (event.channel < MAX_MIDI_CHANNELS && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
nextBankIds[event.channel] = ctrlEvent.param;
break;

case kEngineControlEventTypeMidiProgram:
if (event.channel == pData->ctrlChannel && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
if (event.channel < MAX_MIDI_CHANNELS && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
{
const uint32_t nextProgramId = ctrlEvent.param;
const uint32_t bankId(nextBankIds[event.channel]);
const uint32_t progId(ctrlEvent.param);
const uint32_t rIndex = bankId*128 + progId;

for (k=0; k < pData->midiprog.count; ++k)
for (uint32_t k=0; k < pData->midiprog.count; ++k)
{
if (pData->midiprog.data[k].bank == nextBankId && pData->midiprog.data[k].program == nextProgramId)
if (pData->midiprog.data[k].bank == bankId && pData->midiprog.data[k].program == progId)
{
setMidiProgram(k, false, false, false);
pData->postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f);
LinuxSampler::EngineChannel* const engineChannel(fEngineChannels[pData->ctrlChannel]);

if (pData->engine->isOffline())
{
engineChannel->PrepareLoadInstrument(pData->filename, rIndex);
engineChannel->LoadInstrument();
}
else
{
fInstrument->LoadInstrumentInBackground(fInstrumentIds[rIndex], engineChannel);
}

fCurMidiProgs[event.channel] = k;

if (event.channel == pData->ctrlChannel)
pData->postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f);

break;
}
}
@@ -914,7 +967,6 @@ public:
}
break;
}

break;
}

@@ -925,7 +977,7 @@ public:
uint8_t status = MIDI_GET_STATUS_FROM_DATA(midiEvent.data);
uint8_t channel = event.channel;

// Fix bad note-off (per DSSI spec)
// Fix bad note-off
if (MIDI_IS_STATUS_NOTE_ON(status) && midiEvent.data[2] == 0)
status = MIDI_STATUS_NOTE_OFF;

@@ -970,10 +1022,11 @@ public:
}
else if (MIDI_IS_STATUS_PITCH_WHEEL_CONTROL(status) && (pData->options & PLUGIN_OPTION_SEND_PITCHBEND) != 0)
{
const uint8_t lsb = midiEvent.data[1];
const uint8_t msb = midiEvent.data[2];
const uint8_t lsb = midiEvent.data[1];
const uint8_t msb = midiEvent.data[2];
const int value = ((msb << 7) | lsb) - 8192;

fMidiInputPort->DispatchPitchbend(((msb << 7) | lsb) - 8192, channel, fragmentPos);
fMidiInputPort->DispatchPitchbend(value, channel, fragmentPos);
}

break;
@@ -991,15 +1044,8 @@ public:

bool processSingle(float** const outBuffer, const uint32_t frames, const uint32_t timeOffset)
{
CARLA_ASSERT(outBuffer != nullptr);
CARLA_ASSERT(frames > 0);

if (outBuffer == nullptr)
return false;
if (frames == 0)
return false;

uint32_t i, k;
CARLA_SAFE_ASSERT_RETURN(outBuffer != nullptr, false);
CARLA_SAFE_ASSERT_RETURN(frames > 0, false);

// --------------------------------------------------------------------------------------------------------
// Try lock, silence otherwise
@@ -1010,9 +1056,9 @@ public:
}
else if (! pData->singleMutex.tryLock())
{
for (i=0; i < pData->audioOut.count; ++i)
for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
for (k=0; k < frames; ++k)
for (uint32_t k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] = 0.0f;
}

@@ -1051,7 +1097,7 @@ public:

float oldBufLeft[doBalance ? frames : 1];

for (i=0; i < pData->audioOut.count; ++i)
for (uint32_t i=0; i < pData->audioOut.count; ++i)
{
// Balance
if (doBalance)
@@ -1062,7 +1108,7 @@ public:
float balRangeL = (pData->postProc.balanceLeft + 1.0f)/2.0f;
float balRangeR = (pData->postProc.balanceRight + 1.0f)/2.0f;

for (k=0; k < frames; ++k)
for (uint32_t k=0; k < frames; ++k)
{
if (i % 2 == 0)
{
@@ -1082,7 +1128,7 @@ public:
// Volume
if (doVolume)
{
for (k=0; k < frames; ++k)
for (uint32_t k=0; k < frames; ++k)
outBuffer[i][k+timeOffset] *= pData->postProc.volume;
}
}
@@ -1096,6 +1142,18 @@ public:
return true;
}

void bufferSizeChanged(const uint32_t newBufferSize) override
{
// TODO
(void)newBufferSize;
}

void sampleRateChanged(const double newSampleRate) override
{
// TODO
(void)newSampleRate;
}

// -------------------------------------------------------------------
// Plugin buffers

@@ -1105,7 +1163,9 @@ public:

const void* getExtraStuff() const noexcept override
{
return fUses16Outs ? (const void*)0x1 : nullptr;
static const char xtrue[] = "true";
static const char xfalse[] = "false";
return fUses16Outs ? xtrue : xfalse;
}

bool init(const char* filename, const char* const name, const char* label)
@@ -1233,19 +1293,21 @@ public:
return false;
}

fRealName = info.InstrumentName.c_str();
fLabel = info.Product.c_str();
fMaker = info.Artists.c_str();
CarlaString label2(label);

pData->filename = carla_strdup(filename);
if (fUses16Outs && ! label2.endsWith(" (16 outs)"))
label2 += " (16 outs)";

if (fUses16Outs && ! fLabel.endsWith(" (16 outs)"))
fLabel += " (16 outs)";
fRealName = carla_strdup(info.InstrumentName.c_str());
fLabel = label2.dup();
fMaker = carla_strdup(info.Artists.c_str());

if (name != nullptr)
pData->filename = carla_strdup(filename);

if (name != nullptr && name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(name);
else
pData->name = pData->engine->getUniquePluginName((const char*)fRealName);
pData->name = pData->engine->getUniquePluginName(fRealName);

// ---------------------------------------------------------------
// Register client
@@ -1293,15 +1355,14 @@ public:
// -------------------------------------------------------------------

private:
const char* fFormat;
const bool fUses16Outs;
const char* fFormat;
const char* fRealName;
const char* fLabel;
const char* fMaker;

int32_t fCurMidiProgs[16];

CarlaString fRealName;
CarlaString fLabel;
CarlaString fMaker;

LinuxSampler::Sampler fSampler;
LinuxSampler::Engine* fEngine;



+ 4
- 11
source/backend/plugin/Lv2Plugin.cpp View File

@@ -1053,7 +1053,7 @@ public:
}

// -------------------------------------------------------------------
// Set gui stuff
// Set ui stuff

void showCustomUI(const bool yesNo) override
{
@@ -4123,25 +4123,18 @@ protected:
public:
bool init(const char* const name, const char* const uri)
{
CARLA_ASSERT(pData->engine != nullptr);
CARLA_ASSERT(pData->client == nullptr);
CARLA_ASSERT(uri != nullptr);
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

// ---------------------------------------------------------------
// first checks

if (pData->engine == nullptr)
{
return false;
}

if (pData->client != nullptr)
{
pData->engine->setLastError("Plugin client is already registered");
return false;
}

if (uri == nullptr)
if (uri == nullptr || uri[0] == '\0')
{
pData->engine->setLastError("null uri");
return false;
@@ -4403,7 +4396,7 @@ public:
// ---------------------------------------------------------------
// get info

if (name != nullptr)
if (name != nullptr && name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(name);
else
pData->name = pData->engine->getUniquePluginName(fRdfDescriptor->Name);


+ 5
- 8
source/backend/plugin/NativePlugin.cpp View File

@@ -625,7 +625,7 @@ public:
}

// -------------------------------------------------------------------
// Set gui stuff
// Set ui stuff

void showCustomUI(const bool yesNo) override
{
@@ -2173,14 +2173,11 @@ public:

bool init(const char* const name, const char* const label)
{
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

// ---------------------------------------------------------------
// first checks

if (pData->engine == nullptr)
{
return false;
}

if (pData->client != nullptr)
{
pData->engine->setLastError("Plugin client is already registered");
@@ -2240,9 +2237,9 @@ public:
// ---------------------------------------------------------------
// get info

if (name != nullptr)
if (name != nullptr && name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(name);
else if (fDescriptor->name != nullptr)
else if (fDescriptor->name != nullptr && fDescriptor->name[0] != '\0')
pData->name = pData->engine->getUniquePluginName(fDescriptor->name);
else
pData->name = pData->engine->getUniquePluginName(label);


+ 9
- 13
source/backend/plugin/VstPlugin.cpp View File

@@ -361,7 +361,7 @@ public:
}

// -------------------------------------------------------------------
// Set gui stuff
// Set ui stuff

void showCustomUI(const bool yesNo) override
{
@@ -2139,25 +2139,18 @@ protected:
public:
bool init(const char* const filename, const char* const name)
{
CARLA_ASSERT(pData->engine != nullptr);
CARLA_ASSERT(pData->client == nullptr);
CARLA_ASSERT(filename != nullptr);
CARLA_SAFE_ASSERT_RETURN(pData->engine != nullptr, false);

// ---------------------------------------------------------------
// first checks

if (pData->engine == nullptr)
{
return false;
}

if (pData->client != nullptr)
{
pData->engine->setLastError("Plugin client is already registered");
return false;
}

if (filename == nullptr)
if (filename == nullptr || filename[0] == '\0')
{
pData->engine->setLastError("null filename");
return false;
@@ -2218,7 +2211,7 @@ public:
// ---------------------------------------------------------------
// get info

if (name != nullptr)
if (name != nullptr && name[0] != '\0')
{
pData->name = pData->engine->getUniquePluginName(name);
}
@@ -2231,10 +2224,13 @@ public:
{
pData->name = pData->engine->getUniquePluginName(strBuf);
}
else if (const char* const shortname = std::strrchr(filename, OS_SEP))
{
pData->name = pData->engine->getUniquePluginName(shortname+1);
}
else
{
const char* const label = std::strrchr(filename, OS_SEP)+1;
pData->name = pData->engine->getUniquePluginName(label);
pData->name = pData->engine->getUniquePluginName("unknown");
}
}



Loading…
Cancel
Save