libgig  3.3.0
DLS.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * libgig - C++ cross-platform Gigasampler format file access library *
4  * *
5  * Copyright (C) 2003-2009 by Christian Schoenebeck *
6  * <cuse@users.sourceforge.net> *
7  * *
8  * This library is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this library; if not, write to the Free Software *
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21  * MA 02111-1307 USA *
22  ***************************************************************************/
23 
24 #include "DLS.h"
25 
26 #include <algorithm>
27 #include <time.h>
28 
29 #ifdef __APPLE__
30 #include <CoreFoundation/CFUUID.h>
31 #elif defined(HAVE_UUID_UUID_H)
32 #include <uuid/uuid.h>
33 #endif
34 
35 #include "helper.h"
36 
37 // macros to decode connection transforms
38 #define CONN_TRANSFORM_SRC(x) ((x >> 10) & 0x000F)
39 #define CONN_TRANSFORM_CTL(x) ((x >> 4) & 0x000F)
40 #define CONN_TRANSFORM_DST(x) (x & 0x000F)
41 #define CONN_TRANSFORM_BIPOLAR_SRC(x) (x & 0x4000)
42 #define CONN_TRANSFORM_BIPOLAR_CTL(x) (x & 0x0100)
43 #define CONN_TRANSFORM_INVERT_SRC(x) (x & 0x8000)
44 #define CONN_TRANSFORM_INVERT_CTL(x) (x & 0x0200)
45 
46 // macros to encode connection transforms
47 #define CONN_TRANSFORM_SRC_ENCODE(x) ((x & 0x000F) << 10)
48 #define CONN_TRANSFORM_CTL_ENCODE(x) ((x & 0x000F) << 4)
49 #define CONN_TRANSFORM_DST_ENCODE(x) (x & 0x000F)
50 #define CONN_TRANSFORM_BIPOLAR_SRC_ENCODE(x) ((x) ? 0x4000 : 0)
51 #define CONN_TRANSFORM_BIPOLAR_CTL_ENCODE(x) ((x) ? 0x0100 : 0)
52 #define CONN_TRANSFORM_INVERT_SRC_ENCODE(x) ((x) ? 0x8000 : 0)
53 #define CONN_TRANSFORM_INVERT_CTL_ENCODE(x) ((x) ? 0x0200 : 0)
54 
55 #define DRUM_TYPE_MASK 0x80000000
56 
57 #define F_RGN_OPTION_SELFNONEXCLUSIVE 0x0001
58 
59 #define F_WAVELINK_PHASE_MASTER 0x0001
60 #define F_WAVELINK_MULTICHANNEL 0x0002
61 
62 #define F_WSMP_NO_TRUNCATION 0x0001
63 #define F_WSMP_NO_COMPRESSION 0x0002
64 
65 #define MIDI_BANK_COARSE(x) ((x & 0x00007F00) >> 8) // CC0
66 #define MIDI_BANK_FINE(x) (x & 0x0000007F) // CC32
67 #define MIDI_BANK_MERGE(coarse, fine) ((((uint16_t) coarse) << 7) | fine) // CC0 + CC32
68 #define MIDI_BANK_ENCODE(coarse, fine) (((coarse & 0x0000007F) << 8) | (fine & 0x0000007F))
69 
70 namespace DLS {
71 
72 // *************** Connection ***************
73 // *
74 
76  Source = (conn_src_t) Header->source;
77  Control = (conn_src_t) Header->control;
79  Scale = Header->scale;
87  }
88 
90  conn_block_t c;
91  c.source = Source;
92  c.control = Control;
94  c.scale = Scale;
102  return c;
103  }
104 
105 
106 
107 // *************** Articulation ***************
108 // *
109 
119  pArticulationCk = artl;
120  if (artl->GetChunkID() != CHUNK_ID_ART2 &&
121  artl->GetChunkID() != CHUNK_ID_ARTL) {
122  throw DLS::Exception("<artl-ck> or <art2-ck> chunk expected");
123  }
124  HeaderSize = artl->ReadUint32();
125  Connections = artl->ReadUint32();
126  artl->SetPos(HeaderSize);
127 
129  Connection::conn_block_t connblock;
130  for (uint32_t i = 0; i < Connections; i++) {
131  artl->Read(&connblock.source, 1, 2);
132  artl->Read(&connblock.control, 1, 2);
133  artl->Read(&connblock.destination, 1, 2);
134  artl->Read(&connblock.transform, 1, 2);
135  artl->Read(&connblock.scale, 1, 4);
136  pConnections[i].Init(&connblock);
137  }
138  }
139 
141  if (pConnections) delete[] pConnections;
142  }
143 
149  const int iEntrySize = 12; // 12 bytes per connection block
150  pArticulationCk->Resize(HeaderSize + Connections * iEntrySize);
151  uint8_t* pData = (uint8_t*) pArticulationCk->LoadChunkData();
152  store16(&pData[0], HeaderSize);
153  store16(&pData[2], Connections);
154  for (uint32_t i = 0; i < Connections; i++) {
156  store16(&pData[HeaderSize + i * iEntrySize], c.source);
157  store16(&pData[HeaderSize + i * iEntrySize + 2], c.control);
158  store16(&pData[HeaderSize + i * iEntrySize + 4], c.destination);
159  store16(&pData[HeaderSize + i * iEntrySize + 6], c.transform);
160  store32(&pData[HeaderSize + i * iEntrySize + 8], c.scale);
161  }
162  }
163 
164 
165 
166 // *************** Articulator ***************
167 // *
168 
170  pParentList = ParentList;
171  pArticulations = NULL;
172  }
173 
176  if (!pArticulations) return NULL;
178  return (ArticulationsIterator != pArticulations->end()) ? *ArticulationsIterator : NULL;
179  }
180 
182  if (!pArticulations) return NULL;
184  return (ArticulationsIterator != pArticulations->end()) ? *ArticulationsIterator : NULL;
185  }
186 
188  // prefer articulation level 2
190  if (!lart) lart = pParentList->GetSubList(LIST_TYPE_LART);
191  if (lart) {
192  uint32_t artCkType = (lart->GetListType() == LIST_TYPE_LAR2) ? CHUNK_ID_ART2
193  : CHUNK_ID_ARTL;
194  RIFF::Chunk* art = lart->GetFirstSubChunk();
195  while (art) {
196  if (art->GetChunkID() == artCkType) {
198  pArticulations->push_back(new Articulation(art));
199  }
200  art = lart->GetNextSubChunk();
201  }
202  }
203  }
204 
206  if (pArticulations) {
207  ArticulationList::iterator iter = pArticulations->begin();
208  ArticulationList::iterator end = pArticulations->end();
209  while (iter != end) {
210  delete *iter;
211  iter++;
212  }
213  delete pArticulations;
214  }
215  }
216 
222  if (pArticulations) {
223  ArticulationList::iterator iter = pArticulations->begin();
224  ArticulationList::iterator end = pArticulations->end();
225  for (; iter != end; ++iter) {
226  (*iter)->UpdateChunks();
227  }
228  }
229  }
230 
231 
232 
233 // *************** Info ***************
234 // *
235 
243  pFixedStringLengths = NULL;
244  pResourceListChunk = list;
245  if (list) {
246  RIFF::List* lstINFO = list->GetSubList(LIST_TYPE_INFO);
247  if (lstINFO) {
248  LoadString(CHUNK_ID_INAM, lstINFO, Name);
249  LoadString(CHUNK_ID_IARL, lstINFO, ArchivalLocation);
250  LoadString(CHUNK_ID_ICRD, lstINFO, CreationDate);
251  LoadString(CHUNK_ID_ICMT, lstINFO, Comments);
252  LoadString(CHUNK_ID_IPRD, lstINFO, Product);
253  LoadString(CHUNK_ID_ICOP, lstINFO, Copyright);
254  LoadString(CHUNK_ID_IART, lstINFO, Artists);
255  LoadString(CHUNK_ID_IGNR, lstINFO, Genre);
256  LoadString(CHUNK_ID_IKEY, lstINFO, Keywords);
257  LoadString(CHUNK_ID_IENG, lstINFO, Engineer);
258  LoadString(CHUNK_ID_ITCH, lstINFO, Technician);
259  LoadString(CHUNK_ID_ISFT, lstINFO, Software);
260  LoadString(CHUNK_ID_IMED, lstINFO, Medium);
261  LoadString(CHUNK_ID_ISRC, lstINFO, Source);
262  LoadString(CHUNK_ID_ISRF, lstINFO, SourceForm);
263  LoadString(CHUNK_ID_ICMS, lstINFO, Commissioned);
264  LoadString(CHUNK_ID_ISBJ, lstINFO, Subject);
265  }
266  }
267  }
268 
270  }
271 
284  pFixedStringLengths = lengths;
285  }
286 
292  void Info::LoadString(uint32_t ChunkID, RIFF::List* lstINFO, String& s) {
293  RIFF::Chunk* ck = lstINFO->GetSubChunk(ChunkID);
294  ::LoadString(ck, s); // function from helper.h
295  }
296 
312  void Info::SaveString(uint32_t ChunkID, RIFF::List* lstINFO, const String& s, const String& sDefault) {
313  int size = 0;
314  if (pFixedStringLengths) {
315  for (int i = 0 ; pFixedStringLengths[i].length ; i++) {
316  if (pFixedStringLengths[i].chunkId == ChunkID) {
317  size = pFixedStringLengths[i].length;
318  break;
319  }
320  }
321  }
322  RIFF::Chunk* ck = lstINFO->GetSubChunk(ChunkID);
323  ::SaveString(ChunkID, ck, lstINFO, s, sDefault, size != 0, size); // function from helper.h
324  }
325 
332  if (!pResourceListChunk) return;
333 
334  // make sure INFO list chunk exists
335  RIFF::List* lstINFO = pResourceListChunk->GetSubList(LIST_TYPE_INFO);
336 
337  String defaultName = "";
338  String defaultCreationDate = "";
339  String defaultSoftware = "";
340  String defaultComments = "";
341 
342  uint32_t resourceType = pResourceListChunk->GetListType();
343 
344  if (!lstINFO) {
345  lstINFO = pResourceListChunk->AddSubList(LIST_TYPE_INFO);
346 
347  // assemble default values
348  defaultName = "NONAME";
349 
350  if (resourceType == RIFF_TYPE_DLS) {
351  // get current date
352  time_t now = time(NULL);
353  tm* pNowBroken = localtime(&now);
354  char buf[11];
355  strftime(buf, 11, "%F", pNowBroken);
356  defaultCreationDate = buf;
357 
358  defaultComments = "Created with " + libraryName() + " " + libraryVersion();
359  }
360  if (resourceType == RIFF_TYPE_DLS || resourceType == LIST_TYPE_INS)
361  {
362  defaultSoftware = libraryName() + " " + libraryVersion();
363  }
364  }
365 
366  // save values
367 
368  SaveString(CHUNK_ID_IARL, lstINFO, ArchivalLocation, String(""));
369  SaveString(CHUNK_ID_IART, lstINFO, Artists, String(""));
370  SaveString(CHUNK_ID_ICMS, lstINFO, Commissioned, String(""));
371  SaveString(CHUNK_ID_ICMT, lstINFO, Comments, defaultComments);
372  SaveString(CHUNK_ID_ICOP, lstINFO, Copyright, String(""));
373  SaveString(CHUNK_ID_ICRD, lstINFO, CreationDate, defaultCreationDate);
374  SaveString(CHUNK_ID_IENG, lstINFO, Engineer, String(""));
375  SaveString(CHUNK_ID_IGNR, lstINFO, Genre, String(""));
376  SaveString(CHUNK_ID_IKEY, lstINFO, Keywords, String(""));
377  SaveString(CHUNK_ID_IMED, lstINFO, Medium, String(""));
378  SaveString(CHUNK_ID_INAM, lstINFO, Name, defaultName);
379  SaveString(CHUNK_ID_IPRD, lstINFO, Product, String(""));
380  SaveString(CHUNK_ID_ISBJ, lstINFO, Subject, String(""));
381  SaveString(CHUNK_ID_ISFT, lstINFO, Software, defaultSoftware);
382  SaveString(CHUNK_ID_ISRC, lstINFO, Source, String(""));
383  SaveString(CHUNK_ID_ISRF, lstINFO, SourceForm, String(""));
384  SaveString(CHUNK_ID_ITCH, lstINFO, Technician, String(""));
385  }
386 
387 
388 
389 // *************** Resource ***************
390 // *
391 
401  Resource::Resource(Resource* Parent, RIFF::List* lstResource) {
402  pParent = Parent;
403  pResourceList = lstResource;
404 
405  pInfo = new Info(lstResource);
406 
407  RIFF::Chunk* ckDLSID = lstResource->GetSubChunk(CHUNK_ID_DLID);
408  if (ckDLSID) {
409  pDLSID = new dlsid_t;
410  ckDLSID->Read(&pDLSID->ulData1, 1, 4);
411  ckDLSID->Read(&pDLSID->usData2, 1, 2);
412  ckDLSID->Read(&pDLSID->usData3, 1, 2);
413  ckDLSID->Read(pDLSID->abData, 8, 1);
414  }
415  else pDLSID = NULL;
416  }
417 
419  if (pDLSID) delete pDLSID;
420  if (pInfo) delete pInfo;
421  }
422 
432  pInfo->UpdateChunks();
433 
434  if (pDLSID) {
435  // make sure 'dlid' chunk exists
437  if (!ckDLSID) ckDLSID = pResourceList->AddSubChunk(CHUNK_ID_DLID, 16);
438  uint8_t* pData = (uint8_t*)ckDLSID->LoadChunkData();
439  // update 'dlid' chunk
440  store32(&pData[0], pDLSID->ulData1);
441  store16(&pData[4], pDLSID->usData2);
442  store16(&pData[6], pDLSID->usData3);
443  memcpy(&pData[8], pDLSID->abData, 8);
444  }
445  }
446 
451 #if defined(WIN32) || defined(__APPLE__) || defined(HAVE_UUID_GENERATE)
452 
453  if (!pDLSID) pDLSID = new dlsid_t;
454 
455 #ifdef WIN32
456 
457  UUID uuid;
458  UuidCreate(&uuid);
459  pDLSID->ulData1 = uuid.Data1;
460  pDLSID->usData2 = uuid.Data2;
461  pDLSID->usData3 = uuid.Data3;
462  memcpy(pDLSID->abData, uuid.Data4, 8);
463 
464 #elif defined(__APPLE__)
465 
466  CFUUIDRef uuidRef = CFUUIDCreate(NULL);
467  CFUUIDBytes uuid = CFUUIDGetUUIDBytes(uuidRef);
468  CFRelease(uuidRef);
469  pDLSID->ulData1 = uuid.byte0 | uuid.byte1 << 8 | uuid.byte2 << 16 | uuid.byte3 << 24;
470  pDLSID->usData2 = uuid.byte4 | uuid.byte5 << 8;
471  pDLSID->usData3 = uuid.byte6 | uuid.byte7 << 8;
472  pDLSID->abData[0] = uuid.byte8;
473  pDLSID->abData[1] = uuid.byte9;
474  pDLSID->abData[2] = uuid.byte10;
475  pDLSID->abData[3] = uuid.byte11;
476  pDLSID->abData[4] = uuid.byte12;
477  pDLSID->abData[5] = uuid.byte13;
478  pDLSID->abData[6] = uuid.byte14;
479  pDLSID->abData[7] = uuid.byte15;
480 #else
481  uuid_t uuid;
482  uuid_generate(uuid);
483  pDLSID->ulData1 = uuid[0] | uuid[1] << 8 | uuid[2] << 16 | uuid[3] << 24;
484  pDLSID->usData2 = uuid[4] | uuid[5] << 8;
485  pDLSID->usData3 = uuid[6] | uuid[7] << 8;
486  memcpy(pDLSID->abData, &uuid[8], 8);
487 #endif
488 #endif
489  }
490 
491 
492 // *************** Sampler ***************
493 // *
494 
496  pParentList = ParentList;
497  RIFF::Chunk* wsmp = ParentList->GetSubChunk(CHUNK_ID_WSMP);
498  if (wsmp) {
499  uiHeaderSize = wsmp->ReadUint32();
500  UnityNote = wsmp->ReadUint16();
501  FineTune = wsmp->ReadInt16();
502  Gain = wsmp->ReadInt32();
503  SamplerOptions = wsmp->ReadUint32();
504  SampleLoops = wsmp->ReadUint32();
505  } else { // 'wsmp' chunk missing
506  uiHeaderSize = 20;
507  UnityNote = 60;
508  FineTune = 0; // +- 0 cents
509  Gain = 0; // 0 dB
511  SampleLoops = 0;
512  }
516  if (SampleLoops) {
517  wsmp->SetPos(uiHeaderSize);
518  for (uint32_t i = 0; i < SampleLoops; i++) {
519  wsmp->Read(pSampleLoops + i, 4, 4);
520  if (pSampleLoops[i].Size > sizeof(sample_loop_t)) { // if loop struct was extended
521  wsmp->SetPos(pSampleLoops[i].Size - sizeof(sample_loop_t), RIFF::stream_curpos);
522  }
523  }
524  }
525  }
526 
528  if (pSampleLoops) delete[] pSampleLoops;
529  }
530 
531  void Sampler::SetGain(int32_t gain) {
532  Gain = gain;
533  }
534 
540  // make sure 'wsmp' chunk exists
542  int wsmpSize = uiHeaderSize + SampleLoops * 16;
543  if (!wsmp) {
544  wsmp = pParentList->AddSubChunk(CHUNK_ID_WSMP, wsmpSize);
545  } else if (wsmp->GetSize() != wsmpSize) {
546  wsmp->Resize(wsmpSize);
547  }
548  uint8_t* pData = (uint8_t*) wsmp->LoadChunkData();
549  // update headers size
550  store32(&pData[0], uiHeaderSize);
551  // update respective sampler options bits
556  store16(&pData[4], UnityNote);
557  store16(&pData[6], FineTune);
558  store32(&pData[8], Gain);
559  store32(&pData[12], SamplerOptions);
560  store32(&pData[16], SampleLoops);
561  // update loop definitions
562  for (uint32_t i = 0; i < SampleLoops; i++) {
563  //FIXME: this does not handle extended loop structs correctly
564  store32(&pData[uiHeaderSize + i * 16], pSampleLoops[i].Size);
565  store32(&pData[uiHeaderSize + i * 16 + 4], pSampleLoops[i].LoopType);
566  store32(&pData[uiHeaderSize + i * 16 + 8], pSampleLoops[i].LoopStart);
567  store32(&pData[uiHeaderSize + i * 16 + 12], pSampleLoops[i].LoopLength);
568  }
569  }
570 
577  sample_loop_t* pNewLoops = new sample_loop_t[SampleLoops + 1];
578  // copy old loops array
579  for (int i = 0; i < SampleLoops; i++) {
580  pNewLoops[i] = pSampleLoops[i];
581  }
582  // add the new loop
583  pNewLoops[SampleLoops] = *pLoopDef;
584  // auto correct size field
585  pNewLoops[SampleLoops].Size = sizeof(DLS::sample_loop_t);
586  // free the old array and update the member variables
587  if (SampleLoops) delete[] pSampleLoops;
588  pSampleLoops = pNewLoops;
589  SampleLoops++;
590  }
591 
599  sample_loop_t* pNewLoops = new sample_loop_t[SampleLoops - 1];
600  // copy old loops array (skipping given loop)
601  for (int i = 0, o = 0; i < SampleLoops; i++) {
602  if (&pSampleLoops[i] == pLoopDef) continue;
603  if (o == SampleLoops - 1)
604  throw Exception("Could not delete Sample Loop, because it does not exist");
605  pNewLoops[o] = pSampleLoops[i];
606  o++;
607  }
608  // free the old array and update the member variables
609  if (SampleLoops) delete[] pSampleLoops;
610  pSampleLoops = pNewLoops;
611  SampleLoops--;
612  }
613 
614 
615 
616 // *************** Sample ***************
617 // *
618 
634  Sample::Sample(File* pFile, RIFF::List* waveList, unsigned long WavePoolOffset) : Resource(pFile, waveList) {
635  pWaveList = waveList;
636  ulWavePoolOffset = WavePoolOffset - LIST_HEADER_SIZE;
637  pCkFormat = waveList->GetSubChunk(CHUNK_ID_FMT);
638  pCkData = waveList->GetSubChunk(CHUNK_ID_DATA);
639  if (pCkFormat) {
640  // common fields
646  // PCM format specific
649  FrameSize = (BitDepth / 8) * Channels;
650  } else { // unsupported sample data format
651  BitDepth = 0;
652  FrameSize = 0;
653  }
654  } else { // 'fmt' chunk missing
656  BitDepth = 16;
657  Channels = 1;
658  SamplesPerSecond = 44100;
660  FrameSize = (BitDepth / 8) * Channels;
662  }
664  : 0
665  : 0;
666  }
667 
675  pParent->DeleteSubChunk(pWaveList);
676  }
677 
705  return (pCkData) ? pCkData->LoadChunkData() : NULL;
706  }
707 
715  }
716 
727  unsigned long Sample::GetSize() {
728  if (FormatTag != DLS_WAVE_FORMAT_PCM) return 0;
729  return (pCkData) ? pCkData->GetSize() / FrameSize : 0;
730  }
731 
760  void Sample::Resize(int iNewSize) {
761  if (FormatTag != DLS_WAVE_FORMAT_PCM) throw Exception("Sample's format is not DLS_WAVE_FORMAT_PCM");
762  if (iNewSize < 1) throw Exception("Sample size must be at least one sample point");
763  const int iSizeInBytes = iNewSize * FrameSize;
765  if (pCkData) pCkData->Resize(iSizeInBytes);
766  else pCkData = pWaveList->AddSubChunk(CHUNK_ID_DATA, iSizeInBytes);
767  }
768 
785  unsigned long Sample::SetPos(unsigned long SampleCount, RIFF::stream_whence_t Whence) {
786  if (FormatTag != DLS_WAVE_FORMAT_PCM) return 0; // failed: wave data not PCM format
787  if (!pCkData) throw Exception("No data chunk created for sample yet, call Sample::Resize() to create one");
788  unsigned long orderedBytes = SampleCount * FrameSize;
789  unsigned long result = pCkData->SetPos(orderedBytes, Whence);
790  return (result == orderedBytes) ? SampleCount
791  : result / FrameSize;
792  }
793 
803  unsigned long Sample::Read(void* pBuffer, unsigned long SampleCount) {
804  if (FormatTag != DLS_WAVE_FORMAT_PCM) return 0; // failed: wave data not PCM format
805  return pCkData->Read(pBuffer, SampleCount, FrameSize); // FIXME: channel inversion due to endian correction?
806  }
807 
823  unsigned long Sample::Write(void* pBuffer, unsigned long SampleCount) {
824  if (FormatTag != DLS_WAVE_FORMAT_PCM) return 0; // failed: wave data not PCM format
825  if (GetSize() < SampleCount) throw Exception("Could not write sample data, current sample size to small");
826  return pCkData->Write(pBuffer, SampleCount, FrameSize); // FIXME: channel inversion due to endian correction?
827  }
828 
838  throw Exception("Could not save sample, only PCM format is supported");
839  // we refuse to do anything if not sample wave form was provided yet
840  if (!pCkData)
841  throw Exception("Could not save sample, there is no sample data to save");
842  // update chunks of base class as well
844  // make sure 'fmt' chunk exists
846  if (!pCkFormat) pCkFormat = pWaveList->AddSubChunk(CHUNK_ID_FMT, 16); // assumes PCM format
847  uint8_t* pData = (uint8_t*) pCkFormat->LoadChunkData();
848  // update 'fmt' chunk
849  store16(&pData[0], FormatTag);
850  store16(&pData[2], Channels);
851  store32(&pData[4], SamplesPerSecond);
852  store32(&pData[8], AverageBytesPerSecond);
853  store16(&pData[12], BlockAlign);
854  store16(&pData[14], BitDepth); // assuming PCM format
855  }
856 
857 
858 
859 // *************** Region ***************
860 // *
861 
862  Region::Region(Instrument* pInstrument, RIFF::List* rgnList) : Resource(pInstrument, rgnList), Articulator(rgnList), Sampler(rgnList) {
863  pCkRegion = rgnList;
864 
865  // articulation informations
866  RIFF::Chunk* rgnh = rgnList->GetSubChunk(CHUNK_ID_RGNH);
867  if (rgnh) {
868  rgnh->Read(&KeyRange, 2, 2);
869  rgnh->Read(&VelocityRange, 2, 2);
870  FormatOptionFlags = rgnh->ReadUint16();
871  KeyGroup = rgnh->ReadUint16();
872  // Layer is optional
873  if (rgnh->RemainingBytes() >= sizeof(uint16_t)) {
874  rgnh->Read(&Layer, 1, sizeof(uint16_t));
875  } else Layer = 0;
876  } else { // 'rgnh' chunk is missing
877  KeyRange.low = 0;
878  KeyRange.high = 127;
879  VelocityRange.low = 0;
880  VelocityRange.high = 127;
882  KeyGroup = 0;
883  Layer = 0;
884  }
886 
887  // sample informations
888  RIFF::Chunk* wlnk = rgnList->GetSubChunk(CHUNK_ID_WLNK);
889  if (wlnk) {
891  PhaseGroup = wlnk->ReadUint16();
892  Channel = wlnk->ReadUint32();
893  WavePoolTableIndex = wlnk->ReadUint32();
894  } else { // 'wlnk' chunk is missing
896  PhaseGroup = 0;
897  Channel = 0; // mono
898  WavePoolTableIndex = 0; // first entry in wave pool table
899  }
902 
903  pSample = NULL;
904  }
905 
912  pParent->DeleteSubChunk(pCkRegion);
913  }
914 
916  if (pSample) return pSample;
917  File* file = (File*) GetParent()->GetParent();
918  unsigned long soughtoffset = file->pWavePoolTable[WavePoolTableIndex];
919  Sample* sample = file->GetFirstSample();
920  while (sample) {
921  if (sample->ulWavePoolOffset == soughtoffset) return (pSample = sample);
922  sample = file->GetNextSample();
923  }
924  return NULL;
925  }
926 
932  void Region::SetSample(Sample* pSample) {
933  this->pSample = pSample;
934  WavePoolTableIndex = 0; // we update this offset when we Save()
935  }
936 
944  void Region::SetKeyRange(uint16_t Low, uint16_t High) {
945  KeyRange.low = Low;
946  KeyRange.high = High;
947 
948  // make sure regions are already loaded
949  Instrument* pInstrument = (Instrument*) GetParent();
950  if (!pInstrument->pRegions) pInstrument->LoadRegions();
951  if (!pInstrument->pRegions) return;
952 
953  // find the r which is the first one to the right of this region
954  // at its new position
955  Region* r = NULL;
956  Region* prev_region = NULL;
957  for (
958  Instrument::RegionList::iterator iter = pInstrument->pRegions->begin();
959  iter != pInstrument->pRegions->end(); iter++
960  ) {
961  if ((*iter)->KeyRange.low > this->KeyRange.low) {
962  r = *iter;
963  break;
964  }
965  prev_region = *iter;
966  }
967 
968  // place this region before r if it's not already there
969  if (prev_region != this) pInstrument->MoveRegion(this, r);
970  }
971 
979  // make sure 'rgnh' chunk exists
981  if (!rgnh) rgnh = pCkRegion->AddSubChunk(CHUNK_ID_RGNH, Layer ? 14 : 12);
982  uint8_t* pData = (uint8_t*) rgnh->LoadChunkData();
986  // update 'rgnh' chunk
987  store16(&pData[0], KeyRange.low);
988  store16(&pData[2], KeyRange.high);
989  store16(&pData[4], VelocityRange.low);
990  store16(&pData[6], VelocityRange.high);
991  store16(&pData[8], FormatOptionFlags);
992  store16(&pData[10], KeyGroup);
993  if (rgnh->GetSize() >= 14) store16(&pData[12], Layer);
994 
995  // update chunks of base classes as well (but skip Resource,
996  // as a rgn doesn't seem to have dlid and INFO chunks)
999 
1000  // make sure 'wlnk' chunk exists
1002  if (!wlnk) wlnk = pCkRegion->AddSubChunk(CHUNK_ID_WLNK, 12);
1003  pData = (uint8_t*) wlnk->LoadChunkData();
1010  // get sample's wave pool table index
1011  int index = -1;
1012  File* pFile = (File*) GetParent()->GetParent();
1013  if (pFile->pSamples) {
1014  File::SampleList::iterator iter = pFile->pSamples->begin();
1015  File::SampleList::iterator end = pFile->pSamples->end();
1016  for (int i = 0; iter != end; ++iter, i++) {
1017  if (*iter == pSample) {
1018  index = i;
1019  break;
1020  }
1021  }
1022  }
1023  WavePoolTableIndex = index;
1024  // update 'wlnk' chunk
1025  store16(&pData[0], WaveLinkOptionFlags);
1026  store16(&pData[2], PhaseGroup);
1027  store32(&pData[4], Channel);
1028  store32(&pData[8], WavePoolTableIndex);
1029  }
1030 
1031 
1032 
1033 // *************** Instrument ***************
1034 // *
1035 
1049  Instrument::Instrument(File* pFile, RIFF::List* insList) : Resource(pFile, insList), Articulator(insList) {
1050  pCkInstrument = insList;
1051 
1052  midi_locale_t locale;
1054  if (insh) {
1055  Regions = insh->ReadUint32();
1056  insh->Read(&locale, 2, 4);
1057  } else { // 'insh' chunk missing
1058  Regions = 0;
1059  locale.bank = 0;
1060  locale.instrument = 0;
1061  }
1062 
1063  MIDIProgram = locale.instrument;
1064  IsDrum = locale.bank & DRUM_TYPE_MASK;
1065  MIDIBankCoarse = (uint8_t) MIDI_BANK_COARSE(locale.bank);
1066  MIDIBankFine = (uint8_t) MIDI_BANK_FINE(locale.bank);
1068 
1069  pRegions = NULL;
1070  }
1071 
1073  if (!pRegions) LoadRegions();
1074  if (!pRegions) return NULL;
1075  RegionsIterator = pRegions->begin();
1076  return (RegionsIterator != pRegions->end()) ? *RegionsIterator : NULL;
1077  }
1078 
1080  if (!pRegions) return NULL;
1081  RegionsIterator++;
1082  return (RegionsIterator != pRegions->end()) ? *RegionsIterator : NULL;
1083  }
1084 
1086  if (!pRegions) pRegions = new RegionList;
1088  if (lrgn) {
1089  uint32_t regionCkType = (lrgn->GetSubList(LIST_TYPE_RGN2)) ? LIST_TYPE_RGN2 : LIST_TYPE_RGN; // prefer regions level 2
1090  RIFF::List* rgn = lrgn->GetFirstSubList();
1091  while (rgn) {
1092  if (rgn->GetListType() == regionCkType) {
1093  pRegions->push_back(new Region(this, rgn));
1094  }
1095  rgn = lrgn->GetNextSubList();
1096  }
1097  }
1098  }
1099 
1101  if (!pRegions) LoadRegions();
1103  if (!lrgn) lrgn = pCkInstrument->AddSubList(LIST_TYPE_LRGN);
1104  RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN);
1105  Region* pNewRegion = new Region(this, rgn);
1106  pRegions->push_back(pNewRegion);
1107  Regions = pRegions->size();
1108  return pNewRegion;
1109  }
1110 
1111  void Instrument::MoveRegion(Region* pSrc, Region* pDst) {
1113  lrgn->MoveSubChunk(pSrc->pCkRegion, pDst ? pDst->pCkRegion : 0);
1114 
1115  pRegions->remove(pSrc);
1116  RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pDst);
1117  pRegions->insert(iter, pSrc);
1118  }
1119 
1121  if (!pRegions) return;
1122  RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pRegion);
1123  if (iter == pRegions->end()) return;
1124  pRegions->erase(iter);
1125  Regions = pRegions->size();
1126  delete pRegion;
1127  }
1128 
1136  // first update base classes' chunks
1139  // make sure 'insh' chunk exists
1141  if (!insh) insh = pCkInstrument->AddSubChunk(CHUNK_ID_INSH, 12);
1142  uint8_t* pData = (uint8_t*) insh->LoadChunkData();
1143  // update 'insh' chunk
1144  Regions = (pRegions) ? pRegions->size() : 0;
1145  midi_locale_t locale;
1146  locale.instrument = MIDIProgram;
1148  locale.bank = (IsDrum) ? locale.bank | DRUM_TYPE_MASK : locale.bank & (~DRUM_TYPE_MASK);
1149  MIDIBank = MIDI_BANK_MERGE(MIDIBankCoarse, MIDIBankFine); // just a sync, when we're at it
1150  store32(&pData[0], Regions);
1151  store32(&pData[4], locale.bank);
1152  store32(&pData[8], locale.instrument);
1153  // update Region's chunks
1154  if (!pRegions) return;
1155  RegionList::iterator iter = pRegions->begin();
1156  RegionList::iterator end = pRegions->end();
1157  for (; iter != end; ++iter) {
1158  (*iter)->UpdateChunks();
1159  }
1160  }
1161 
1168  if (pRegions) {
1169  RegionList::iterator iter = pRegions->begin();
1170  RegionList::iterator end = pRegions->end();
1171  while (iter != end) {
1172  delete *iter;
1173  iter++;
1174  }
1175  delete pRegions;
1176  }
1177  // remove instrument's chunks
1179  pParent->DeleteSubChunk(pCkInstrument);
1180  }
1181 
1182 
1183 
1184 // *************** File ***************
1185 // *
1186 
1193  File::File() : Resource(NULL, pRIFF = new RIFF::File(RIFF_TYPE_DLS)) {
1195  pVersion = new version_t;
1196  pVersion->major = 0;
1197  pVersion->minor = 0;
1198  pVersion->release = 0;
1199  pVersion->build = 0;
1200 
1201  Instruments = 0;
1202  WavePoolCount = 0;
1203  pWavePoolTable = NULL;
1204  pWavePoolTableHi = NULL;
1205  WavePoolHeaderSize = 8;
1206 
1207  pSamples = NULL;
1208  pInstruments = NULL;
1209 
1210  b64BitWavePoolOffsets = false;
1211  }
1212 
1222  File::File(RIFF::File* pRIFF) : Resource(NULL, pRIFF) {
1223  if (!pRIFF) throw DLS::Exception("NULL pointer reference to RIFF::File object.");
1224  this->pRIFF = pRIFF;
1225 
1226  RIFF::Chunk* ckVersion = pRIFF->GetSubChunk(CHUNK_ID_VERS);
1227  if (ckVersion) {
1228  pVersion = new version_t;
1229  ckVersion->Read(pVersion, 4, 2);
1230  }
1231  else pVersion = NULL;
1232 
1233  RIFF::Chunk* colh = pRIFF->GetSubChunk(CHUNK_ID_COLH);
1234  if (!colh) throw DLS::Exception("Mandatory chunks in RIFF list chunk not found.");
1235  Instruments = colh->ReadUint32();
1236 
1237  RIFF::Chunk* ptbl = pRIFF->GetSubChunk(CHUNK_ID_PTBL);
1238  if (!ptbl) { // pool table is missing - this is probably an ".art" file
1239  WavePoolCount = 0;
1240  pWavePoolTable = NULL;
1241  pWavePoolTableHi = NULL;
1242  WavePoolHeaderSize = 8;
1243  b64BitWavePoolOffsets = false;
1244  } else {
1245  WavePoolHeaderSize = ptbl->ReadUint32();
1246  WavePoolCount = ptbl->ReadUint32();
1247  pWavePoolTable = new uint32_t[WavePoolCount];
1248  pWavePoolTableHi = new uint32_t[WavePoolCount];
1249  ptbl->SetPos(WavePoolHeaderSize);
1250 
1251  // Check for 64 bit offsets (used in gig v3 files)
1253  if (b64BitWavePoolOffsets) {
1254  for (int i = 0 ; i < WavePoolCount ; i++) {
1255  pWavePoolTableHi[i] = ptbl->ReadUint32();
1256  pWavePoolTable[i] = ptbl->ReadUint32();
1257  if (pWavePoolTable[i] & 0x80000000)
1258  throw DLS::Exception("Files larger than 2 GB not yet supported");
1259  }
1260  } else { // conventional 32 bit offsets
1261  ptbl->Read(pWavePoolTable, WavePoolCount, sizeof(uint32_t));
1262  for (int i = 0 ; i < WavePoolCount ; i++) pWavePoolTableHi[i] = 0;
1263  }
1264  }
1265 
1266  pSamples = NULL;
1267  pInstruments = NULL;
1268  }
1269 
1271  if (pInstruments) {
1272  InstrumentList::iterator iter = pInstruments->begin();
1273  InstrumentList::iterator end = pInstruments->end();
1274  while (iter != end) {
1275  delete *iter;
1276  iter++;
1277  }
1278  delete pInstruments;
1279  }
1280 
1281  if (pSamples) {
1282  SampleList::iterator iter = pSamples->begin();
1283  SampleList::iterator end = pSamples->end();
1284  while (iter != end) {
1285  delete *iter;
1286  iter++;
1287  }
1288  delete pSamples;
1289  }
1290 
1291  if (pWavePoolTable) delete[] pWavePoolTable;
1292  if (pWavePoolTableHi) delete[] pWavePoolTableHi;
1293  if (pVersion) delete pVersion;
1294  for (std::list<RIFF::File*>::iterator i = ExtensionFiles.begin() ; i != ExtensionFiles.end() ; i++)
1295  delete *i;
1296  }
1297 
1299  if (!pSamples) LoadSamples();
1300  if (!pSamples) return NULL;
1301  SamplesIterator = pSamples->begin();
1302  return (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL;
1303  }
1304 
1306  if (!pSamples) return NULL;
1307  SamplesIterator++;
1308  return (SamplesIterator != pSamples->end()) ? *SamplesIterator : NULL;
1309  }
1310 
1312  if (!pSamples) pSamples = new SampleList;
1314  if (wvpl) {
1315  unsigned long wvplFileOffset = wvpl->GetFilePos();
1316  RIFF::List* wave = wvpl->GetFirstSubList();
1317  while (wave) {
1318  if (wave->GetListType() == LIST_TYPE_WAVE) {
1319  unsigned long waveFileOffset = wave->GetFilePos();
1320  pSamples->push_back(new Sample(this, wave, waveFileOffset - wvplFileOffset));
1321  }
1322  wave = wvpl->GetNextSubList();
1323  }
1324  }
1325  else { // Seen a dwpl list chunk instead of a wvpl list chunk in some file (officially not DLS compliant)
1327  if (dwpl) {
1328  unsigned long dwplFileOffset = dwpl->GetFilePos();
1329  RIFF::List* wave = dwpl->GetFirstSubList();
1330  while (wave) {
1331  if (wave->GetListType() == LIST_TYPE_WAVE) {
1332  unsigned long waveFileOffset = wave->GetFilePos();
1333  pSamples->push_back(new Sample(this, wave, waveFileOffset - dwplFileOffset));
1334  }
1335  wave = dwpl->GetNextSubList();
1336  }
1337  }
1338  }
1339  }
1340 
1349  if (!pSamples) LoadSamples();
1352  // create new Sample object and its respective 'wave' list chunk
1353  RIFF::List* wave = wvpl->AddSubList(LIST_TYPE_WAVE);
1354  Sample* pSample = new Sample(this, wave, 0 /*arbitrary value, we update offsets when we save*/);
1355  pSamples->push_back(pSample);
1356  return pSample;
1357  }
1358 
1366  void File::DeleteSample(Sample* pSample) {
1367  if (!pSamples) return;
1368  SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), pSample);
1369  if (iter == pSamples->end()) return;
1370  pSamples->erase(iter);
1371  delete pSample;
1372  }
1373 
1375  if (!pInstruments) LoadInstruments();
1376  if (!pInstruments) return NULL;
1377  InstrumentsIterator = pInstruments->begin();
1378  return (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL;
1379  }
1380 
1382  if (!pInstruments) return NULL;
1384  return (InstrumentsIterator != pInstruments->end()) ? *InstrumentsIterator : NULL;
1385  }
1386 
1389  RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS);
1390  if (lstInstruments) {
1391  RIFF::List* lstInstr = lstInstruments->GetFirstSubList();
1392  while (lstInstr) {
1393  if (lstInstr->GetListType() == LIST_TYPE_INS) {
1394  pInstruments->push_back(new Instrument(this, lstInstr));
1395  }
1396  lstInstr = lstInstruments->GetNextSubList();
1397  }
1398  }
1399  }
1400 
1409  if (!pInstruments) LoadInstruments();
1411  RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS);
1412  RIFF::List* lstInstr = lstInstruments->AddSubList(LIST_TYPE_INS);
1413  Instrument* pInstrument = new Instrument(this, lstInstr);
1414  pInstruments->push_back(pInstrument);
1415  return pInstrument;
1416  }
1417 
1425  void File::DeleteInstrument(Instrument* pInstrument) {
1426  if (!pInstruments) return;
1427  InstrumentList::iterator iter = find(pInstruments->begin(), pInstruments->end(), pInstrument);
1428  if (iter == pInstruments->end()) return;
1429  pInstruments->erase(iter);
1430  delete pInstrument;
1431  }
1432 
1441  // first update base class's chunks
1443 
1444  // if version struct exists, update 'vers' chunk
1445  if (pVersion) {
1446  RIFF::Chunk* ckVersion = pRIFF->GetSubChunk(CHUNK_ID_VERS);
1447  if (!ckVersion) ckVersion = pRIFF->AddSubChunk(CHUNK_ID_VERS, 8);
1448  uint8_t* pData = (uint8_t*) ckVersion->LoadChunkData();
1449  store16(&pData[0], pVersion->minor);
1450  store16(&pData[2], pVersion->major);
1451  store16(&pData[4], pVersion->build);
1452  store16(&pData[6], pVersion->release);
1453  }
1454 
1455  // update 'colh' chunk
1456  Instruments = (pInstruments) ? pInstruments->size() : 0;
1458  if (!colh) colh = pRIFF->AddSubChunk(CHUNK_ID_COLH, 4);
1459  uint8_t* pData = (uint8_t*) colh->LoadChunkData();
1460  store32(pData, Instruments);
1461 
1462  // update instrument's chunks
1463  if (pInstruments) {
1464  InstrumentList::iterator iter = pInstruments->begin();
1465  InstrumentList::iterator end = pInstruments->end();
1466  for (; iter != end; ++iter) {
1467  (*iter)->UpdateChunks();
1468  }
1469  }
1470 
1471  // update 'ptbl' chunk
1472  const int iSamples = (pSamples) ? pSamples->size() : 0;
1473  const int iPtblOffsetSize = (b64BitWavePoolOffsets) ? 8 : 4;
1475  if (!ptbl) ptbl = pRIFF->AddSubChunk(CHUNK_ID_PTBL, 1 /*anything, we'll resize*/);
1476  const int iPtblSize = WavePoolHeaderSize + iPtblOffsetSize * iSamples;
1477  ptbl->Resize(iPtblSize);
1478  pData = (uint8_t*) ptbl->LoadChunkData();
1479  WavePoolCount = iSamples;
1480  store32(&pData[4], WavePoolCount);
1481  // we actually update the sample offsets in the pool table when we Save()
1482  memset(&pData[WavePoolHeaderSize], 0, iPtblSize - WavePoolHeaderSize);
1483 
1484  // update sample's chunks
1485  if (pSamples) {
1486  SampleList::iterator iter = pSamples->begin();
1487  SampleList::iterator end = pSamples->end();
1488  for (; iter != end; ++iter) {
1489  (*iter)->UpdateChunks();
1490  }
1491  }
1492  }
1493 
1507  void File::Save(const String& Path) {
1508  UpdateChunks();
1509  pRIFF->Save(Path);
1510  __UpdateWavePoolTableChunk();
1511  }
1512 
1522  void File::Save() {
1523  UpdateChunks();
1524  pRIFF->Save();
1525  __UpdateWavePoolTableChunk();
1526  }
1527 
1534  // enusre 'lins' list chunk exists (mandatory for instrument definitions)
1535  RIFF::List* lstInstruments = pRIFF->GetSubList(LIST_TYPE_LINS);
1536  if (!lstInstruments) pRIFF->AddSubList(LIST_TYPE_LINS);
1537  // ensure 'ptbl' chunk exists (mandatory for samples)
1539  if (!ptbl) {
1540  const int iOffsetSize = (b64BitWavePoolOffsets) ? 8 : 4;
1541  ptbl = pRIFF->AddSubChunk(CHUNK_ID_PTBL, WavePoolHeaderSize + iOffsetSize);
1542  }
1543  // enusre 'wvpl' list chunk exists (mandatory for samples)
1545  if (!wvpl) pRIFF->AddSubList(LIST_TYPE_WVPL);
1546  }
1547 
1557  void File::__UpdateWavePoolTableChunk() {
1558  __UpdateWavePoolTable();
1560  const int iOffsetSize = (b64BitWavePoolOffsets) ? 8 : 4;
1561  // check if 'ptbl' chunk is large enough
1562  WavePoolCount = (pSamples) ? pSamples->size() : 0;
1563  const unsigned long ulRequiredSize = WavePoolHeaderSize + iOffsetSize * WavePoolCount;
1564  if (ptbl->GetSize() < ulRequiredSize) throw Exception("Fatal error, 'ptbl' chunk too small");
1565  // save the 'ptbl' chunk's current read/write position
1566  unsigned long ulOriginalPos = ptbl->GetPos();
1567  // update headers
1568  ptbl->SetPos(0);
1569  uint32_t tmp = WavePoolHeaderSize;
1570  ptbl->WriteUint32(&tmp);
1571  tmp = WavePoolCount;
1572  ptbl->WriteUint32(&tmp);
1573  // update offsets
1574  ptbl->SetPos(WavePoolHeaderSize);
1575  if (b64BitWavePoolOffsets) {
1576  for (int i = 0 ; i < WavePoolCount ; i++) {
1577  tmp = pWavePoolTableHi[i];
1578  ptbl->WriteUint32(&tmp);
1579  tmp = pWavePoolTable[i];
1580  ptbl->WriteUint32(&tmp);
1581  }
1582  } else { // conventional 32 bit offsets
1583  for (int i = 0 ; i < WavePoolCount ; i++) {
1584  tmp = pWavePoolTable[i];
1585  ptbl->WriteUint32(&tmp);
1586  }
1587  }
1588  // restore 'ptbl' chunk's original read/write position
1589  ptbl->SetPos(ulOriginalPos);
1590  }
1591 
1597  void File::__UpdateWavePoolTable() {
1598  WavePoolCount = (pSamples) ? pSamples->size() : 0;
1599  // resize wave pool table arrays
1600  if (pWavePoolTable) delete[] pWavePoolTable;
1601  if (pWavePoolTableHi) delete[] pWavePoolTableHi;
1602  pWavePoolTable = new uint32_t[WavePoolCount];
1603  pWavePoolTableHi = new uint32_t[WavePoolCount];
1604  if (!pSamples) return;
1605  // update offsets int wave pool table
1607  uint64_t wvplFileOffset = wvpl->GetFilePos();
1608  if (b64BitWavePoolOffsets) {
1609  SampleList::iterator iter = pSamples->begin();
1610  SampleList::iterator end = pSamples->end();
1611  for (int i = 0 ; iter != end ; ++iter, i++) {
1612  uint64_t _64BitOffset = (*iter)->pWaveList->GetFilePos() - wvplFileOffset - LIST_HEADER_SIZE;
1613  (*iter)->ulWavePoolOffset = _64BitOffset;
1614  pWavePoolTableHi[i] = (uint32_t) (_64BitOffset >> 32);
1615  pWavePoolTable[i] = (uint32_t) _64BitOffset;
1616  }
1617  } else { // conventional 32 bit offsets
1618  SampleList::iterator iter = pSamples->begin();
1619  SampleList::iterator end = pSamples->end();
1620  for (int i = 0 ; iter != end ; ++iter, i++) {
1621  uint64_t _64BitOffset = (*iter)->pWaveList->GetFilePos() - wvplFileOffset - LIST_HEADER_SIZE;
1622  (*iter)->ulWavePoolOffset = _64BitOffset;
1623  pWavePoolTable[i] = (uint32_t) _64BitOffset;
1624  }
1625  }
1626  }
1627 
1628 
1629 
1630 // *************** Exception ***************
1631 // *
1632 
1633  Exception::Exception(String Message) : RIFF::Exception(Message) {
1634  }
1635 
1637  std::cout << "DLS::Exception: " << Message << std::endl;
1638  }
1639 
1640 
1641 // *************** functions ***************
1642 // *
1643 
1650  return PACKAGE;
1651  }
1652 
1658  return VERSION;
1659  }
1660 
1661 } // namespace DLS
#define CONN_TRANSFORM_BIPOLAR_CTL_ENCODE(x)
Definition: DLS.cpp:51
unsigned long WriteUint32(uint32_t *pData, unsigned long WordCount=1)
Writes WordCount number of 32 Bit unsigned integer words from the buffer pointed by pData to the chun...
Definition: RIFF.cpp:611
ArticulationList * pArticulations
Definition: DLS.h:292
uint16_t BlockAlign
The block alignment (in bytes) of the waveform data. Playback software needs to process a multiple of...
Definition: DLS.h:392
#define LIST_TYPE_DWPL
Seen on some files instead of a wvpl list chunk.
Definition: DLS.h:75
sample_loop_t * pSampleLoops
Points to the beginning of a sample loop array, or is NULL if there are no loops defined.
Definition: DLS.h:364
virtual void UpdateChunks()
Update chunks with current info values.
Definition: DLS.cpp:331
uint32_t Regions
Reflects the number of Region defintions this Instrument has.
Definition: DLS.h:454
range_t VelocityRange
Definition: DLS.h:421
virtual void UpdateChunks()
Update chunks with current Resource data.
Definition: DLS.cpp:431
bool SourceBipolar
Definition: DLS.h:245
virtual void UpdateChunks()
Apply Instrument with all its Regions to the respective RIFF chunks.
Definition: DLS.cpp:1135
Parses DLS Level 1 and 2 compliant files and provides abstract access to the data.
Definition: DLS.h:482
File()
Constructor.
Definition: DLS.cpp:1193
stream_whence_t
File stream position dependent to these relations.
Definition: RIFF.h:134
uint16_t Layer
Definition: DLS.h:423
unsigned long Read(void *pData, unsigned long WordCount, unsigned long WordSize)
Reads WordCount number of data words with given WordSize and copies it into a buffer pointed by pData...
Definition: RIFF.cpp:280
String CreationDate
<ICRD-ck>. Specifies the date the subject of the file was created. List dates in yyyy-mm-dd format...
Definition: DLS.h:304
Chunk * GetFirstSubChunk()
Returns the first subchunk within the list.
Definition: RIFF.cpp:1023
virtual ~Articulation()
Definition: DLS.cpp:140
#define F_WAVELINK_PHASE_MASTER
Definition: DLS.cpp:59
ArticulationList::iterator ArticulationsIterator
Definition: DLS.h:293
#define LIST_TYPE_WAVE
Definition: DLS.h:76
#define CHUNK_ID_ARTL
Definition: DLS.h:111
virtual void UpdateChunks()
Apply all articulations to the respective RIFF chunks.
Definition: DLS.cpp:221
#define CHUNK_ID_ISBJ
Definition: DLS.h:96
uint32_t GetChunkID()
Chunk ID in unsigned integer representation.
Definition: RIFF.h:157
String Engineer
<IENG-ck>. Stores the name of the engineer who worked on the file. Multiple engineer names are separa...
Definition: DLS.h:311
#define CHUNK_ID_ICMT
Definition: DLS.h:87
virtual void SetKeyRange(uint16_t Low, uint16_t High)
Modifies the key range of this Region and makes sure the respective chunks are in correct order...
Definition: DLS.cpp:944
void __ensureMandatoryChunksExist()
Checks if all (for DLS) mandatory chunks exist, if not they will be created.
Definition: DLS.cpp:1533
String Artists
<IART-ck>. Lists the artist of the original subject of the file.
Definition: DLS.h:308
#define CHUNK_ID_ISRF
Definition: DLS.h:99
#define LIST_TYPE_LART
Definition: DLS.h:80
Sample * GetFirstSample()
Returns a pointer to the first Sample object of the file, NULL otherwise.
Definition: DLS.cpp:1298
Instrument * GetNextInstrument()
Returns a pointer to the next Instrument object of the file, NULL otherwise.
Definition: DLS.cpp:1381
std::string String
Definition: DLS.h:122
Will be thrown whenever a DLS specific error occurs while trying to access a DLS File.
Definition: DLS.h:533
uint32_t HeaderSize
Definition: DLS.h:279
conn_trn_t SourceTransform
Definition: DLS.h:243
Optional information for DLS files, instruments, samples, etc.
Definition: DLS.h:300
uint16_t usData2
Definition: DLS.h:135
unsigned long Read(void *pBuffer, unsigned long SampleCount)
Reads SampleCount number of sample points from the current position into the buffer pointed by pBuffe...
Definition: DLS.cpp:803
uint16_t KeyGroup
Definition: DLS.h:422
#define CONN_TRANSFORM_INVERT_SRC_ENCODE(x)
Definition: DLS.cpp:52
virtual ~Region()
Destructor.
Definition: DLS.cpp:910
Instrument * AddInstrument()
Add a new instrument definition.
Definition: DLS.cpp:1408
#define CHUNK_ID_PTBL
Definition: DLS.h:108
#define LIST_TYPE_WVPL
Definition: DLS.h:74
RIFF::List * pCkRegion
Definition: DLS.h:435
Instrument * GetFirstInstrument()
Returns a pointer to the first Instrument object of the file, NULL otherwise.
Definition: DLS.cpp:1374
String Keywords
<IKEY-ck>. Provides a list of keywords that refer to the file or subject of the file. Keywords are separated with semicolon and blank, e.g., FX; death; murder.
Definition: DLS.h:310
#define DLS_WAVE_FORMAT_PCM
Definition: DLS.h:115
#define CHUNK_ID_ART2
Definition: DLS.h:112
#define CONN_TRANSFORM_DST(x)
Definition: DLS.cpp:40
std::list< Articulation * > ArticulationList
Definition: DLS.h:290
conn_src_t
Connection Sources.
Definition: DLS.h:141
unsigned long SetPos(unsigned long Where, stream_whence_t Whence=stream_start)
Sets the position within the chunk body, thus within the data portion of the chunk (in bytes)...
Definition: RIFF.cpp:199
#define CONN_TRANSFORM_SRC_ENCODE(x)
Definition: DLS.cpp:47
unsigned long GetSize()
Returns sample size.
Definition: DLS.cpp:727
friend class Region
Definition: DLS.h:476
uint32_t * pWavePoolTable
Definition: DLS.h:513
#define CHUNK_ID_IMED
Definition: DLS.h:93
uint32_t WavePoolTableIndex
Definition: DLS.h:436
uint16_t Channels
Number of channels represented in the waveform data, e.g. 1 for mono, 2 for stereo (defaults to 1=mon...
Definition: DLS.h:389
#define CONN_TRANSFORM_BIPOLAR_SRC(x)
Definition: DLS.cpp:41
virtual ~Info()
Definition: DLS.cpp:269
#define LIST_HEADER_SIZE
Definition: RIFF.h:87
RIFF::List * pCkInstrument
Definition: DLS.h:468
uint32_t SamplerOptions
Definition: DLS.h:373
#define CHUNK_ID_ICOP
Definition: DLS.h:88
void GenerateDLSID()
Generates a new DLSID for the resource.
Definition: DLS.cpp:450
#define CHUNK_ID_DATA
Definition: DLS.h:104
String SourceForm
<ISRF-ck>. Identifies the original form of the material that was digitized, such as record...
Definition: DLS.h:316
int16_t FineTune
Definition: DLS.h:359
bool ControlInvert
Definition: DLS.h:248
Sampler(RIFF::List *ParentList)
Definition: DLS.cpp:495
List * GetSubList(uint32_t ListType)
Returns sublist chunk with list type ListType within this chunk list.
Definition: RIFF.cpp:998
void DeleteSubChunk(Chunk *pSubChunk)
Removes a sub chunk.
Definition: RIFF.cpp:1218
Defines Sample Loop Points.
Definition: DLS.h:226
#define LIST_TYPE_RGN2
Definition: DLS.h:83
virtual void UpdateChunks()
Apply articulation connections to the respective RIFF chunks.
Definition: DLS.cpp:148
Region * AddRegion()
Definition: DLS.cpp:1100
uint8_t abData[8]
Definition: DLS.h:137
unsigned long SetPos(unsigned long SampleCount, RIFF::stream_whence_t Whence=RIFF::stream_start)
Sets the position within the sample (in sample points, not in bytes).
Definition: DLS.cpp:785
RIFF::List * pResourceList
Definition: DLS.h:349
virtual ~Sample()
Destructor.
Definition: DLS.cpp:673
void PrintMessage()
Definition: DLS.cpp:1636
virtual void LoadSamples()
Definition: DLS.cpp:1311
bool ControlBipolar
Definition: DLS.h:249
bool NoSampleCompression
Definition: DLS.h:362
uint16_t MIDIBank
Reflects combination of MIDIBankCoarse and MIDIBankFine (bank 1 - bank 16384). Do not change this val...
Definition: DLS.h:450
virtual void SetGain(int32_t gain)
Definition: DLS.cpp:531
#define CONN_TRANSFORM_BIPOLAR_CTL(x)
Definition: DLS.cpp:42
unsigned long RemainingBytes()
Returns the number of bytes left to read in the chunk body.
Definition: RIFF.cpp:231
#define RIFF_TYPE_DLS
Definition: DLS.h:72
List * GetFirstSubList()
Returns the first sublist within the list (that is a subchunk with chunk ID "LIST").
Definition: RIFF.cpp:1057
#define LIST_TYPE_INFO
Definition: DLS.h:73
RIFF::List * pParentList
Definition: DLS.h:371
#define MIDI_BANK_MERGE(coarse, fine)
Definition: DLS.cpp:67
#define MIDI_BANK_FINE(x)
Definition: DLS.cpp:66
#define CHUNK_ID_ICRD
Definition: DLS.h:89
#define CHUNK_ID_IKEY
Definition: DLS.h:92
uint16_t minor
Definition: DLS.h:126
RIFF::List * pParentList
Definition: DLS.h:291
std::list< Sample * > SampleList
Definition: DLS.h:502
virtual void UpdateChunks()
Apply all the DLS file's current instruments, samples and settings to the respective RIFF chunks...
Definition: DLS.cpp:1440
InstrumentList::iterator InstrumentsIterator
Definition: DLS.h:510
uint32_t uiHeaderSize
Definition: DLS.h:372
uint8_t MIDIBankCoarse
Reflects the MIDI Bank number for MIDI Control Change 0 (bank 1 - 128).
Definition: DLS.h:451
#define CHUNK_ID_ISFT
Definition: DLS.h:97
conn_dst_t Destination
Definition: DLS.h:250
uint FrameSize
Reflects the size (in bytes) of one single sample point (only if known sample data format is used...
Definition: DLS.h:395
#define MIDI_BANK_COARSE(x)
Definition: DLS.cpp:65
RIFF::Chunk * pCkFormat
Definition: DLS.h:408
unsigned long ReadUint32(uint32_t *pData, unsigned long WordCount=1)
Reads WordCount number of 32 Bit unsigned integer words and copies it into the buffer pointed by pDat...
Definition: RIFF.cpp:590
Every subject of an DLS file and the file itself can have an unique, computer generated ID...
Definition: DLS.h:133
unsigned long GetPos()
Position within the chunk data body.
Definition: RIFF.h:161
bool MultiChannel
Definition: DLS.h:427
#define F_WAVELINK_MULTICHANNEL
Definition: DLS.cpp:60
uint16_t usData3
Definition: DLS.h:136
Region * GetFirstRegion()
Definition: DLS.cpp:1072
void DeleteSampleLoop(sample_loop_t *pLoopDef)
Deletes an existing sample loop.
Definition: DLS.cpp:598
virtual ~Instrument()
Destructor.
Definition: DLS.cpp:1167
uint16_t low
Low value of range.
Definition: DLS.h:221
void SetByteOrder(endian_t Endian)
Set the byte order to be used when saving.
Definition: RIFF.cpp:1579
#define CONN_TRANSFORM_BIPOLAR_SRC_ENCODE(x)
Definition: DLS.cpp:50
bool b64BitWavePoolOffsets
Definition: DLS.h:515
#define DRUM_TYPE_MASK
Definition: DLS.cpp:55
unsigned long GetSize()
Chunk size in bytes (without header, thus the chunk data body)
Definition: RIFF.h:159
RIFF List Chunk.
Definition: RIFF.h:248
#define CHUNK_ID_WSMP
Definition: DLS.h:109
RIFF::Chunk * pCkData
Definition: DLS.h:407
#define CHUNK_ID_VERS
Definition: DLS.h:101
void SetFixedStringLengths(const string_length_t *lengths)
Forces specific Info fields to be of a fixed length when being saved to a file.
Definition: DLS.cpp:283
RegionList * pRegions
Definition: DLS.h:469
uint16_t FormatTag
Format ID of the waveform data (should be DLS_WAVE_FORMAT_PCM for DLS1 compliant files, this is also the default value if Sample was created with Instrument::AddSample()).
Definition: DLS.h:388
void ReleaseSampleData()
Free sample data from RAM.
Definition: DLS.cpp:713
#define CHUNK_ID_RGNH
Definition: DLS.h:106
Abstract base class which provides mandatory informations about sample players in general...
Definition: DLS.h:356
bool SelfNonExclusive
Definition: DLS.h:424
String libraryName()
Returns the name of this C++ library.
Definition: DLS.cpp:1649
Sample * GetSample()
Definition: DLS.cpp:915
Exception(String Message)
Definition: DLS.cpp:1633
#define CHUNK_ID_WLNK
Definition: DLS.h:107
#define CONN_TRANSFORM_DST_ENCODE(x)
Definition: DLS.cpp:49
conn_trn_t
Connection Transforms.
Definition: DLS.h:212
uint32_t SampleLoops
Reflects the number of sample loops.
Definition: DLS.h:363
conn_trn_t DestinationTransform
Definition: DLS.h:251
Resource * pParent
Definition: DLS.h:348
void Resize(int iNewSize)
Resize sample.
Definition: DLS.cpp:760
SampleList * pSamples
Definition: DLS.h:507
#define CHUNK_ID_FMT
Definition: DLS.h:103
conn_dst_t
Connection Destinations.
Definition: DLS.h:167
bool NoSampleDepthTruncation
Definition: DLS.h:361
String Message
Definition: RIFF.h:344
virtual ~Articulator()
Definition: DLS.cpp:205
void DeleteSample(Sample *pSample)
Delete a sample.
Definition: DLS.cpp:1366
bool SourceInvert
Definition: DLS.h:244
unsigned long ReadInt32(int32_t *pData, unsigned long WordCount=1)
Reads WordCount number of 32 Bit signed integer words and copies it into the buffer pointed by pData...
Definition: RIFF.cpp:553
uint16_t high
High value of range.
Definition: DLS.h:222
virtual void UpdateChunks()
Apply Region settings to the respective RIFF chunks.
Definition: DLS.cpp:978
Articulation * GetFirstArticulation()
Definition: DLS.cpp:174
uint32_t Size
For internal usage only: usually reflects exactly sizeof(sample_loop_t), otherwise if the value is la...
Definition: DLS.h:227
bool PhaseMaster
Definition: DLS.h:425
Chunk * GetSubChunk(uint32_t ChunkID)
Returns subchunk with chunk ID ChunkID within this chunk list.
Definition: RIFF.cpp:979
#define LIST_TYPE_INS
Definition: DLS.h:78
Chunk * GetNextSubChunk()
Returns the next subchunk within the list.
Definition: RIFF.cpp:1039
Info(RIFF::List *list)
Constructor.
Definition: DLS.cpp:242
std::list< Instrument * > InstrumentList
Definition: DLS.h:503
Region(Instrument *pInstrument, RIFF::List *rgnList)
Definition: DLS.cpp:862
#define CHUNK_ID_DLID
Definition: DLS.h:102
unsigned long SamplesTotal
Reflects total number of sample points (only if known sample data format is used, 0 otherwise)...
Definition: DLS.h:394
String Source
<ISRC-ck>. Identifies the name of the person or organization who supplied the original subject of the...
Definition: DLS.h:315
uint16_t BitDepth
Size of each sample per channel (only if known sample data format is used, 0 otherwise).
Definition: DLS.h:393
Ordinary RIFF Chunk.
Definition: RIFF.h:153
uint32_t GetListType()
Returns unsigned integer representation of the list's ID.
Definition: RIFF.h:252
#define CHUNK_ID_ICMS
Definition: DLS.h:86
unsigned long GetFilePos()
Current, actual offset in file.
Definition: RIFF.h:162
uint32_t Scale
Definition: DLS.h:252
uint8_t UnityNote
Definition: DLS.h:358
#define F_WSMP_NO_COMPRESSION
Definition: DLS.cpp:63
virtual ~File()
Definition: DLS.cpp:1270
#define CONN_TRANSFORM_SRC(x)
Definition: DLS.cpp:38
#define LIST_TYPE_RGN
Definition: DLS.h:82
uint32_t MIDIProgram
Specifies the MIDI Program Change Number this Instrument should be assigned to.
Definition: DLS.h:453
String Commissioned
<ICMS-ck>. Lists the name of the person or organization that commissioned the subject of the file...
Definition: DLS.h:317
#define CHUNK_ID_ITCH
Definition: DLS.h:100
unsigned long ReadInt16(int16_t *pData, unsigned long WordCount=1)
Reads WordCount number of 16 Bit signed integer words and copies it into the buffer pointed by pData...
Definition: RIFF.cpp:479
#define F_RGN_OPTION_SELFNONEXCLUSIVE
Definition: DLS.cpp:57
void SetSample(Sample *pSample)
Assign another sample to this Region.
Definition: DLS.cpp:932
unsigned long Write(void *pData, unsigned long WordCount, unsigned long WordSize)
Writes WordCount number of data words with given WordSize from the buffer pointed by pData...
Definition: RIFF.cpp:338
uint32_t ulData1
Definition: DLS.h:134
SampleList::iterator SamplesIterator
Definition: DLS.h:508
List * GetParent()
Returns pointer to the chunk's parent list chunk.
Definition: RIFF.h:158
Articulation * GetNextArticulation()
Definition: DLS.cpp:181
Chunk * AddSubChunk(uint32_t uiChunkID, uint uiBodySize)
Creates a new sub chunk.
Definition: RIFF.cpp:1159
conn_src_t Control
Definition: DLS.h:246
#define CHUNK_ID_IENG
Definition: DLS.h:90
#define CONN_TRANSFORM_INVERT_CTL_ENCODE(x)
Definition: DLS.cpp:53
uint16_t WaveLinkOptionFlags
Definition: DLS.h:439
#define F_WSMP_NO_TRUNCATION
Definition: DLS.cpp:62
#define CONN_TRANSFORM_CTL(x)
Definition: DLS.cpp:39
#define MIDI_BANK_ENCODE(coarse, fine)
Definition: DLS.cpp:68
#define LIST_TYPE_LAR2
Definition: DLS.h:81
#define CONN_TRANSFORM_INVERT_SRC(x)
Definition: DLS.cpp:43
void DeleteInstrument(Instrument *pInstrument)
Delete an instrument.
Definition: DLS.cpp:1425
unsigned long Write(void *pBuffer, unsigned long SampleCount)
Write sample wave data.
Definition: DLS.cpp:823
version_t * pVersion
Points to a version_t structure if the file provided a version number else is set to NULL...
Definition: DLS.h:484
String Technician
<ITCH-ck>. Identifies the technician who sampled the subject file.
Definition: DLS.h:312
Instrument(File *pFile, RIFF::List *insList)
Constructor.
Definition: DLS.cpp:1049
uint16_t major
Definition: DLS.h:127
RegionList::iterator RegionsIterator
Definition: DLS.h:470
#define CHUNK_ID_INSH
Definition: DLS.h:105
void * LoadChunkData()
Load chunk body into RAM.
Definition: RIFF.cpp:736
Region * GetNextRegion()
Definition: DLS.cpp:1079
RIFF::Chunk * pArticulationCk
Definition: DLS.h:278
#define LIST_TYPE_LRGN
Definition: DLS.h:79
#define CHUNK_ID_IGNR
Definition: DLS.h:91
#define CHUNK_ID_IART
Definition: DLS.h:85
uint32_t AverageBytesPerSecond
The average number of bytes per second at which the waveform data should be transferred (Playback sof...
Definition: DLS.h:391
conn_src_t Source
Definition: DLS.h:242
uint8_t MIDIBankFine
Reflects the MIDI Bank number for MIDI Control Change 32 (bank 1 - 128).
Definition: DLS.h:452
uint16_t PhaseGroup
Definition: DLS.h:426
#define CHUNK_ID_COLH
Definition: DLS.h:110
uint32_t Channel
Definition: DLS.h:428
uint32_t WavePoolHeaderSize
Definition: DLS.h:511
RIFF::File * pRIFF
Definition: DLS.h:505
Abstract base class which encapsulates data structures which all DLS resources are able to provide...
Definition: DLS.h:339
RIFF File.
Definition: RIFF.h:295
void Init(conn_block_t *Header)
Definition: DLS.cpp:75
List * AddSubList(uint32_t uiListType)
Creates a new list sub chunk.
Definition: RIFF.cpp:1198
InstrumentList * pInstruments
Definition: DLS.h:509
uint16_t build
Definition: DLS.h:128
virtual void LoadInstruments()
Definition: DLS.cpp:1387
virtual void UpdateChunks()
Apply sample and its settings to the respective RIFF chunks.
Definition: DLS.cpp:836
#define CHUNK_ID_IPRD
Definition: DLS.h:95
String Software
<ISFT-ck>. Identifies the name of the sofware package used to create the file.
Definition: DLS.h:313
#define CONN_TRANSFORM_CTL_ENCODE(x)
Definition: DLS.cpp:48
String ArchivalLocation
<IARL-ck>. Indicates where the subject of the file is stored.
Definition: DLS.h:303
unsigned long ulWavePoolOffset
Definition: DLS.h:409
virtual void Save()
Save changes to same file.
Definition: DLS.cpp:1522
#define CHUNK_ID_INAM
Definition: DLS.h:94
uint16_t release
Definition: DLS.h:129
Encapsulates sample waves used for playback.
Definition: DLS.h:386
Sample * GetNextSample()
Returns a pointer to the next Sample object of the file, NULL otherwise.
Definition: DLS.cpp:1305
void MoveSubChunk(Chunk *pSrc, Chunk *pDst)
Moves a sub chunk.
Definition: RIFF.cpp:1182
String Name
<INAM-ck>. Stores the title of the subject of the file, such as, Seattle From Above.
Definition: DLS.h:302
uint32_t SamplesPerSecond
Sampling rate at which each channel should be played (defaults to 44100 if Sample was created with In...
Definition: DLS.h:390
String Product
<IPRD-ck>. Specifies the name of the title the file was originally intended for, such as World Ruler ...
Definition: DLS.h:306
Sample(File *pFile, RIFF::List *waveList, unsigned long WavePoolOffset)
Constructor.
Definition: DLS.cpp:634
virtual ~Resource()
Definition: DLS.cpp:418
uint32_t WavePoolCount
Definition: DLS.h:512
String Medium
<IMED-ck>. Describes the original subject of the file, such as, record, CD, and so forth...
Definition: DLS.h:314
String Subject
<ISBJ-ck>. Describes the contents of the file.
Definition: DLS.h:318
void LoadArticulations()
Definition: DLS.cpp:187
RIFF::List * pWaveList
Definition: DLS.h:406
virtual void LoadRegions()
Definition: DLS.cpp:1085
virtual void Save()
Save changes to same file.
Definition: RIFF.cpp:1597
unsigned long ReadUint16(uint16_t *pData, unsigned long WordCount=1)
Reads WordCount number of 16 Bit unsigned integer words and copies it into the buffer pointed by pDat...
Definition: RIFF.cpp:516
conn_block_t ToConnBlock()
Definition: DLS.cpp:89
virtual ~Sampler()
Definition: DLS.cpp:527
#define LIST_TYPE_LINS
Definition: DLS.h:77
Resource * GetParent()
Definition: DLS.h:344
#define CHUNK_ID_IARL
Definition: DLS.h:84
void ReleaseChunkData()
Free loaded chunk body from RAM.
Definition: RIFF.cpp:780
void DeleteRegion(Region *pRegion)
Definition: DLS.cpp:1120
Abstract base class for classes that provide articulation information (thus for Instrument and Region...
Definition: DLS.h:283
Connection * pConnections
Points to the beginning of a Connection array.
Definition: DLS.h:271
Sample * pSample
Definition: DLS.h:437
uint32_t Connections
Reflects the number of Connections.
Definition: DLS.h:272
conn_trn_t ControlTransform
Definition: DLS.h:247
range_t KeyRange
Definition: DLS.h:420
#define CHUNK_ID_ISRC
Definition: DLS.h:98
Provides access to the defined connections used for the synthesis model.
Definition: DLS.h:269
#define CONN_TRANSFORM_INVERT_CTL(x)
Definition: DLS.cpp:44
dlsid_t * pDLSID
Points to a dlsid_t structure if the file provided a DLS ID else is NULL.
Definition: DLS.h:342
uint32_t Instruments
Reflects the number of available Instrument objects.
Definition: DLS.h:485
String Genre
<IGNR-ck>. Descirbes the original work, such as, Jazz, Classic, Rock, Techno, Rave, etc.
Definition: DLS.h:309
Provides all neccessary information for the synthesis of a DLS Instrument.
Definition: DLS.h:447
int32_t Gain
Definition: DLS.h:360
Quadtuple version number ("major.minor.release.build").
Definition: DLS.h:125
String Copyright
<ICOP-ck>. Records the copyright information for the file.
Definition: DLS.h:307
Sample * AddSample()
Add a new sample.
Definition: DLS.cpp:1348
Info * pInfo
Points (in any case) to an Info object, providing additional, optional infos and comments.
Definition: DLS.h:341
String libraryVersion()
Returns version of this C++ library.
Definition: DLS.cpp:1657
virtual void UpdateChunks()
Apply all sample player options to the respective RIFF chunk.
Definition: DLS.cpp:539
Defines a connection within the synthesis model.
Definition: DLS.h:240
uint16_t FormatOptionFlags
Definition: DLS.h:438
uint32_t * pWavePoolTableHi
Definition: DLS.h:514
String Comments
<ICMT-ck>. Provides general comments about the file or the subject of the file. Sentences might end w...
Definition: DLS.h:305
void Resize(int iNewSize)
Resize chunk.
Definition: RIFF.cpp:805
Articulator(RIFF::List *ParentList)
Definition: DLS.cpp:169
List * GetNextSubList()
Returns the next sublist (that is a subchunk with chunk ID "LIST") within the list.
Definition: RIFF.cpp:1079
Defines Region information of an Instrument.
Definition: DLS.h:418
std::list< RIFF::File * > ExtensionFiles
Definition: DLS.h:506
Articulation(RIFF::Chunk *artl)
Constructor.
Definition: DLS.cpp:118
bool IsDrum
Indicates if the Instrument is a drum type, as they differ in the synthesis model of DLS from melodic...
Definition: DLS.h:449
std::list< Region * > RegionList
Definition: DLS.h:462
void * LoadSampleData()
Load sample data into RAM.
Definition: DLS.cpp:704
void AddSampleLoop(sample_loop_t *pLoopDef)
Adds a new sample loop with the provided loop definition.
Definition: DLS.cpp:576
Resource(Resource *Parent, RIFF::List *lstResource)
Constructor.
Definition: DLS.cpp:401