4801 |
|
|
4802 |
ScriptGroup::~ScriptGroup() { |
ScriptGroup::~ScriptGroup() { |
4803 |
if (pScripts) { |
if (pScripts) { |
4804 |
std::list<Script*>::iterator iter = pScripts->begin(); |
std::vector<Script*>::iterator iter = pScripts->begin(); |
4805 |
std::list<Script*>::iterator end = pScripts->end(); |
std::vector<Script*>::iterator end = pScripts->end(); |
4806 |
while (iter != end) { |
while (iter != end) { |
4807 |
delete *iter; |
delete *iter; |
4808 |
++iter; |
++iter; |
4840 |
// now store the name of this group as <LSNM> chunk as subchunk of the <RTIS> list chunk |
// now store the name of this group as <LSNM> chunk as subchunk of the <RTIS> list chunk |
4841 |
::SaveString(CHUNK_ID_LSNM, NULL, pList, Name, String("Unnamed Group"), true, 64); |
::SaveString(CHUNK_ID_LSNM, NULL, pList, Name, String("Unnamed Group"), true, 64); |
4842 |
|
|
4843 |
for (std::list<Script*>::iterator it = pScripts->begin(); |
for (std::vector<Script*>::iterator it = pScripts->begin(); |
4844 |
it != pScripts->end(); ++it) |
it != pScripts->end(); ++it) |
4845 |
{ |
{ |
4846 |
(*it)->UpdateChunks(pProgress); |
(*it)->UpdateChunks(pProgress); |
4855 |
* @param index - number of the sought script (0..n) |
* @param index - number of the sought script (0..n) |
4856 |
* @returns sought script or NULL if there's no such script |
* @returns sought script or NULL if there's no such script |
4857 |
*/ |
*/ |
4858 |
Script* ScriptGroup::GetScript(uint index) { |
Script* ScriptGroup::GetScript(size_t index) { |
4859 |
if (!pScripts) LoadScripts(); |
if (!pScripts) LoadScripts(); |
4860 |
std::list<Script*>::iterator it = pScripts->begin(); |
if (index >= pScripts->size()) return NULL; |
4861 |
for (uint i = 0; it != pScripts->end(); ++i, ++it) |
return (*pScripts)[index]; |
|
if (i == index) return *it; |
|
|
return NULL; |
|
4862 |
} |
} |
4863 |
|
|
4864 |
/** @brief Add new instrument script. |
/** @brief Add new instrument script. |
4891 |
*/ |
*/ |
4892 |
void ScriptGroup::DeleteScript(Script* pScript) { |
void ScriptGroup::DeleteScript(Script* pScript) { |
4893 |
if (!pScripts) LoadScripts(); |
if (!pScripts) LoadScripts(); |
4894 |
std::list<Script*>::iterator iter = |
std::vector<Script*>::iterator iter = |
4895 |
find(pScripts->begin(), pScripts->end(), pScript); |
find(pScripts->begin(), pScripts->end(), pScript); |
4896 |
if (iter == pScripts->end()) |
if (iter == pScripts->end()) |
4897 |
throw gig::Exception("Could not delete script, could not find given script"); |
throw gig::Exception("Could not delete script, could not find given script"); |
4904 |
|
|
4905 |
void ScriptGroup::LoadScripts() { |
void ScriptGroup::LoadScripts() { |
4906 |
if (pScripts) return; |
if (pScripts) return; |
4907 |
pScripts = new std::list<Script*>; |
pScripts = new std::vector<Script*>; |
4908 |
if (!pList) return; |
if (!pList) return; |
4909 |
|
|
4910 |
size_t i = 0; |
size_t i = 0; |
5501 |
File* pFile = (File*) GetParent(); |
File* pFile = (File*) GetParent(); |
5502 |
for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) { |
for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) { |
5503 |
uint32_t soughtOffset = scriptPoolFileOffsets[k].fileOffset; |
uint32_t soughtOffset = scriptPoolFileOffsets[k].fileOffset; |
5504 |
for (uint i = 0; pFile->GetScriptGroup(i); ++i) { |
for (size_t i = 0; pFile->GetScriptGroup(i); ++i) { |
5505 |
ScriptGroup* group = pFile->GetScriptGroup(i); |
ScriptGroup* group = pFile->GetScriptGroup(i); |
5506 |
for (uint s = 0; group->GetScript(s); ++s) { |
for (uint s = 0; group->GetScript(s); ++s) { |
5507 |
Script* script = group->GetScript(s); |
Script* script = group->GetScript(s); |
5539 |
* @param index - instrument script slot index |
* @param index - instrument script slot index |
5540 |
* @returns script or NULL if index is out of bounds |
* @returns script or NULL if index is out of bounds |
5541 |
*/ |
*/ |
5542 |
Script* Instrument::GetScriptOfSlot(uint index) { |
Script* Instrument::GetScriptOfSlot(size_t index) { |
5543 |
LoadScripts(); |
LoadScripts(); |
5544 |
if (index >= pScriptRefs->size()) return NULL; |
if (index >= pScriptRefs->size()) return NULL; |
5545 |
return pScriptRefs->at(index).script; |
return pScriptRefs->at(index).script; |
5600 |
* @param index1 - index of the first script slot to swap |
* @param index1 - index of the first script slot to swap |
5601 |
* @param index2 - index of the second script slot to swap |
* @param index2 - index of the second script slot to swap |
5602 |
*/ |
*/ |
5603 |
void Instrument::SwapScriptSlots(uint index1, uint index2) { |
void Instrument::SwapScriptSlots(size_t index1, size_t index2) { |
5604 |
LoadScripts(); |
LoadScripts(); |
5605 |
if (index1 >= pScriptRefs->size() || index2 >= pScriptRefs->size()) |
if (index1 >= pScriptRefs->size() || index2 >= pScriptRefs->size()) |
5606 |
return; |
return; |
5615 |
* |
* |
5616 |
* @param index - index of script slot to remove |
* @param index - index of script slot to remove |
5617 |
*/ |
*/ |
5618 |
void Instrument::RemoveScriptSlot(uint index) { |
void Instrument::RemoveScriptSlot(size_t index) { |
5619 |
LoadScripts(); |
LoadScripts(); |
5620 |
if (index >= pScriptRefs->size()) return; |
if (index >= pScriptRefs->size()) return; |
5621 |
pScriptRefs->erase( pScriptRefs->begin() + index ); |
pScriptRefs->erase( pScriptRefs->begin() + index ); |
5656 |
* GigaStudio 4 software. It will currently only work with LinuxSampler and |
* GigaStudio 4 software. It will currently only work with LinuxSampler and |
5657 |
* gigedit. |
* gigedit. |
5658 |
*/ |
*/ |
5659 |
uint Instrument::ScriptSlotCount() const { |
size_t Instrument::ScriptSlotCount() const { |
5660 |
return uint(pScriptRefs ? pScriptRefs->size() : scriptPoolFileOffsets.size()); |
return pScriptRefs ? pScriptRefs->size() : scriptPoolFileOffsets.size(); |
5661 |
} |
} |
5662 |
|
|
5663 |
/** @brief Whether script execution shall be skipped. |
/** @brief Whether script execution shall be skipped. |
5676 |
* @param index - index of the script slot on this instrument |
* @param index - index of the script slot on this instrument |
5677 |
* @see Script::Bypass |
* @see Script::Bypass |
5678 |
*/ |
*/ |
5679 |
bool Instrument::IsScriptSlotBypassed(uint index) { |
bool Instrument::IsScriptSlotBypassed(size_t index) { |
5680 |
if (index >= ScriptSlotCount()) return false; |
if (index >= ScriptSlotCount()) return false; |
5681 |
return pScriptRefs ? pScriptRefs->at(index).bypass |
return pScriptRefs ? pScriptRefs->at(index).bypass |
5682 |
: scriptPoolFileOffsets.at(index).bypass; |
: scriptPoolFileOffsets.at(index).bypass; |
5716 |
* the @c Script identified by passed @p uuid. |
* the @c Script identified by passed @p uuid. |
5717 |
*/ |
*/ |
5718 |
bool Instrument::ReferencesScriptWithUuid(const _UUID& uuid) { |
bool Instrument::ReferencesScriptWithUuid(const _UUID& uuid) { |
5719 |
const uint nSlots = ScriptSlotCount(); |
const size_t nSlots = ScriptSlotCount(); |
5720 |
for (uint iSlot = 0; iSlot < nSlots; ++iSlot) |
for (size_t iSlot = 0; iSlot < nSlots; ++iSlot) |
5721 |
if (_UUIDFromCArray(&GetScriptOfSlot(iSlot)->Uuid[0]) == uuid) |
if (_UUIDFromCArray(&GetScriptOfSlot(iSlot)->Uuid[0]) == uuid) |
5722 |
return true; |
return true; |
5723 |
return false; |
return false; |
6303 |
delete pGroups; |
delete pGroups; |
6304 |
} |
} |
6305 |
if (pScriptGroups) { |
if (pScriptGroups) { |
6306 |
std::list<ScriptGroup*>::iterator iter = pScriptGroups->begin(); |
std::vector<ScriptGroup*>::iterator iter = pScriptGroups->begin(); |
6307 |
std::list<ScriptGroup*>::iterator end = pScriptGroups->end(); |
std::vector<ScriptGroup*>::iterator end = pScriptGroups->end(); |
6308 |
while (iter != end) { |
while (iter != end) { |
6309 |
delete *iter; |
delete *iter; |
6310 |
++iter; |
++iter; |
6410 |
pSample->DeleteChunks(); |
pSample->DeleteChunks(); |
6411 |
delete pSample; |
delete pSample; |
6412 |
|
|
|
SampleList::iterator tmp = SamplesIterator; |
|
6413 |
// remove all references to the sample |
// remove all references to the sample |
6414 |
for (Instrument* instrument = GetFirstInstrument() ; instrument ; |
size_t iIns = 0; |
6415 |
instrument = GetNextInstrument()) { |
for (Instrument* instrument = GetInstrument(iIns); instrument; |
6416 |
|
instrument = GetInstrument(++iIns)) |
6417 |
|
{ |
6418 |
size_t iRgn = 0; |
size_t iRgn = 0; |
6419 |
for (Region* region = instrument->GetRegionAt(iRgn); region; |
for (Region* region = instrument->GetRegionAt(iRgn); region; |
6420 |
region = instrument->GetRegionAt(++iRgn)) |
region = instrument->GetRegionAt(++iRgn)) |
6427 |
} |
} |
6428 |
} |
} |
6429 |
} |
} |
|
SamplesIterator = tmp; // restore iterator |
|
6430 |
} |
} |
6431 |
|
|
6432 |
void File::LoadSamples() { |
void File::LoadSamples() { |
6711 |
} |
} |
6712 |
|
|
6713 |
// clone script groups and their scripts |
// clone script groups and their scripts |
6714 |
for (int iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) { |
for (size_t iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) { |
6715 |
ScriptGroup* sg = pFile->GetScriptGroup(iGroup); |
ScriptGroup* sg = pFile->GetScriptGroup(iGroup); |
6716 |
ScriptGroup* dg = AddScriptGroup(); |
ScriptGroup* dg = AddScriptGroup(); |
6717 |
dg->Name = "COPY" + ToString(iCallCount) + "_" + sg->Name; |
dg->Name = "COPY" + ToString(iCallCount) + "_" + sg->Name; |
7103 |
* @param index - number of the sought group (0..n) |
* @param index - number of the sought group (0..n) |
7104 |
* @returns sought script group or NULL if there's no such group |
* @returns sought script group or NULL if there's no such group |
7105 |
*/ |
*/ |
7106 |
ScriptGroup* File::GetScriptGroup(uint index) { |
ScriptGroup* File::GetScriptGroup(size_t index) { |
7107 |
if (!pScriptGroups) LoadScriptGroups(); |
if (!pScriptGroups) LoadScriptGroups(); |
7108 |
std::list<ScriptGroup*>::iterator it = pScriptGroups->begin(); |
if (index >= pScriptGroups->size()) return NULL; |
7109 |
for (uint i = 0; it != pScriptGroups->end(); ++i, ++it) |
return (*pScriptGroups)[index]; |
|
if (i == index) return *it; |
|
|
return NULL; |
|
7110 |
} |
} |
7111 |
|
|
7112 |
/** @brief Get instrument script group (by name). |
/** @brief Get instrument script group (by name). |
7119 |
*/ |
*/ |
7120 |
ScriptGroup* File::GetScriptGroup(const String& name) { |
ScriptGroup* File::GetScriptGroup(const String& name) { |
7121 |
if (!pScriptGroups) LoadScriptGroups(); |
if (!pScriptGroups) LoadScriptGroups(); |
7122 |
std::list<ScriptGroup*>::iterator it = pScriptGroups->begin(); |
for (size_t i = 0; i < pScriptGroups->size(); ++i) { |
7123 |
for (uint i = 0; it != pScriptGroups->end(); ++i, ++it) |
ScriptGroup* pGroup = (*pScriptGroups)[i]; |
7124 |
if ((*it)->Name == name) return *it; |
if (pGroup->Name == name) return pGroup; |
7125 |
|
} |
7126 |
return NULL; |
return NULL; |
7127 |
} |
} |
7128 |
|
|
7155 |
*/ |
*/ |
7156 |
void File::DeleteScriptGroup(ScriptGroup* pScriptGroup) { |
void File::DeleteScriptGroup(ScriptGroup* pScriptGroup) { |
7157 |
if (!pScriptGroups) LoadScriptGroups(); |
if (!pScriptGroups) LoadScriptGroups(); |
7158 |
std::list<ScriptGroup*>::iterator iter = |
std::vector<ScriptGroup*>::iterator iter = |
7159 |
find(pScriptGroups->begin(), pScriptGroups->end(), pScriptGroup); |
find(pScriptGroups->begin(), pScriptGroups->end(), pScriptGroup); |
7160 |
if (iter == pScriptGroups->end()) |
if (iter == pScriptGroups->end()) |
7161 |
throw gig::Exception("Could not delete script group, could not find given script group"); |
throw gig::Exception("Could not delete script group, could not find given script group"); |
7170 |
|
|
7171 |
void File::LoadScriptGroups() { |
void File::LoadScriptGroups() { |
7172 |
if (pScriptGroups) return; |
if (pScriptGroups) return; |
7173 |
pScriptGroups = new std::list<ScriptGroup*>; |
pScriptGroups = new std::vector<ScriptGroup*>; |
7174 |
RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS); |
RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS); |
7175 |
if (lstLS) { |
if (lstLS) { |
7176 |
size_t i = 0; |
size_t i = 0; |
7215 |
// of the respective instrument script chunk as reference. |
// of the respective instrument script chunk as reference. |
7216 |
if (pScriptGroups) { |
if (pScriptGroups) { |
7217 |
// Update instrument script (group) chunks. |
// Update instrument script (group) chunks. |
7218 |
for (std::list<ScriptGroup*>::iterator it = pScriptGroups->begin(); |
for (std::vector<ScriptGroup*>::iterator it = pScriptGroups->begin(); |
7219 |
it != pScriptGroups->end(); ++it) |
it != pScriptGroups->end(); ++it) |
7220 |
{ |
{ |
7221 |
(*it)->UpdateChunks(pProgress); |
(*it)->UpdateChunks(pProgress); |
7322 |
|
|
7323 |
memset(&pData[48], 0, sublen - 48); |
memset(&pData[48], 0, sublen - 48); |
7324 |
|
|
7325 |
for (Instrument* instrument = GetFirstInstrument() ; instrument ; |
size_t iIns = 0; |
7326 |
instrument = GetNextInstrument()) { |
for (Instrument* instrument = GetInstrument(iIns); instrument; |
7327 |
|
instrument = GetInstrument(++iIns)) |
7328 |
|
{ |
7329 |
int nbusedsamples = 0; |
int nbusedsamples = 0; |
7330 |
int nbusedchannels = 0; |
int nbusedchannels = 0; |
7331 |
int nbdimregions = 0; |
int nbdimregions = 0; |
7430 |
void File::UpdateFileOffsets() { |
void File::UpdateFileOffsets() { |
7431 |
DLS::File::UpdateFileOffsets(); |
DLS::File::UpdateFileOffsets(); |
7432 |
|
|
7433 |
for (Instrument* instrument = GetFirstInstrument(); instrument; |
size_t i = 0; |
7434 |
instrument = GetNextInstrument()) |
for (Instrument* instrument = GetInstrument(i); instrument; |
7435 |
|
instrument = GetInstrument(++i)) |
7436 |
{ |
{ |
7437 |
instrument->UpdateScriptFileOffsets(); |
instrument->UpdateScriptFileOffsets(); |
7438 |
} |
} |