--- linuxsampler/trunk/src/engines/gig/EngineChannel.cpp 2009/10/23 17:53:17 2012 +++ linuxsampler/trunk/src/engines/gig/EngineChannel.cpp 2010/09/22 18:59:16 2127 @@ -3,8 +3,8 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005-2009 Christian Schoenebeck * - * Copyright (C) 2009 Grigor Iliev * + * Copyright (C) 2005-2008 Christian Schoenebeck * + * Copyright (C) 2009-2010 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 * @@ -36,8 +36,7 @@ // fully loaded, try to give back instrument again (see bug #113) InstrumentChangeCmd< ::gig::DimensionRegion, ::gig::Instrument>& cmd = ChangeInstrument(NULL); if (cmd.pInstrument) { - InstrumentResourceManager* instrs = dynamic_cast(pEngine->GetInstrumentManager()); - instrs->HandBack(cmd.pInstrument, this); + Engine::instruments.HandBack(cmd.pInstrument, this); } /////// } @@ -91,7 +90,7 @@ cmd.pRegionsInUse->clear(); // delete all key groups - ActiveKeyGroups.clear(); + DeleteGroupEventLists(); // request gig instrument from instrument manager ::gig::Instrument* newInstrument; @@ -123,9 +122,22 @@ throw Exception("gig::Engine error: Failed to load instrument, cause: Unknown exception while trying to parse gig file."); } - // rebuild ActiveKeyGroups map with key groups of current instrument - for (::gig::Region* pRegion = newInstrument->GetFirstRegion(); pRegion; pRegion = newInstrument->GetNextRegion()) - if (pRegion->KeyGroup) ActiveKeyGroups[pRegion->KeyGroup] = NULL; + RoundRobinIndex = 0; + for (int i = 0 ; i < 128 ; i++) pMIDIKeyInfo[i].pRoundRobinIndex = NULL; + + // rebuild ActiveKeyGroups map with key groups of current + // instrument and set the round robin pointers to use one + // counter for each region + int region = 0; + for (::gig::Region* pRegion = newInstrument->GetFirstRegion(); pRegion; pRegion = newInstrument->GetNextRegion()) { + AddGroup(pRegion->KeyGroup); + + RoundRobinIndexes[region] = 0; + for (int iKey = pRegion->KeyRange.low; iKey <= pRegion->KeyRange.high; iKey++) { + pMIDIKeyInfo[iKey].pRoundRobinIndex = &RoundRobinIndexes[region]; + } + region++; + } InstrumentIdxName = newInstrument->pInfo->Name; InstrumentStat = 100;