1 |
/* |
/* |
2 |
* Copyright (C) 2007, 2008 Andreas Persson |
* Copyright (C) 2007 - 2015 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
20 |
#include "linuxsamplerplugin.h" |
#include "linuxsamplerplugin.h" |
21 |
|
|
22 |
#include <linuxsampler/plugins/InstrumentEditorFactory.h> |
#include <linuxsampler/plugins/InstrumentEditorFactory.h> |
23 |
|
#include <linuxsampler/engines/Engine.h> |
24 |
|
#include <linuxsampler/engines/EngineChannel.h> |
25 |
#include "../gigedit/gigedit.h" |
#include "../gigedit/gigedit.h" |
26 |
#include "../gigedit/global.h" |
#include "../gigedit/global.h" |
27 |
|
|
121 |
app->signal_keyboard_key_released().connect( |
app->signal_keyboard_key_released().connect( |
122 |
sigc::mem_fun(*this, &LinuxSamplerPlugin::__onVirtualKeyboardKeyReleased) |
sigc::mem_fun(*this, &LinuxSamplerPlugin::__onVirtualKeyboardKeyReleased) |
123 |
); |
); |
124 |
|
app->signal_switch_sampler_instrument().connect( |
125 |
|
sigc::mem_fun(*this, &LinuxSamplerPlugin::__requestSamplerToSwitchInstrument) |
126 |
|
); |
127 |
|
|
128 |
// register a timeout job to gigedit's main loop, so we can poll the |
// register a timeout job to gigedit's main loop, so we can poll the |
129 |
// the sampler periodically for MIDI events (I HOPE it works on all |
// the sampler periodically for MIDI events (I HOPE it works on all |
178 |
#endif |
#endif |
179 |
} |
} |
180 |
|
|
181 |
|
void LinuxSamplerPlugin::__requestSamplerToSwitchInstrument(gig::Instrument* pInstrument) { |
182 |
|
if (!pInstrument) return; |
183 |
|
|
184 |
|
LinuxSampler::EngineChannel* pEngineChannel = GetEngineChannel(); |
185 |
|
if (!pEngineChannel) return; |
186 |
|
|
187 |
|
LinuxSampler::Engine* pEngine = pEngineChannel->GetEngine(); |
188 |
|
if (!pEngine) return; |
189 |
|
|
190 |
|
LinuxSampler::InstrumentManager* pInstrumentManager = pEngine->GetInstrumentManager(); |
191 |
|
if (!pInstrumentManager) return; |
192 |
|
|
193 |
|
gig::File* pFile = (gig::File*) pInstrument->GetParent(); |
194 |
|
|
195 |
|
// resolve instrument's index number in its gig file |
196 |
|
int index = -1; |
197 |
|
for (int i = 0; pFile->GetInstrument(i); ++i) { |
198 |
|
if (pFile->GetInstrument(i) == pInstrument) { |
199 |
|
index = i; |
200 |
|
break; |
201 |
|
} |
202 |
|
} |
203 |
|
if (index < 0) return; |
204 |
|
|
205 |
|
LinuxSampler::InstrumentManager::instrument_id_t id; |
206 |
|
id.FileName = pFile->GetFileName(); |
207 |
|
id.Index = index; |
208 |
|
pInstrumentManager->LoadInstrumentInBackground(id, pEngineChannel); |
209 |
|
} |
210 |
|
|
211 |
bool LinuxSamplerPlugin::IsTypeSupported(String sTypeName, String sTypeVersion) { |
bool LinuxSamplerPlugin::IsTypeSupported(String sTypeName, String sTypeVersion) { |
212 |
return sTypeName == gig::libraryName() && |
return sTypeName == gig::libraryName() && |
213 |
sTypeVersion == gig::libraryVersion(); |
sTypeVersion == gig::libraryVersion(); |