/[svn]/libgig/trunk/src/DLS.cpp
ViewVC logotype

Diff of /libgig/trunk/src/DLS.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2922 by schoenebeck, Wed May 18 18:04:49 2016 UTC revision 3198 by schoenebeck, Sun May 21 12:46:05 2017 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   libgig - C++ cross-platform Gigasampler format file access library    *   *   libgig - C++ cross-platform Gigasampler format file access library    *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003-2016 by Christian Schoenebeck                      *   *   Copyright (C) 2003-2017 by Christian Schoenebeck                      *
6   *                              <cuse@users.sourceforge.net>               *   *                              <cuse@users.sourceforge.net>               *
7   *                                                                         *   *                                                                         *
8   *   This library is free software; you can redistribute it and/or modify  *   *   This library is free software; you can redistribute it and/or modify  *
# Line 996  namespace DLS { Line 996  namespace DLS {
996      Region::Region(Instrument* pInstrument, RIFF::List* rgnList) : Resource(pInstrument, rgnList), Articulator(rgnList), Sampler(rgnList) {      Region::Region(Instrument* pInstrument, RIFF::List* rgnList) : Resource(pInstrument, rgnList), Articulator(rgnList), Sampler(rgnList) {
997          pCkRegion = rgnList;          pCkRegion = rgnList;
998    
999          // articulation informations          // articulation information
1000          RIFF::Chunk* rgnh = rgnList->GetSubChunk(CHUNK_ID_RGNH);          RIFF::Chunk* rgnh = rgnList->GetSubChunk(CHUNK_ID_RGNH);
1001          if (rgnh) {          if (rgnh) {
1002              rgnh->Read(&KeyRange, 2, 2);              rgnh->Read(&KeyRange, 2, 2);
# Line 1018  namespace DLS { Line 1018  namespace DLS {
1018          }          }
1019          SelfNonExclusive = FormatOptionFlags & F_RGN_OPTION_SELFNONEXCLUSIVE;          SelfNonExclusive = FormatOptionFlags & F_RGN_OPTION_SELFNONEXCLUSIVE;
1020    
1021          // sample informations          // sample information
1022          RIFF::Chunk* wlnk = rgnList->GetSubChunk(CHUNK_ID_WLNK);          RIFF::Chunk* wlnk = rgnList->GetSubChunk(CHUNK_ID_WLNK);
1023          if (wlnk) {          if (wlnk) {
1024              WaveLinkOptionFlags = wlnk->ReadUint16();              WaveLinkOptionFlags = wlnk->ReadUint16();
# Line 1277  namespace DLS { Line 1277  namespace DLS {
1277          RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN);          RIFF::List* rgn = lrgn->AddSubList(LIST_TYPE_RGN);
1278          Region* pNewRegion = new Region(this, rgn);          Region* pNewRegion = new Region(this, rgn);
1279          pRegions->push_back(pNewRegion);          pRegions->push_back(pNewRegion);
1280          Regions = pRegions->size();          Regions = (uint32_t) pRegions->size();
1281          return pNewRegion;          return pNewRegion;
1282      }      }
1283    
# Line 1295  namespace DLS { Line 1295  namespace DLS {
1295          RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pRegion);          RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pRegion);
1296          if (iter == pRegions->end()) return;          if (iter == pRegions->end()) return;
1297          pRegions->erase(iter);          pRegions->erase(iter);
1298          Regions = pRegions->size();          Regions = (uint32_t) pRegions->size();
1299          delete pRegion;          delete pRegion;
1300      }      }
1301    
# Line 1315  namespace DLS { Line 1315  namespace DLS {
1315          if (!insh) insh = pCkInstrument->AddSubChunk(CHUNK_ID_INSH, 12);          if (!insh) insh = pCkInstrument->AddSubChunk(CHUNK_ID_INSH, 12);
1316          uint8_t* pData = (uint8_t*) insh->LoadChunkData();          uint8_t* pData = (uint8_t*) insh->LoadChunkData();
1317          // update 'insh' chunk          // update 'insh' chunk
1318          Regions = (pRegions) ? pRegions->size() : 0;          Regions = (pRegions) ? uint32_t(pRegions->size()) : 0;
1319          midi_locale_t locale;          midi_locale_t locale;
1320          locale.instrument = MIDIProgram;          locale.instrument = MIDIProgram;
1321          locale.bank       = MIDI_BANK_ENCODE(MIDIBankCoarse, MIDIBankFine);          locale.bank       = MIDI_BANK_ENCODE(MIDIBankCoarse, MIDIBankFine);
# Line 1711  namespace DLS { Line 1711  namespace DLS {
1711          }          }
1712    
1713          // update 'colh' chunk          // update 'colh' chunk
1714          Instruments = (pInstruments) ? pInstruments->size() : 0;          Instruments = (pInstruments) ? uint32_t(pInstruments->size()) : 0;
1715          RIFF::Chunk* colh = pRIFF->GetSubChunk(CHUNK_ID_COLH);          RIFF::Chunk* colh = pRIFF->GetSubChunk(CHUNK_ID_COLH);
1716          if (!colh)   colh = pRIFF->AddSubChunk(CHUNK_ID_COLH, 4);          if (!colh)   colh = pRIFF->AddSubChunk(CHUNK_ID_COLH, 4);
1717          uint8_t* pData = (uint8_t*) colh->LoadChunkData();          uint8_t* pData = (uint8_t*) colh->LoadChunkData();
# Line 1738  namespace DLS { Line 1738  namespace DLS {
1738          }          }
1739    
1740          // update 'ptbl' chunk          // update 'ptbl' chunk
1741          const int iSamples = (pSamples) ? pSamples->size() : 0;          const int iSamples = (pSamples) ? int(pSamples->size()) : 0;
1742          int iPtblOffsetSize = (b64BitWavePoolOffsets) ? 8 : 4;          int iPtblOffsetSize = (b64BitWavePoolOffsets) ? 8 : 4;
1743          RIFF::Chunk* ptbl = pRIFF->GetSubChunk(CHUNK_ID_PTBL);          RIFF::Chunk* ptbl = pRIFF->GetSubChunk(CHUNK_ID_PTBL);
1744          if (!ptbl)   ptbl = pRIFF->AddSubChunk(CHUNK_ID_PTBL, 1 /*anything, we'll resize*/);          if (!ptbl)   ptbl = pRIFF->AddSubChunk(CHUNK_ID_PTBL, 1 /*anything, we'll resize*/);
# Line 1827  namespace DLS { Line 1827  namespace DLS {
1827       * have at the end of the saving process.       * have at the end of the saving process.
1828       *       *
1829       * @param pProgress - optional: callback function for progress notification       * @param pProgress - optional: callback function for progress notification
1830       * @throws RIFF::Exception if any kind of IO error occured       * @throws RIFF::Exception if any kind of IO error occurred
1831       * @throws DLS::Exception  if any kind of DLS specific error occured       * @throws DLS::Exception  if any kind of DLS specific error occurred
1832       */       */
1833      void File::Save(progress_t* pProgress) {      void File::Save(progress_t* pProgress) {
1834          {          {
# Line 1897  namespace DLS { Line 1897  namespace DLS {
1897          RIFF::Chunk* ptbl = pRIFF->GetSubChunk(CHUNK_ID_PTBL);          RIFF::Chunk* ptbl = pRIFF->GetSubChunk(CHUNK_ID_PTBL);
1898          const int iOffsetSize = (b64BitWavePoolOffsets) ? 8 : 4;          const int iOffsetSize = (b64BitWavePoolOffsets) ? 8 : 4;
1899          // check if 'ptbl' chunk is large enough          // check if 'ptbl' chunk is large enough
1900          WavePoolCount = (pSamples) ? pSamples->size() : 0;          WavePoolCount = (pSamples) ? uint32_t(pSamples->size()) : 0;
1901          const file_offset_t ulRequiredSize = WavePoolHeaderSize + iOffsetSize * WavePoolCount;          const file_offset_t ulRequiredSize = WavePoolHeaderSize + iOffsetSize * WavePoolCount;
1902          if (ptbl->GetSize() < ulRequiredSize) throw Exception("Fatal error, 'ptbl' chunk too small");          if (ptbl->GetSize() < ulRequiredSize) throw Exception("Fatal error, 'ptbl' chunk too small");
1903          // save the 'ptbl' chunk's current read/write position          // save the 'ptbl' chunk's current read/write position
# Line 1933  namespace DLS { Line 1933  namespace DLS {
1933       * exists already.       * exists already.
1934       */       */
1935      void File::__UpdateWavePoolTable() {      void File::__UpdateWavePoolTable() {
1936          WavePoolCount = (pSamples) ? pSamples->size() : 0;          WavePoolCount = (pSamples) ? uint32_t(pSamples->size()) : 0;
1937          // resize wave pool table arrays          // resize wave pool table arrays
1938          if (pWavePoolTable)   delete[] pWavePoolTable;          if (pWavePoolTable)   delete[] pWavePoolTable;
1939          if (pWavePoolTableHi) delete[] pWavePoolTableHi;          if (pWavePoolTableHi) delete[] pWavePoolTableHi;
# Line 1968  namespace DLS { Line 1968  namespace DLS {
1968  // *************** Exception ***************  // *************** Exception ***************
1969  // *  // *
1970    
1971      Exception::Exception(String Message) : RIFF::Exception(Message) {      Exception::Exception() : RIFF::Exception() {
1972        }
1973    
1974        Exception::Exception(String format, ...) : RIFF::Exception() {
1975            va_list arg;
1976            va_start(arg, format);
1977            Message = assemble(format, arg);
1978            va_end(arg);
1979        }
1980    
1981        Exception::Exception(String format, va_list arg) : RIFF::Exception() {
1982            Message = assemble(format, arg);
1983      }      }
1984    
1985      void Exception::PrintMessage() {      void Exception::PrintMessage() {

Legend:
Removed from v.2922  
changed lines
  Added in v.3198

  ViewVC Help
Powered by ViewVC