28 |
|
|
29 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
30 |
EngineChannel::EngineChannel() { |
EngineChannel::EngineChannel() { |
31 |
|
CurrentGigScript = NULL; |
32 |
} |
} |
33 |
|
|
34 |
EngineChannel::~EngineChannel() { |
EngineChannel::~EngineChannel() { |
84 |
|
|
85 |
// make sure we don't trigger any new notes with an old |
// make sure we don't trigger any new notes with an old |
86 |
// instrument |
// instrument |
87 |
InstrumentChangeCmd< ::gig::DimensionRegion, ::gig::Instrument>& cmd = ChangeInstrument(0); |
InstrumentChangeCmd< ::gig::DimensionRegion, ::gig::Instrument>& cmd = ChangeInstrument(NULL); |
88 |
if (cmd.pInstrument) { |
if (cmd.pInstrument) { |
89 |
// give old instrument back to instrument manager, but |
// give old instrument back to instrument manager, but |
90 |
// keep the dimension regions and samples that are in use |
// keep the dimension regions and samples that are in use |
93 |
if (cmd.pScript) { |
if (cmd.pScript) { |
94 |
// give old instrument script back to instrument resource manager |
// give old instrument script back to instrument resource manager |
95 |
cmd.pScript->resetAll(); |
cmd.pScript->resetAll(); |
96 |
|
CurrentGigScript = NULL; |
97 |
} |
} |
98 |
cmd.pRegionsInUse->clear(); |
cmd.pRegionsInUse->clear(); |
99 |
|
|
120 |
String sourceCode = script->GetScriptAsText(); |
String sourceCode = script->GetScriptAsText(); |
121 |
LoadInstrumentScript(sourceCode); |
LoadInstrumentScript(sourceCode); |
122 |
} |
} |
123 |
|
CurrentGigScript = script; |
124 |
} |
} |
125 |
catch (RIFF::Exception e) { |
catch (RIFF::Exception e) { |
126 |
InstrumentStat = -2; |
InstrumentStat = -2; |
172 |
StatusChanged(true); |
StatusChanged(true); |
173 |
} |
} |
174 |
|
|
175 |
|
/** |
176 |
|
* Called by instrument editor API to inform this engine channel that the |
177 |
|
* passed @a script has been modified by the instrument editor and that |
178 |
|
* this engine channel should thus reload the instrument script (that is |
179 |
|
* that it should re-parse the scripts new source code). |
180 |
|
*/ |
181 |
|
void EngineChannel::reloadScript(::gig::Script* script) { |
182 |
|
dmsg(3,("gig::EngineChannel::realoadScript()\n")); |
183 |
|
// make sure this engine channel is actually using the requested |
184 |
|
// modified gig::Script object (because the internal script resource |
185 |
|
// manager will i.e. provide the same VM object for different |
186 |
|
// ::gig::Script objects with same source code though. |
187 |
|
if (!script || CurrentGigScript != script) return; |
188 |
|
|
189 |
|
//TODO: reloading the entire instrument is currently a very lazy (and slow) solution just for reloading the instrument script |
190 |
|
try { |
191 |
|
LoadInstrument(); |
192 |
|
} catch (Exception e) { |
193 |
|
std::cerr << e.Message() << std::endl; |
194 |
|
} catch (...) { |
195 |
|
String msg = "gig::Engine error: Failed to reload instrument script, cause: Unknown exception while trying to reload gig file."; |
196 |
|
std::cerr << msg << std::endl; |
197 |
|
} |
198 |
|
} |
199 |
|
|
200 |
void EngineChannel::ProcessKeySwitchChange(int key) { |
void EngineChannel::ProcessKeySwitchChange(int key) { |
201 |
// Change key dimension value if key is in keyswitching area |
// Change key dimension value if key is in keyswitching area |
202 |
{ |
{ |