--- linuxsampler/trunk/src/engines/gig/EngineChannel.cpp 2011/10/01 08:23:02 2277 +++ linuxsampler/trunk/src/engines/gig/EngineChannel.cpp 2014/06/10 13:32:16 2612 @@ -4,7 +4,7 @@ * * * Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * * Copyright (C) 2005-2008 Christian Schoenebeck * - * Copyright (C) 2009-2011 Christian Schoenebeck and Grigor Iliev * + * Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -89,6 +89,10 @@ // keep the dimension regions and samples that are in use pInstrumentManager->HandBackInstrument(cmd.pInstrument, this, cmd.pRegionsInUse); } + if (cmd.pScript) { + // give old instrument script back to instrument resource manager + cmd.pScript->resetAll(); + } cmd.pRegionsInUse->clear(); // delete all key groups @@ -105,6 +109,15 @@ if (!newInstrument) { throw InstrumentManagerException("resource was not created"); } + + if (newInstrument->ScriptSlotCount() > 1) { + std::cerr << "WARNING: Executing more than one real-time instrument script slot is not implemented yet!\n"; + } + ::gig::Script* script = newInstrument->GetScriptOfSlot(0); + if (script) { + String sourceCode = script->GetScriptAsText(); + LoadInstrumentScript(sourceCode); + } } catch (RIFF::Exception e) { InstrumentStat = -2; @@ -144,7 +157,11 @@ InstrumentIdxName = newInstrument->pInfo->Name; InstrumentStat = 100; - ChangeInstrument(newInstrument); + cmd = ChangeInstrument(newInstrument); + if (cmd.pScript) { + // give old instrument script back to instrument resource manager + cmd.pScript->resetAll(); + } StatusChanged(true); } @@ -157,5 +174,18 @@ (pInstrument->DimensionKeyRange.high - pInstrument->DimensionKeyRange.low + 1); } } + + String EngineChannel::InstrumentFileName() { + return EngineChannelBase::InstrumentFileName(); + } + + String EngineChannel::InstrumentFileName(int index) { + if (index == 0) return InstrumentFileName(); + if (!pInstrument || !pInstrument->GetParent()) return ""; + DLS::File* pMainFile = dynamic_cast(pInstrument->GetParent()); + if (!pMainFile) return ""; + RIFF::File* pExtensionFile = pMainFile->GetExtensionFile(index); + return (pExtensionFile) ? pExtensionFile->GetFileName() : ""; + } }} // namespace LinuxSampler::gig