275 |
* @param bufSize - size of the data to be processed |
* @param bufSize - size of the data to be processed |
276 |
* @param crc - variable the CRC sum shall be stored to |
* @param crc - variable the CRC sum shall be stored to |
277 |
*/ |
*/ |
278 |
static void __calculateCRC(unsigned char* buf, int bufSize, uint32_t& crc) { |
static void __calculateCRC(unsigned char* buf, size_t bufSize, uint32_t& crc) { |
279 |
for (int i = 0 ; i < bufSize ; i++) { |
for (size_t i = 0 ; i < bufSize ; i++) { |
280 |
crc = __CRCTable[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); |
crc = __CRCTable[(crc ^ buf[i]) & 0xff] ^ (crc >> 8); |
281 |
} |
} |
282 |
} |
} |
1396 |
* @see GetWaveDataCRC32Checksum() |
* @see GetWaveDataCRC32Checksum() |
1397 |
*/ |
*/ |
1398 |
bool Sample::VerifyWaveData(uint32_t* pActually) { |
bool Sample::VerifyWaveData(uint32_t* pActually) { |
1399 |
File* pFile = static_cast<File*>(GetParent()); |
//File* pFile = static_cast<File*>(GetParent()); |
1400 |
uint32_t crc = CalculateWaveDataChecksum(); |
uint32_t crc = CalculateWaveDataChecksum(); |
1401 |
if (pActually) *pActually = crc; |
if (pActually) *pActually = crc; |
1402 |
return crc == this->crc; |
return crc == this->crc; |
1829 |
|
|
1830 |
// update '3ewa' chunk with DimensionRegion's current settings |
// update '3ewa' chunk with DimensionRegion's current settings |
1831 |
|
|
1832 |
const uint32_t chunksize = _3ewa->GetNewSize(); |
const uint32_t chunksize = (uint32_t) _3ewa->GetNewSize(); |
1833 |
store32(&pData[0], chunksize); // unknown, always chunk size? |
store32(&pData[0], chunksize); // unknown, always chunk size? |
1834 |
|
|
1835 |
const int32_t lfo3freq = (int32_t) GIG_EXP_ENCODE(LFO3Frequency); |
const int32_t lfo3freq = (int32_t) GIG_EXP_ENCODE(LFO3Frequency); |
3797 |
DimensionRegion* Region::GetDimensionRegionByValue(const uint DimValues[8]) { |
DimensionRegion* Region::GetDimensionRegionByValue(const uint DimValues[8]) { |
3798 |
uint8_t bits; |
uint8_t bits; |
3799 |
int veldim = -1; |
int veldim = -1; |
3800 |
int velbitpos; |
int velbitpos = 0; |
3801 |
int bitpos = 0; |
int bitpos = 0; |
3802 |
int dimregidx = 0; |
int dimregidx = 0; |
3803 |
for (uint i = 0; i < Dimensions; i++) { |
for (uint i = 0; i < Dimensions; i++) { |
3846 |
int Region::GetDimensionRegionIndexByValue(const uint DimValues[8]) { |
int Region::GetDimensionRegionIndexByValue(const uint DimValues[8]) { |
3847 |
uint8_t bits; |
uint8_t bits; |
3848 |
int veldim = -1; |
int veldim = -1; |
3849 |
int velbitpos; |
int velbitpos = 0; |
3850 |
int bitpos = 0; |
int bitpos = 0; |
3851 |
int dimregidx = 0; |
int dimregidx = 0; |
3852 |
for (uint i = 0; i < Dimensions; i++) { |
for (uint i = 0; i < Dimensions; i++) { |
4195 |
// to handle potential future extensions of the header |
// to handle potential future extensions of the header |
4196 |
ckScri->SetPos(sizeof(int32_t) + headerSize); |
ckScri->SetPos(sizeof(int32_t) + headerSize); |
4197 |
// read actual script data |
// read actual script data |
4198 |
uint32_t scriptSize = ckScri->GetSize() - ckScri->GetPos(); |
uint32_t scriptSize = uint32_t(ckScri->GetSize() - ckScri->GetPos()); |
4199 |
data.resize(scriptSize); |
data.resize(scriptSize); |
4200 |
for (int i = 0; i < scriptSize; ++i) |
for (int i = 0; i < scriptSize; ++i) |
4201 |
data[i] = ckScri->ReadUint8(); |
data[i] = ckScri->ReadUint8(); |
4248 |
__calculateCRC(&data[0], data.size(), crc); |
__calculateCRC(&data[0], data.size(), crc); |
4249 |
__encodeCRC(crc); |
__encodeCRC(crc); |
4250 |
// make sure chunk exists and has the required size |
// make sure chunk exists and has the required size |
4251 |
const int chunkSize = 7*sizeof(int32_t) + Name.size() + data.size(); |
const file_offset_t chunkSize = (file_offset_t) 7*sizeof(int32_t) + Name.size() + data.size(); |
4252 |
if (!pChunk) pChunk = pGroup->pList->AddSubChunk(CHUNK_ID_SCRI, chunkSize); |
if (!pChunk) pChunk = pGroup->pList->AddSubChunk(CHUNK_ID_SCRI, chunkSize); |
4253 |
else pChunk->Resize(chunkSize); |
else pChunk->Resize(chunkSize); |
4254 |
// fill the chunk data to be written to disk |
// fill the chunk data to be written to disk |
4255 |
uint8_t* pData = (uint8_t*) pChunk->LoadChunkData(); |
uint8_t* pData = (uint8_t*) pChunk->LoadChunkData(); |
4256 |
int pos = 0; |
int pos = 0; |
4257 |
store32(&pData[pos], 6*sizeof(int32_t) + Name.size()); // total header size |
store32(&pData[pos], uint32_t(6*sizeof(int32_t) + Name.size())); // total header size |
4258 |
pos += sizeof(int32_t); |
pos += sizeof(int32_t); |
4259 |
store32(&pData[pos], Compression); |
store32(&pData[pos], Compression); |
4260 |
pos += sizeof(int32_t); |
pos += sizeof(int32_t); |
4266 |
pos += sizeof(int32_t); |
pos += sizeof(int32_t); |
4267 |
store32(&pData[pos], crc); |
store32(&pData[pos], crc); |
4268 |
pos += sizeof(int32_t); |
pos += sizeof(int32_t); |
4269 |
store32(&pData[pos], Name.size()); |
store32(&pData[pos], (uint32_t) Name.size()); |
4270 |
pos += sizeof(int32_t); |
pos += sizeof(int32_t); |
4271 |
for (int i = 0; i < Name.size(); ++i, ++pos) |
for (int i = 0; i < Name.size(); ++i, ++pos) |
4272 |
pData[pos] = Name[i]; |
pData[pos] = Name[i]; |
4443 |
EffectSend = 0; |
EffectSend = 0; |
4444 |
Attenuation = 0; |
Attenuation = 0; |
4445 |
FineTune = 0; |
FineTune = 0; |
4446 |
PitchbendRange = 0; |
PitchbendRange = 2; |
4447 |
PianoReleaseMode = false; |
PianoReleaseMode = false; |
4448 |
DimensionKeyRange.low = 0; |
DimensionKeyRange.low = 0; |
4449 |
DimensionKeyRange.high = 0; |
DimensionKeyRange.high = 0; |
4618 |
|
|
4619 |
RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS); |
RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS); |
4620 |
if (!lst3LS) lst3LS = pCkInstrument->AddSubList(LIST_TYPE_3LS); |
if (!lst3LS) lst3LS = pCkInstrument->AddSubList(LIST_TYPE_3LS); |
4621 |
const int slotCount = pScriptRefs->size(); |
const int slotCount = (int) pScriptRefs->size(); |
4622 |
const int headerSize = 3 * sizeof(uint32_t); |
const int headerSize = 3 * sizeof(uint32_t); |
4623 |
const int slotSize = 2 * sizeof(uint32_t); |
const int slotSize = 2 * sizeof(uint32_t); |
4624 |
const int totalChunkSize = headerSize + slotCount * slotSize; |
const int totalChunkSize = headerSize + slotCount * slotSize; |
4654 |
if (pScriptRefs && pScriptRefs->size() > 0) { |
if (pScriptRefs && pScriptRefs->size() > 0) { |
4655 |
RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS); |
RIFF::List* lst3LS = pCkInstrument->GetSubList(LIST_TYPE_3LS); |
4656 |
RIFF::Chunk* ckSCSL = lst3LS->GetSubChunk(CHUNK_ID_SCSL); |
RIFF::Chunk* ckSCSL = lst3LS->GetSubChunk(CHUNK_ID_SCSL); |
4657 |
const int slotCount = pScriptRefs->size(); |
const int slotCount = (int) pScriptRefs->size(); |
4658 |
const int headerSize = 3 * sizeof(uint32_t); |
const int headerSize = 3 * sizeof(uint32_t); |
4659 |
ckSCSL->SetPos(headerSize); |
ckSCSL->SetPos(headerSize); |
4660 |
for (int i = 0; i < slotCount; ++i) { |
for (int i = 0; i < slotCount; ++i) { |
4661 |
uint32_t fileOffset = |
uint32_t fileOffset = uint32_t( |
4662 |
(*pScriptRefs)[i].script->pChunk->GetFilePos() - |
(*pScriptRefs)[i].script->pChunk->GetFilePos() - |
4663 |
(*pScriptRefs)[i].script->pChunk->GetPos() - |
(*pScriptRefs)[i].script->pChunk->GetPos() - |
4664 |
CHUNK_HEADER_SIZE(ckSCSL->GetFile()->GetFileOffsetSize()); |
CHUNK_HEADER_SIZE(ckSCSL->GetFile()->GetFileOffsetSize()) |
4665 |
|
); |
4666 |
ckSCSL->WriteUint32(&fileOffset); |
ckSCSL->WriteUint32(&fileOffset); |
4667 |
// jump over flags entry (containing the bypass flag) |
// jump over flags entry (containing the bypass flag) |
4668 |
ckSCSL->SetPos(sizeof(uint32_t), RIFF::stream_curpos); |
ckSCSL->SetPos(sizeof(uint32_t), RIFF::stream_curpos); |
4722 |
RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN); |
RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN); |
4723 |
Region* pNewRegion = new Region(this, rgn); |
Region* pNewRegion = new Region(this, rgn); |
4724 |
pRegions->push_back(pNewRegion); |
pRegions->push_back(pNewRegion); |
4725 |
Regions = pRegions->size(); |
Regions = (uint32_t) pRegions->size(); |
4726 |
// update Region key table for fast lookup |
// update Region key table for fast lookup |
4727 |
UpdateRegionKeyTable(); |
UpdateRegionKeyTable(); |
4728 |
// done |
// done |
4868 |
for (uint s = 0; group->GetScript(s); ++s) { |
for (uint s = 0; group->GetScript(s); ++s) { |
4869 |
Script* script = group->GetScript(s); |
Script* script = group->GetScript(s); |
4870 |
if (script->pChunk) { |
if (script->pChunk) { |
4871 |
uint32_t offset = script->pChunk->GetFilePos() - |
uint32_t offset = uint32_t( |
4872 |
script->pChunk->GetPos() - |
script->pChunk->GetFilePos() - |
4873 |
CHUNK_HEADER_SIZE(script->pChunk->GetFile()->GetFileOffsetSize()); |
script->pChunk->GetPos() - |
4874 |
|
CHUNK_HEADER_SIZE(script->pChunk->GetFile()->GetFileOffsetSize()) |
4875 |
|
); |
4876 |
if (offset == soughtOffset) |
if (offset == soughtOffset) |
4877 |
{ |
{ |
4878 |
_ScriptPooolRef ref; |
_ScriptPooolRef ref; |
4997 |
*/ |
*/ |
4998 |
void Instrument::RemoveScript(Script* pScript) { |
void Instrument::RemoveScript(Script* pScript) { |
4999 |
LoadScripts(); |
LoadScripts(); |
5000 |
for (int i = pScriptRefs->size() - 1; i >= 0; --i) { |
for (ssize_t i = pScriptRefs->size() - 1; i >= 0; --i) { |
5001 |
if ((*pScriptRefs)[i].script == pScript) { |
if ((*pScriptRefs)[i].script == pScript) { |
5002 |
pScriptRefs->erase( pScriptRefs->begin() + i ); |
pScriptRefs->erase( pScriptRefs->begin() + i ); |
5003 |
} |
} |
5019 |
* gigedit. |
* gigedit. |
5020 |
*/ |
*/ |
5021 |
uint Instrument::ScriptSlotCount() const { |
uint Instrument::ScriptSlotCount() const { |
5022 |
return pScriptRefs ? pScriptRefs->size() : scriptPoolFileOffsets.size(); |
return uint(pScriptRefs ? pScriptRefs->size() : scriptPoolFileOffsets.size()); |
5023 |
} |
} |
5024 |
|
|
5025 |
/** @brief Whether script execution shall be skipped. |
/** @brief Whether script execution shall be skipped. |
5443 |
} |
} |
5444 |
} |
} |
5445 |
String name(pRIFF->GetFileName()); |
String name(pRIFF->GetFileName()); |
5446 |
int nameLen = name.length(); |
int nameLen = (int) name.length(); |
5447 |
char suffix[6]; |
char suffix[6]; |
5448 |
if (nameLen > 4 && name.substr(nameLen - 4) == ".gig") nameLen -= 4; |
if (nameLen > 4 && name.substr(nameLen - 4) == ".gig") nameLen -= 4; |
5449 |
|
|
5759 |
if (!pSamples) GetFirstSample(); // make sure sample chunks were scanned |
if (!pSamples) GetFirstSample(); // make sure sample chunks were scanned |
5760 |
if (_3crc->GetNewSize() != pSamples->size() * 8) return false; |
if (_3crc->GetNewSize() != pSamples->size() * 8) return false; |
5761 |
|
|
5762 |
const int n = _3crc->GetNewSize() / 8; |
const file_offset_t n = _3crc->GetNewSize() / 8; |
5763 |
|
|
5764 |
uint32_t* pData = (uint32_t*) _3crc->LoadChunkData(); |
uint32_t* pData = (uint32_t*) _3crc->LoadChunkData(); |
5765 |
if (!pData) return false; |
if (!pData) return false; |
5766 |
|
|
5767 |
for (int i = 0; i < n; ++i) { |
for (file_offset_t i = 0; i < n; ++i) { |
5768 |
uint32_t one = pData[i*2]; |
uint32_t one = pData[i*2]; |
5769 |
if (one != 1) return false; |
if (one != 1) return false; |
5770 |
} |
} |
6156 |
// Note that there are several fields with unknown use. These |
// Note that there are several fields with unknown use. These |
6157 |
// are set to zero. |
// are set to zero. |
6158 |
|
|
6159 |
int sublen = pSamples->size() / 8 + 49; |
int sublen = int(pSamples->size() / 8 + 49); |
6160 |
int einfSize = (Instruments + 1) * sublen; |
int einfSize = (Instruments + 1) * sublen; |
6161 |
|
|
6162 |
RIFF::Chunk* einf = pRIFF->GetSubChunk(CHUNK_ID_EINF); |
RIFF::Chunk* einf = pRIFF->GetSubChunk(CHUNK_ID_EINF); |
6229 |
store32(&pData[(instrumentIdx + 1) * sublen + 24], nbloops); |
store32(&pData[(instrumentIdx + 1) * sublen + 24], nbloops); |
6230 |
// next 8 bytes unknown |
// next 8 bytes unknown |
6231 |
store32(&pData[(instrumentIdx + 1) * sublen + 36], instrumentIdx); |
store32(&pData[(instrumentIdx + 1) * sublen + 36], instrumentIdx); |
6232 |
store32(&pData[(instrumentIdx + 1) * sublen + 40], pSamples->size()); |
store32(&pData[(instrumentIdx + 1) * sublen + 40], (uint32_t) pSamples->size()); |
6233 |
// next 4 bytes unknown |
// next 4 bytes unknown |
6234 |
|
|
6235 |
totnbregions += instrument->Regions; |
totnbregions += instrument->Regions; |
6247 |
store32(&pData[24], totnbloops); |
store32(&pData[24], totnbloops); |
6248 |
// next 8 bytes unknown |
// next 8 bytes unknown |
6249 |
// next 4 bytes unknown, not always 0 |
// next 4 bytes unknown, not always 0 |
6250 |
store32(&pData[40], pSamples->size()); |
store32(&pData[40], (uint32_t) pSamples->size()); |
6251 |
// next 4 bytes unknown |
// next 4 bytes unknown |
6252 |
} |
} |
6253 |
|
|