--- libgig/trunk/src/SF.cpp 2010/05/26 11:56:42 2099 +++ libgig/trunk/src/SF.cpp 2010/05/30 11:39:36 2100 @@ -21,8 +21,6 @@ * MA 02111-1307 USA * ***************************************************************************/ -#include - #include "RIFF.h" #include "SF.h" @@ -659,19 +657,19 @@ return regions[idx]; } - std::vector InstrumentBase::GetRegionsOnKey(int key, uint8_t vel) { - std::vector v; - for (int i = 0; i < GetRegionCount(); i++) { - Region* r = GetRegion(i); - if ( - ((r->loKey == NONE && r->hiKey == NONE) || (key >= r->loKey && key <= r->hiKey)) && - ((r->minVel == NONE && r->maxVel == NONE) || (vel >= r->minVel && vel <= r->maxVel)) - ) { - v.push_back(r); + Query::Query(InstrumentBase& instrument) : instrument(instrument) { + i = 0; + } + + Region* Query::next() { + while (i < instrument.GetRegionCount()) { + Region* r = instrument.GetRegion(i++); + if (((r->loKey == NONE && r->hiKey == NONE) || (key >= r->loKey && key <= r->hiKey)) && + ((r->minVel == NONE && r->maxVel == NONE) || (vel >= r->minVel && vel <= r->maxVel))) { + return r; } } - - return v; + return 0; } Instrument::Instrument(sf2::File* pFile, RIFF::Chunk* ck) : InstrumentBase(pFile) {