2 |
* * |
* * |
3 |
* libgig - C++ cross-platform Gigasampler format file access library * |
* libgig - C++ cross-platform Gigasampler format file access library * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003-2014 by Christian Schoenebeck * |
* Copyright (C) 2003-2015 by Christian Schoenebeck * |
6 |
* <cuse@users.sourceforge.net> * |
* <cuse@users.sourceforge.net> * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
4636 |
} |
} |
4637 |
|
|
4638 |
/** |
/** |
4639 |
|
* Move this instrument at the position before @arg dst. |
4640 |
|
* |
4641 |
|
* This method can be used to reorder the sequence of instruments in a |
4642 |
|
* .gig file. This might be helpful especially on large .gig files which |
4643 |
|
* contain a large number of instruments within the same .gig file. So |
4644 |
|
* grouping such instruments to similar ones, can help to keep track of them |
4645 |
|
* when working with such complex .gig files. |
4646 |
|
* |
4647 |
|
* When calling this method, this instrument will be removed from in its |
4648 |
|
* current position in the instruments list and moved to the requested |
4649 |
|
* target position provided by @param dst. You may also pass NULL as |
4650 |
|
* argument to this method, in that case this intrument will be moved to the |
4651 |
|
* very end of the .gig file's instrument list. |
4652 |
|
* |
4653 |
|
* You have to call Save() to make the order change persistent to the .gig |
4654 |
|
* file. |
4655 |
|
* |
4656 |
|
* Currently this method is limited to moving the instrument within the same |
4657 |
|
* .gig file. Trying to move it to another .gig file by calling this method |
4658 |
|
* will throw an exception. |
4659 |
|
* |
4660 |
|
* @param dst - destination instrument at which this instrument will be |
4661 |
|
* moved to, or pass NULL for moving to end of list |
4662 |
|
* @throw gig::Exception if this instrument and target instrument are not |
4663 |
|
* part of the same file |
4664 |
|
*/ |
4665 |
|
void Instrument::MoveTo(Instrument* dst) { |
4666 |
|
if (dst && GetParent() != dst->GetParent()) |
4667 |
|
throw Exception( |
4668 |
|
"gig::Instrument::MoveTo() can only be used for moving within " |
4669 |
|
"the same gig file." |
4670 |
|
); |
4671 |
|
|
4672 |
|
File* pFile = (File*) GetParent(); |
4673 |
|
|
4674 |
|
// move this instrument within the instrument list |
4675 |
|
{ |
4676 |
|
DLS::File::InstrumentList& list = *pFile->pInstruments; |
4677 |
|
|
4678 |
|
DLS::File::InstrumentList::iterator itFrom = |
4679 |
|
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(this)); |
4680 |
|
|
4681 |
|
DLS::File::InstrumentList::iterator itTo = |
4682 |
|
std::find(list.begin(), list.end(), static_cast<DLS::Instrument*>(dst)); |
4683 |
|
|
4684 |
|
list.splice(itTo, list, itFrom); |
4685 |
|
} |
4686 |
|
|
4687 |
|
// move the instrument's actual list RIFF chunk appropriately |
4688 |
|
RIFF::List* lstCkInstruments = pFile->pRIFF->GetSubList(LIST_TYPE_LINS); |
4689 |
|
lstCkInstruments->MoveSubChunk( |
4690 |
|
this->pCkInstrument, |
4691 |
|
(dst) ? dst->pCkInstrument : NULL |
4692 |
|
); |
4693 |
|
} |
4694 |
|
|
4695 |
|
/** |
4696 |
* Returns a MIDI rule of the instrument. |
* Returns a MIDI rule of the instrument. |
4697 |
* |
* |
4698 |
* The list of MIDI rules, at least in gig v3, always contains at |
* The list of MIDI rules, at least in gig v3, always contains at |