Browse Source

More LinuxSampler stuff; Try to handle jack shutdown better (TEST)

tags/1.9.4
falkTX 10 years ago
parent
commit
b2023a4cb3
5 changed files with 168 additions and 178 deletions
  1. +3
    -1
      source/backend/engine/CarlaEngine.cpp
  2. +8
    -0
      source/backend/engine/CarlaEngineInternal.cpp
  3. +1
    -0
      source/backend/engine/CarlaEngineInternal.hpp
  4. +32
    -24
      source/backend/engine/CarlaEngineJack.cpp
  5. +124
    -153
      source/backend/plugin/LinuxSamplerPlugin.cpp

+ 3
- 1
source/backend/engine/CarlaEngine.cpp View File

@@ -623,11 +623,13 @@ bool CarlaEngine::removeAllPlugins()

pData->thread.stopThread(500);

const uint32_t curPluginCount(pData->curPluginCount);

const ScopedActionLock sal(pData, kEnginePostActionZeroCount, 0, 0, isRunning());

callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr);

for (uint i=0; i < pData->maxPluginNumber; ++i)
for (uint i=0; i < curPluginCount; ++i)
{
EnginePluginData& pluginData(pData->plugins[i]);



+ 8
- 0
source/backend/engine/CarlaEngineInternal.cpp View File

@@ -79,6 +79,14 @@ void EngineNextAction::ready() const noexcept
waitEvent.reset();
}

void EngineNextAction::clearAndReset() noexcept
{
opcode = kEnginePostActionNull;
pluginId = 0;
value = 0;
waitEvent.reset();
}

// -----------------------------------------------------------------------
// CarlaEngine::ProtectedData



+ 1
- 0
source/backend/engine/CarlaEngineInternal.hpp View File

@@ -124,6 +124,7 @@ struct EngineNextAction {
EngineNextAction() noexcept;
~EngineNextAction() noexcept;
void ready() const noexcept;
void clearAndReset() noexcept;

CARLA_DECLARE_NON_COPY_STRUCT(EngineNextAction)
};


+ 32
- 24
source/backend/engine/CarlaEngineJack.cpp View File

@@ -1598,6 +1598,8 @@ protected:
}
}

pData->nextAction.waitEvent.reset();

#ifndef BUILD_BRIDGE
carla_fill<jack_port_t*>(fRackPorts, nullptr, kRackPortCount);
#endif
@@ -1608,6 +1610,23 @@ protected:

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

void handlePluginJackShutdownCallback(CarlaPlugin* const plugin)
{
CarlaEngineJackClient* const engineClient((CarlaEngineJackClient*)plugin->getEngineClient());
CARLA_SAFE_ASSERT_RETURN(engineClient != nullptr,);

plugin->tryLock(true);
engineClient->invalidate();
plugin->unlock();

if (pData->nextAction.pluginId == plugin->getId())
pData->nextAction.clearAndReset();

callback(ENGINE_CALLBACK_PLUGIN_UNAVAILABLE, plugin->getId(), 0, 0, 0.0f, "Killed by JACK");
}

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

private:
jack_client_t* fClient;
jack_position_t fTransportPos;
@@ -1980,19 +1999,17 @@ private:
static int carla_jack_process_callback_plugin(jack_nframes_t nframes, void* arg)
{
CarlaPlugin* const plugin((CarlaPlugin*)arg);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr && plugin->isEnabled(), 0);

if (plugin != nullptr && plugin->isEnabled())
{
CarlaEngineJack* const engine((CarlaEngineJack*)plugin->getEngine());
CARLA_SAFE_ASSERT_RETURN(engine != nullptr,0);
CarlaEngineJack* const engine((CarlaEngineJack*)plugin->getEngine());
CARLA_SAFE_ASSERT_RETURN(engine != nullptr, 0);

if (plugin->tryLock(engine->fFreewheel))
{
plugin->initBuffers();
engine->saveTransportInfo();
engine->processPlugin(plugin, nframes);
plugin->unlock();
}
if (plugin->tryLock(engine->fFreewheel))
{
plugin->initBuffers();
engine->saveTransportInfo();
engine->processPlugin(plugin, nframes);
plugin->unlock();
}

return 0;
@@ -2006,21 +2023,12 @@ private:
static void carla_jack_shutdown_callback_plugin(void* arg)
{
CarlaPlugin* const plugin((CarlaPlugin*)arg);
CARLA_SAFE_ASSERT_RETURN(plugin != nullptr,);

if (plugin != nullptr /*&& plugin->isEnabled()*/)
{
CarlaEngine* const engine(plugin->getEngine());
CARLA_SAFE_ASSERT_RETURN(engine != nullptr,);

CarlaEngineJackClient* const engineClient((CarlaEngineJackClient*)plugin->getEngineClient());
CARLA_SAFE_ASSERT_RETURN(engineClient != nullptr,);
CarlaEngineJack* const engine((CarlaEngineJack*)plugin->getEngine());
CARLA_SAFE_ASSERT_RETURN(engine != nullptr,);

plugin->tryLock(true);
engineClient->invalidate();
plugin->unlock();

engine->callback(ENGINE_CALLBACK_PLUGIN_UNAVAILABLE, plugin->getId(), 0, 0, 0.0f, "Killed by JACK");
}
engine->handlePluginJackShutdownCallback(plugin);
}
#endif



+ 124
- 153
source/backend/plugin/LinuxSamplerPlugin.cpp View File

@@ -153,17 +153,17 @@ public:
return new MidiInputPortPlugin(this, int(Ports.size()));
}

void DeleteMidiPort(MidiInputPort* const port)
{
delete (MidiInputPortPlugin*)port;
}

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

bool isAutonomousDevice() override { return false; }
static bool isAutonomousDriver() { return false; }

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

MidiInputPortPlugin* CreateMidiPortPlugin()
{
return new MidiInputPortPlugin(this, int(Ports.size()));
}
};

// -----------------------------------------------------------------------
@@ -175,10 +175,7 @@ struct SamplerPlugin {

SamplerPlugin()
: sampler(),
midiIn(&sampler)
{
carla_stderr2("SamplerPlugin created");
}
midiIn(&sampler) {}
};

} // namespace LinuxSampler
@@ -205,14 +202,13 @@ public:
fMaker(nullptr),
fRealName(nullptr),
fAudioOutputDevice(nullptr),
//fMidiInputDevice(nullptr),
fMidiInputPort(nullptr)//,
//fInstrument(nullptr)
fMidiInputPort(nullptr),
fInstrument(nullptr)
{
carla_debug("LinuxSamplerPlugin::LinuxSamplerPlugin(%p, %i, %s, %s)", engine, id, bool2str(isGIG), bool2str(use16Outs));

carla_zeroStruct(fCurMidiProgs, MAX_MIDI_CHANNELS);
//carla_zeroStruct(fEngineChannels, MAX_MIDI_CHANNELS);
carla_zeroStruct(fCurProgs, MAX_MIDI_CHANNELS);
carla_zeroStruct(fEngineChannels, MAX_MIDI_CHANNELS);
carla_zeroStruct(fSamplerChannels, MAX_MIDI_CHANNELS);

if (use16Outs && ! isGIG)
@@ -235,40 +231,30 @@ public:
pData->active = false;
}

//if (fMidiInputDevice != nullptr)
if (fMidiInputPort != nullptr)
{
if (fMidiInputPort != nullptr)
for (uint i=0; i<kMaxChannels; ++i)
{
for (uint i=0; i<kMaxChannels; ++i)
if (fSamplerChannels[i] != nullptr)
{
if (fSamplerChannels[i] != nullptr)
if (fEngineChannels[i] != nullptr)
{
//if (fEngineChannels[i] != nullptr)
{
fMidiInputPort->Disconnect(fSamplerChannels[i]->GetEngineChannel());
//fMidiInputPort->Disconnect(fEngineChannels[i]);
//fEngineChannels[i]->DisconnectAudioOutputDevice();
//fEngineChannels[i] = nullptr;
}

sSampler->sampler.RemoveSamplerChannel(fSamplerChannels[i]);
fSamplerChannels[i] = nullptr;
fMidiInputPort->Disconnect(fEngineChannels[i]);
fEngineChannels[i]->DisconnectAudioOutputDevice();
fEngineChannels[i] = nullptr;
}
}

sSampler->midiIn.DeleteMidiPort(fMidiInputPort);
//delete fMidiInputPort;
fMidiInputPort = nullptr;
sSampler->sampler.RemoveSamplerChannel(fSamplerChannels[i]);
fSamplerChannels[i] = nullptr;
}
}

//sSampler->DestroyMidiInputDevice(fMidiInputDevice);
//delete fMidiInputDevice;
//fMidiInputDevice = nullptr;
delete fMidiInputPort;
fMidiInputPort = nullptr;
}

if (fAudioOutputDevice != nullptr)
{
//sSampler->DestroyAudioOutputDevice(fAudioOutputDevice);
delete fAudioOutputDevice;
fAudioOutputDevice = nullptr;
}
@@ -382,12 +368,12 @@ public:
if (kMaxChannels > 1 && fInstrumentIds.size() > 1)
{
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],
fCurMidiProgs[8], fCurMidiProgs[9], fCurMidiProgs[10], fCurMidiProgs[11],
fCurMidiProgs[12], fCurMidiProgs[13], fCurMidiProgs[14], fCurMidiProgs[15]);
std::snprintf(strBuf, STR_MAX, "%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i:%i", fCurProgs[0], fCurProgs[1], fCurProgs[2], fCurProgs[3],
fCurProgs[4], fCurProgs[5], fCurProgs[6], fCurProgs[7],
fCurProgs[8], fCurProgs[9], fCurProgs[10], fCurProgs[11],
fCurProgs[12], fCurProgs[13], fCurProgs[14], fCurProgs[15]);

CarlaPlugin::setCustomData(CUSTOM_DATA_TYPE_STRING, "midiPrograms", strBuf, false);
CarlaPlugin::setCustomData(CUSTOM_DATA_TYPE_STRING, "programs", strBuf, false);
}
}

@@ -397,7 +383,7 @@ public:
void setCtrlChannel(const int8_t channel, const bool sendOsc, const bool sendCallback) noexcept override
{
if (channel >= 0 && channel < MAX_MIDI_CHANNELS)
pData->midiprog.current = fCurMidiProgs[channel];
pData->prog.current = fCurProgs[channel];

CarlaPlugin::setCtrlChannel(channel, sendOsc, sendCallback);
}
@@ -415,46 +401,50 @@ public:
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));

if (std::strcmp(key, "midiPrograms") != 0)
if (std::strcmp(key, "programs") != 0)
return carla_stderr2("LinuxSamplerPlugin::setCustomData(\"%s\", \"%s\", \"%s\", %s) - type is not string", type, key, value, bool2str(sendGui));

if (kMaxChannels > 1 && fInstrumentIds.size() > 1)
{
StringArray midiProgramList(StringArray::fromTokens(value, ":", ""));
StringArray programList(StringArray::fromTokens(value, ":", ""));

if (midiProgramList.size() == MAX_MIDI_CHANNELS)
if (programList.size() == MAX_MIDI_CHANNELS)
{
uint8_t channel = 0;
for (juce::String *it=midiProgramList.begin(), *end=midiProgramList.end(); it != end; ++it)
for (juce::String *it=programList.begin(), *end=programList.end(); it != end; ++it)
{
const int index(it->getIntValue());

if (index >= 0 && index < static_cast<int>(pData->midiprog.count))
if (index >= 0 && index < static_cast<int>(pData->prog.count))
{
const uint32_t bank = pData->midiprog.data[index].bank;
const uint32_t program = pData->midiprog.data[index].program;
const uint32_t rIndex = bank*128 + program;
LinuxSampler::EngineChannel* const engineChannel(fEngineChannels[channel]);
CARLA_SAFE_ASSERT_CONTINUE(engineChannel != nullptr);

/*if (pData->engine->isOffline())
if (pData->engine->isOffline())
{
fEngineChannels[channel]->PrepareLoadInstrument(pData->filename, rIndex);
fEngineChannels[channel]->LoadInstrument();
try {
engineChannel->PrepareLoadInstrument(pData->filename, index);
engineChannel->LoadInstrument();
} CARLA_SAFE_EXCEPTION("LoadInstrument");
}
else*/
else
{
fInstrument->LoadInstrumentInBackground(fInstrumentIds[rIndex], fEngineChannels[channel]);
try {
fInstrument->LoadInstrumentInBackground(fInstrumentIds[index], engineChannel);
} CARLA_SAFE_EXCEPTION("LoadInstrumentInBackground");
}

fCurMidiProgs[channel] = index;
fCurProgs[channel] = index;

if (pData->ctrlChannel == static_cast<int32_t>(channel))
{
pData->midiprog.current = index;
pData->engine->callback(ENGINE_CALLBACK_MIDI_PROGRAM_CHANGED, pData->id, index, 0, 0.0f, nullptr);
pData->prog.current = index;
pData->engine->callback(ENGINE_CALLBACK_PROGRAM_CHANGED, pData->id, index, 0, 0.0f, nullptr);
}
}

++channel;
if (++channel >= MAX_MIDI_CHANNELS)
break;
}
CARLA_SAFE_ASSERT(channel == MAX_MIDI_CHANNELS);
}
@@ -463,39 +453,37 @@ public:
CarlaPlugin::setCustomData(type, key, value, sendGui);
}

void setMidiProgram(const int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) noexcept override
void setProgram(const int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback) noexcept override
{
CARLA_SAFE_ASSERT_RETURN(index >= -1 && index < static_cast<int32_t>(pData->midiprog.count),);
CARLA_SAFE_ASSERT_RETURN(index >= -1 && index < static_cast<int32_t>(pData->prog.count),);

const int8_t channel(kIsGIG ? pData->ctrlChannel : 0);

if (index >= 0 && channel >= 0 && channel < MAX_MIDI_CHANNELS)
{
const uint32_t bank = pData->midiprog.data[index].bank;
const uint32_t program = pData->midiprog.data[index].program;
const uint32_t rIndex = bank*128 + program;

LinuxSampler::EngineChannel* const engineChannel(fEngineChannels[channel]);
CARLA_SAFE_ASSERT_RETURN(engineChannel != nullptr,);

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

/*if (pData->engine->isOffline())
if (pData->engine->isOffline())
{
engineChannel->PrepareLoadInstrument(pData->filename, rIndex);
engineChannel->LoadInstrument();
try {
engineChannel->PrepareLoadInstrument(pData->filename, index);
engineChannel->LoadInstrument();
} CARLA_SAFE_EXCEPTION("LoadInstrument");
}
else*/
else
{
try {
fInstrument->LoadInstrumentInBackground(fInstrumentIds[rIndex], engineChannel);
} CARLA_SAFE_EXCEPTION("LinuxSampler setMidiProgram loadInstrument");
fInstrument->LoadInstrumentInBackground(fInstrumentIds[index], engineChannel);
} CARLA_SAFE_EXCEPTION("LoadInstrumentInBackground");
}

fCurMidiProgs[channel] = index;
fCurProgs[channel] = index;
}

CarlaPlugin::setMidiProgram(index, sendGui, sendOsc, sendCallback);
CarlaPlugin::setProgram(index, sendGui, sendOsc, sendCallback);
}

// -------------------------------------------------------------------
@@ -648,7 +636,7 @@ public:
carla_debug("LinuxSamplerPlugin::reloadPrograms(%s)", bool2str(doInit));

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

// Query new programs
const uint32_t count(static_cast<uint32_t>(fInstrumentIds.size()));
@@ -656,35 +644,24 @@ public:
// sound kits must always have at least 1 midi-program
CARLA_SAFE_ASSERT_RETURN(count > 0,);

pData->midiprog.createNew(count);
pData->prog.createNew(count);

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

for (uint32_t i=0; i < pData->midiprog.count; ++i)
for (uint32_t i=0; i < pData->prog.count; ++i)
{
pData->midiprog.data[i].bank = i / 128;
pData->midiprog.data[i].program = i % 128;

try {
info = fInstrument->GetInstrumentInfo(fInstrumentIds[i]);
}
catch (const LinuxSampler::InstrumentManagerException&)
{
continue;
}

pData->midiprog.data[i].name = carla_strdup(info.InstrumentName.c_str());
pData->prog.names[i] = carla_strdup(fInstrument->GetInstrumentName(fInstrumentIds[i]).c_str());
} CARLA_SAFE_EXCEPTION_CONTINUE("GetInstrumentInfo");
}

#ifndef BUILD_BRIDGE
// Update OSC Names
if (pData->engine->isOscControlRegistered())
{
pData->engine->oscSend_control_set_midi_program_count(pData->id, count);
pData->engine->oscSend_control_set_program_count(pData->id, count);

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);
pData->engine->oscSend_control_set_program_name(pData->id, i, pData->prog.names[i]);
}
#endif

@@ -694,13 +671,14 @@ public:
{
CARLA_SAFE_ASSERT_CONTINUE(fEngineChannels[i] != nullptr);

/*fEngineChannels[i]->PrepareLoadInstrument(pData->filename, 0);
fEngineChannels[i]->LoadInstrument();*/
fInstrument->LoadInstrumentInBackground(fInstrumentIds[0], fEngineChannels[i]);
fCurMidiProgs[i] = 0;
try {
fInstrument->LoadInstrumentInBackground(fInstrumentIds[0], fEngineChannels[i]);
} CARLA_SAFE_EXCEPTION("LoadInstrumentInBackground");

fCurProgs[i] = 0;
}

pData->midiprog.current = 0;
pData->prog.current = 0;
}
else
{
@@ -804,11 +782,6 @@ public:
uint32_t startTime = 0;
uint32_t timeOffset = 0;

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 (uint32_t i=0; i < nEvents; ++i)
{
const EngineEvent& event(pData->event.portIn->getEvent(i));
@@ -822,9 +795,6 @@ public:
{
startTime = 0;
timeOffset = event.time;

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;
@@ -934,42 +904,35 @@ public:
}

case kEngineControlEventTypeMidiBank:
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 < MAX_MIDI_CHANNELS && (pData->options & PLUGIN_OPTION_MAP_PROGRAM_CHANGES) != 0)
{
const uint32_t bankId(nextBankIds[event.channel]);
const uint32_t progId(ctrlEvent.param);
const uint32_t rIndex = bankId*128 + progId;
const uint32_t programId(ctrlEvent.param);
CARLA_SAFE_ASSERT_CONTINUE(programId < fInstrumentIds.size());

for (uint32_t k=0; k < pData->midiprog.count; ++k)
{
if (pData->midiprog.data[k].bank == bankId && pData->midiprog.data[k].program == progId)
{
LinuxSampler::EngineChannel* const engineChannel(fEngineChannels[kIsGIG ? event.channel : 0]);
CARLA_SAFE_ASSERT_CONTINUE(engineChannel != nullptr);

/*if (pData->engine->isOffline())
{
engineChannel->PrepareLoadInstrument(pData->filename, rIndex);
engineChannel->LoadInstrument();
}
else*/
{
fInstrument->LoadInstrumentInBackground(fInstrumentIds[rIndex], engineChannel);
}
LinuxSampler::EngineChannel* const engineChannel(fEngineChannels[kIsGIG ? event.channel : 0]);
CARLA_SAFE_ASSERT_CONTINUE(engineChannel != nullptr);

fCurMidiProgs[event.channel] = static_cast<int32_t>(k);
if (pData->engine->isOffline())
{
try {
engineChannel->PrepareLoadInstrument(pData->filename, programId);
engineChannel->LoadInstrument();
} CARLA_SAFE_EXCEPTION("LoadInstrument");
}
else
{
try {
fInstrument->LoadInstrumentInBackground(fInstrumentIds[programId], engineChannel);
} CARLA_SAFE_EXCEPTION("LoadInstrumentInBackground");
}

if (event.channel == pData->ctrlChannel)
pData->postponeRtEvent(kPluginPostRtEventMidiProgramChange, static_cast<int32_t>(k), 0, 0.0f);
fCurProgs[event.channel] = static_cast<int32_t>(programId);

break;
}
}
if (pData->ctrlChannel == event.channel)
pData->postponeRtEvent(kPluginPostRtEventProgramChange, static_cast<int32_t>(programId), 0, 0.0f);
}
break;

@@ -1187,7 +1150,7 @@ public:
// Init LinuxSampler stuff

fAudioOutputDevice = new LinuxSampler::AudioOutputDevicePlugin(pData->engine, this, kUses16Outs);
fMidiInputPort = sSampler->midiIn.CreateMidiPort();
fMidiInputPort = sSampler->midiIn.CreateMidiPortPlugin();

for (uint i=0; i<kMaxChannels; ++i)
{
@@ -1197,32 +1160,42 @@ public:
fSamplerChannels[i]->SetEngineType(kIsGIG ? "GIG" : "SFZ");
fSamplerChannels[i]->SetAudioOutputDevice(fAudioOutputDevice);

//fEngineChannels[i] = fSamplerChannels[i]->GetEngineChannel();
//CARLA_SAFE_ASSERT_CONTINUE(fEngineChannels[i] != nullptr);
fEngineChannels[i] = fSamplerChannels[i]->GetEngineChannel();
CARLA_SAFE_ASSERT_CONTINUE(fEngineChannels[i] != nullptr);

//fEngineChannels[i]->Connect(fAudioOutputDevice);
//fEngineChannels[i]->Volume(LinuxSampler::kVolumeMax);
fEngineChannels[i]->Connect(fAudioOutputDevice); // FIXME
fEngineChannels[i]->Pan(0.0f);
fEngineChannels[i]->Volume(LinuxSampler::kVolumeMax);

//if (kUses16Outs)
if (kUses16Outs)
{
//fEngineChannels[i]->SetOutputChannel(0, i*2);
//fEngineChannels[i]->SetOutputChannel(1, i*2 +1);
//fMidiInputPort->Connect(fSamplerChannels[i]->GetEngineChannel(), static_cast<LinuxSampler::midi_chan_t>(i));
fEngineChannels[i]->SetOutputChannel(0, i*2);
fEngineChannels[i]->SetOutputChannel(1, i*2 +1);
fMidiInputPort->Connect(fEngineChannels[i], static_cast<LinuxSampler::midi_chan_t>(i));
}
//else
else
{
//fEngineChannels[i]->SetOutputChannel(0, 0);
//fEngineChannels[i]->SetOutputChannel(1, 1);
fMidiInputPort->Connect(fSamplerChannels[i]->GetEngineChannel(), LinuxSampler::midi_chan_all);
fEngineChannels[i]->SetOutputChannel(0, 0);
fEngineChannels[i]->SetOutputChannel(1, 1);
fMidiInputPort->Connect(fEngineChannels[i], LinuxSampler::midi_chan_all);
}
}

// ---------------------------------------------------------------
// Get Engine

LinuxSampler::Engine* const engine(fEngineChannels[0]->GetEngine());

//fMidiInputPort->Connect(fEngineChannels[i], static_cast<LinuxSampler::midi_chan_t>(i));
if (engine == nullptr)
{
pData->engine->setLastError("Failed to get LinuxSampler instrument manager");
return false;
}

// ---------------------------------------------------------------
// Get the Engine's Instrument Manager

fInstrument = kIsGIG ? sEngineGIG->engine->GetInstrumentManager() : sEngineSFZ->engine->GetInstrumentManager();
fInstrument = engine->GetInstrumentManager();

if (fInstrument == nullptr)
{
@@ -1314,18 +1287,16 @@ private:
const char* fMaker;
const char* fRealName;

int32_t fCurMidiProgs[MAX_MIDI_CHANNELS];
int32_t fCurProgs[MAX_MIDI_CHANNELS];

LinuxSampler::SamplerChannel* fSamplerChannels[MAX_MIDI_CHANNELS];
//LinuxSampler::EngineChannel* fEngineChannels[MAX_MIDI_CHANNELS];
LinuxSampler::EngineChannel* fEngineChannels[MAX_MIDI_CHANNELS];

LinuxSampler::AudioOutputDevicePlugin* fAudioOutputDevice;
LinuxSampler::MidiInputPort* fMidiInputPort;

//LinuxSampler::MidiInputDevicePlugin* fMidiInputDevice;
LinuxSampler::MidiInputPortPlugin* fMidiInputPort;

//LinuxSampler::InstrumentManager* fInstrument;
//std::vector<LinuxSampler::InstrumentManager::instrument_id_t> fInstrumentIds;
LinuxSampler::InstrumentManager* fInstrument;
std::vector<LinuxSampler::InstrumentManager::instrument_id_t> fInstrumentIds;

SharedResourcePointer<LinuxSampler::SamplerPlugin> sSampler;



Loading…
Cancel
Save