2152 |
if (file->pWavePoolTable) pDimensionRegions[i]->pSample = GetSampleFromWavePool(wavepoolindex); |
if (file->pWavePoolTable) pDimensionRegions[i]->pSample = GetSampleFromWavePool(wavepoolindex); |
2153 |
} |
} |
2154 |
GetSample(); // load global region sample reference |
GetSample(); // load global region sample reference |
2155 |
|
} else { |
2156 |
|
DimensionRegions = 0; |
2157 |
} |
} |
2158 |
|
|
2159 |
// make sure there is at least one dimension region |
// make sure there is at least one dimension region |
2176 |
* @throws gig::Exception if samples cannot be dereferenced |
* @throws gig::Exception if samples cannot be dereferenced |
2177 |
*/ |
*/ |
2178 |
void Region::UpdateChunks() { |
void Region::UpdateChunks() { |
2179 |
|
// in the gig format we don't care about the Region's sample reference |
2180 |
|
// but we still have to provide some existing one to not corrupt the |
2181 |
|
// file, so to avoid the latter we simply always assign the sample of |
2182 |
|
// the first dimension region of this region |
2183 |
|
pSample = pDimensionRegions[0]->pSample; |
2184 |
|
|
2185 |
// first update base class's chunks |
// first update base class's chunks |
2186 |
DLS::Region::UpdateChunks(); |
DLS::Region::UpdateChunks(); |
2187 |
|
|
2748 |
} |
} |
2749 |
|
|
2750 |
Group::~Group() { |
Group::~Group() { |
2751 |
|
// remove the chunk associated with this group (if any) |
2752 |
|
if (pNameChunk) pNameChunk->GetParent()->DeleteSubChunk(pNameChunk); |
2753 |
} |
} |
2754 |
|
|
2755 |
/** @brief Update chunks with current group settings. |
/** @brief Update chunks with current group settings. |
2756 |
* |
* |
2757 |
* Apply current Group field values to the respective. You have to call |
* Apply current Group field values to the respective chunks. You have |
2758 |
* File::Save() to make changes persistent. |
* to call File::Save() to make changes persistent. |
2759 |
|
* |
2760 |
|
* Usually there is absolutely no need to call this method explicitly. |
2761 |
|
* It will be called automatically when File::Save() was called. |
2762 |
*/ |
*/ |
2763 |
void Group::UpdateChunks() { |
void Group::UpdateChunks() { |
2764 |
// make sure <3gri> and <3gnl> list chunks exist |
// make sure <3gri> and <3gnl> list chunks exist |
2906 |
if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples"); |
if (!pSamples || !pSamples->size()) throw gig::Exception("Could not delete sample as there are no samples"); |
2907 |
SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample); |
SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), (DLS::Sample*) pSample); |
2908 |
if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample"); |
if (iter == pSamples->end()) throw gig::Exception("Could not delete sample, could not find given sample"); |
2909 |
|
if (SamplesIterator != pSamples->end() && *SamplesIterator == pSample) ++SamplesIterator; // avoid iterator invalidation |
2910 |
pSamples->erase(iter); |
pSamples->erase(iter); |
2911 |
delete pSample; |
delete pSample; |
2912 |
} |
} |
3043 |
* have to call Save() to make this persistent to the file. |
* have to call Save() to make this persistent to the file. |
3044 |
* |
* |
3045 |
* @param pInstrument - instrument to delete |
* @param pInstrument - instrument to delete |
3046 |
* @throws gig::Excption if given instrument could not be found |
* @throws gig::Exception if given instrument could not be found |
3047 |
*/ |
*/ |
3048 |
void File::DeleteInstrument(Instrument* pInstrument) { |
void File::DeleteInstrument(Instrument* pInstrument) { |
3049 |
if (!pInstruments) throw gig::Exception("Could not delete instrument as there are no instruments"); |
if (!pInstruments) throw gig::Exception("Could not delete instrument as there are no instruments"); |
3121 |
return pGroup; |
return pGroup; |
3122 |
} |
} |
3123 |
|
|
3124 |
|
/** @brief Delete a group and its samples. |
3125 |
|
* |
3126 |
|
* This will delete the given Group object and all the samples that |
3127 |
|
* belong to this group from the gig file. You have to call Save() to |
3128 |
|
* make this persistent to the file. |
3129 |
|
* |
3130 |
|
* @param pGroup - group to delete |
3131 |
|
* @throws gig::Exception if given group could not be found |
3132 |
|
*/ |
3133 |
void File::DeleteGroup(Group* pGroup) { |
void File::DeleteGroup(Group* pGroup) { |
3134 |
if (!pGroups) LoadGroups(); |
if (!pGroups) LoadGroups(); |
3135 |
std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup); |
std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup); |
3136 |
if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group"); |
if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group"); |
3137 |
if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!"); |
if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!"); |
3138 |
|
// delete all members of this group |
3139 |
|
for (Sample* pSample = pGroup->GetFirstSample(); pSample; pSample = pGroup->GetNextSample()) { |
3140 |
|
DeleteSample(pSample); |
3141 |
|
} |
3142 |
|
// now delete this group object |
3143 |
|
pGroups->erase(iter); |
3144 |
|
delete pGroup; |
3145 |
|
} |
3146 |
|
|
3147 |
|
/** @brief Delete a group. |
3148 |
|
* |
3149 |
|
* This will delete the given Group object from the gig file. All the |
3150 |
|
* samples that belong to this group will not be deleted, but instead |
3151 |
|
* be moved to another group. You have to call Save() to make this |
3152 |
|
* persistent to the file. |
3153 |
|
* |
3154 |
|
* @param pGroup - group to delete |
3155 |
|
* @throws gig::Exception if given group could not be found |
3156 |
|
*/ |
3157 |
|
void File::DeleteGroupOnly(Group* pGroup) { |
3158 |
|
if (!pGroups) LoadGroups(); |
3159 |
|
std::list<Group*>::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup); |
3160 |
|
if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group"); |
3161 |
|
if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!"); |
3162 |
// move all members of this group to another group |
// move all members of this group to another group |
3163 |
pGroup->MoveAll(); |
pGroup->MoveAll(); |
3164 |
pGroups->erase(iter); |
pGroups->erase(iter); |
3189 |
} |
} |
3190 |
} |
} |
3191 |
|
|
3192 |
|
/** |
3193 |
|
* Apply all the gig file's current instruments, samples, groups and settings |
3194 |
|
* to the respective RIFF chunks. You have to call Save() to make changes |
3195 |
|
* persistent. |
3196 |
|
* |
3197 |
|
* Usually there is absolutely no need to call this method explicitly. |
3198 |
|
* It will be called automatically when File::Save() was called. |
3199 |
|
* |
3200 |
|
* @throws Exception - on errors |
3201 |
|
*/ |
3202 |
|
void File::UpdateChunks() { |
3203 |
|
// first update base class's chunks |
3204 |
|
DLS::File::UpdateChunks(); |
3205 |
|
|
3206 |
|
// update group's chunks |
3207 |
|
if (pGroups) { |
3208 |
|
std::list<Group*>::iterator iter = pGroups->begin(); |
3209 |
|
std::list<Group*>::iterator end = pGroups->end(); |
3210 |
|
for (; iter != end; ++iter) { |
3211 |
|
(*iter)->UpdateChunks(); |
3212 |
|
} |
3213 |
|
} |
3214 |
|
} |
3215 |
|
|
3216 |
|
|
3217 |
|
|
3218 |
// *************** Exception *************** |
// *************** Exception *************** |