239 |
* @param list - pointer to a list chunk which contains an INFO list chunk |
* @param list - pointer to a list chunk which contains an INFO list chunk |
240 |
*/ |
*/ |
241 |
Info::Info(RIFF::List* list) { |
Info::Info(RIFF::List* list) { |
242 |
FixedStringLengths = NULL; |
pFixedStringLengths = NULL; |
243 |
pResourceListChunk = list; |
pResourceListChunk = list; |
244 |
if (list) { |
if (list) { |
245 |
RIFF::List* lstINFO = list->GetSubList(LIST_TYPE_INFO); |
RIFF::List* lstINFO = list->GetSubList(LIST_TYPE_INFO); |
268 |
Info::~Info() { |
Info::~Info() { |
269 |
} |
} |
270 |
|
|
271 |
|
/** |
272 |
|
* Forces specific Info fields to be of a fixed length when being saved |
273 |
|
* to a file. By default the respective RIFF chunk of an Info field |
274 |
|
* will have a size analogue to its actual string length. With this |
275 |
|
* method however this behavior can be overridden, allowing to force an |
276 |
|
* arbitrary fixed size individually for each Info field. |
277 |
|
* |
278 |
|
* This method is used as a workaround for the gig format, not for DLS. |
279 |
|
* |
280 |
|
* @param lengths - NULL terminated array of string_length_t elements |
281 |
|
*/ |
282 |
|
void Info::SetFixedStringLengths(const string_length_t* lengths) { |
283 |
|
pFixedStringLengths = lengths; |
284 |
|
} |
285 |
|
|
286 |
/** @brief Load given INFO field. |
/** @brief Load given INFO field. |
287 |
* |
* |
288 |
* Load INFO field from INFO chunk with chunk ID \a ChunkID from INFO |
* Load INFO field from INFO chunk with chunk ID \a ChunkID from INFO |
310 |
*/ |
*/ |
311 |
void Info::SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault) { |
void Info::SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault) { |
312 |
int size = 0; |
int size = 0; |
313 |
if (FixedStringLengths) { |
if (pFixedStringLengths) { |
314 |
for (int i = 0 ; FixedStringLengths[i].length ; i++) { |
for (int i = 0 ; pFixedStringLengths[i].length ; i++) { |
315 |
if (FixedStringLengths[i].chunkId == ChunkID) { |
if (pFixedStringLengths[i].chunkId == ChunkID) { |
316 |
size = FixedStringLengths[i].length; |
size = pFixedStringLengths[i].length; |
317 |
break; |
break; |
318 |
} |
} |
319 |
} |
} |
502 |
SamplerOptions = wsmp->ReadUint32(); |
SamplerOptions = wsmp->ReadUint32(); |
503 |
SampleLoops = wsmp->ReadUint32(); |
SampleLoops = wsmp->ReadUint32(); |
504 |
} else { // 'wsmp' chunk missing |
} else { // 'wsmp' chunk missing |
505 |
uiHeaderSize = 0; |
uiHeaderSize = 20; |
506 |
UnityNote = 60; |
UnityNote = 60; |
507 |
FineTune = 0; // +- 0 cents |
FineTune = 0; // +- 0 cents |
508 |
Gain = 0; // 0 dB |
Gain = 0; // 0 dB |
527 |
if (pSampleLoops) delete[] pSampleLoops; |
if (pSampleLoops) delete[] pSampleLoops; |
528 |
} |
} |
529 |
|
|
530 |
|
void Sampler::SetGain(int32_t gain) { |
531 |
|
Gain = gain; |
532 |
|
} |
533 |
|
|
534 |
/** |
/** |
535 |
* Apply all sample player options to the respective RIFF chunk. You |
* Apply all sample player options to the respective RIFF chunk. You |
536 |
* have to call File::Save() to make changes persistent. |
* have to call File::Save() to make changes persistent. |
538 |
void Sampler::UpdateChunks() { |
void Sampler::UpdateChunks() { |
539 |
// make sure 'wsmp' chunk exists |
// make sure 'wsmp' chunk exists |
540 |
RIFF::Chunk* wsmp = pParentList->GetSubChunk(CHUNK_ID_WSMP); |
RIFF::Chunk* wsmp = pParentList->GetSubChunk(CHUNK_ID_WSMP); |
541 |
|
int wsmpSize = uiHeaderSize + SampleLoops * 16; |
542 |
if (!wsmp) { |
if (!wsmp) { |
543 |
uiHeaderSize = 20; |
wsmp = pParentList->AddSubChunk(CHUNK_ID_WSMP, wsmpSize); |
544 |
wsmp = pParentList->AddSubChunk(CHUNK_ID_WSMP, uiHeaderSize + SampleLoops * 16); |
} else if (wsmp->GetSize() != wsmpSize) { |
545 |
|
wsmp->Resize(wsmpSize); |
546 |
} |
} |
547 |
uint8_t* pData = (uint8_t*) wsmp->LoadChunkData(); |
uint8_t* pData = (uint8_t*) wsmp->LoadChunkData(); |
548 |
// update headers size |
// update headers size |