913 |
} |
} |
914 |
|
|
915 |
/** |
/** |
916 |
|
* Modifies the key range of this Region and makes sure the respective |
917 |
|
* chunks are in correct order. |
918 |
|
* |
919 |
|
* @param Low - lower end of key range |
920 |
|
* @param High - upper end of key range |
921 |
|
*/ |
922 |
|
void Region::SetKeyRange(uint16_t Low, uint16_t High) { |
923 |
|
KeyRange.low = Low; |
924 |
|
KeyRange.high = High; |
925 |
|
|
926 |
|
// make sure regions are already loaded |
927 |
|
Instrument* pInstrument = (Instrument*) GetParent(); |
928 |
|
if (!pInstrument->pRegions) pInstrument->LoadRegions(); |
929 |
|
if (!pInstrument->pRegions) return; |
930 |
|
|
931 |
|
// find the r which is the first one to the right of this region |
932 |
|
// at its new position |
933 |
|
Region* r = NULL; |
934 |
|
Region* prev_region = NULL; |
935 |
|
for ( |
936 |
|
Instrument::RegionList::iterator iter = pInstrument->pRegions->begin(); |
937 |
|
iter != pInstrument->pRegions->end(); iter++ |
938 |
|
) { |
939 |
|
if ((*iter)->KeyRange.low > this->KeyRange.low) { |
940 |
|
r = *iter; |
941 |
|
break; |
942 |
|
} |
943 |
|
prev_region = *iter; |
944 |
|
} |
945 |
|
|
946 |
|
// place this region before r if it's not already there |
947 |
|
if (prev_region != this) pInstrument->MoveRegion(this, r); |
948 |
|
} |
949 |
|
|
950 |
|
/** |
951 |
* Apply Region settings to the respective RIFF chunks. You have to |
* Apply Region settings to the respective RIFF chunks. You have to |
952 |
* call File::Save() to make changes persistent. |
* call File::Save() to make changes persistent. |
953 |
* |
* |