/[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 801 by schoenebeck, Wed Nov 9 20:04:11 2005 UTC revision 802 by schoenebeck, Thu Nov 10 19:53:34 2005 UTC
# Line 912  namespace DLS { Line 912  namespace DLS {
912      }      }
913    
914      void Instrument::DeleteRegion(Region* pRegion) {      void Instrument::DeleteRegion(Region* pRegion) {
915            if (!pRegions) return;
916          RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pRegion);          RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pRegion);
917          if (iter == pRegions->end()) return;          if (iter == pRegions->end()) return;
918          pRegions->erase(iter);          pRegions->erase(iter);
# Line 980  namespace DLS { Line 981  namespace DLS {
981       * to add samples, instruments and finally call Save() to actually write       * to add samples, instruments and finally call Save() to actually write
982       * a DLS file.       * a DLS file.
983       */       */
984      File::File() : pRIFF(new RIFF::File(RIFF_TYPE_DLS)), Resource(NULL, pRIFF) {      File::File() : Resource(NULL, pRIFF = new RIFF::File(RIFF_TYPE_DLS)) {
985          pVersion = new version_t;          pVersion = new version_t;
986          pVersion->major   = 0;          pVersion->major   = 0;
987          pVersion->minor   = 0;          pVersion->minor   = 0;
# Line 1145  namespace DLS { Line 1146  namespace DLS {
1146       * @param pSample - sample to delete       * @param pSample - sample to delete
1147       */       */
1148      void File::DeleteSample(Sample* pSample) {      void File::DeleteSample(Sample* pSample) {
1149            if (!pSamples) return;
1150          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), pSample);          SampleList::iterator iter = find(pSamples->begin(), pSamples->end(), pSample);
1151          if (iter == pSamples->end()) return;          if (iter == pSamples->end()) return;
1152          pSamples->erase(iter);          pSamples->erase(iter);
# Line 1203  namespace DLS { Line 1205  namespace DLS {
1205       * @param pInstrument - instrument to delete       * @param pInstrument - instrument to delete
1206       */       */
1207      void File::DeleteInstrument(Instrument* pInstrument) {      void File::DeleteInstrument(Instrument* pInstrument) {
1208            if (!pInstruments) return;
1209          InstrumentList::iterator iter = find(pInstruments->begin(), pInstruments->end(), pInstrument);          InstrumentList::iterator iter = find(pInstruments->begin(), pInstruments->end(), pInstrument);
1210          if (iter == pInstruments->end()) return;          if (iter == pInstruments->end()) return;
1211          pInstruments->erase(iter);          pInstruments->erase(iter);
# Line 1335  namespace DLS { Line 1338  namespace DLS {
1338          RIFF::Chunk* ptbl = pRIFF->GetSubChunk(CHUNK_ID_PTBL);          RIFF::Chunk* ptbl = pRIFF->GetSubChunk(CHUNK_ID_PTBL);
1339          const int iOffsetSize = (b64BitWavePoolOffsets) ? 8 : 4;          const int iOffsetSize = (b64BitWavePoolOffsets) ? 8 : 4;
1340          // check if 'ptbl' chunk is large enough          // check if 'ptbl' chunk is large enough
1341          WavePoolCount = pSamples->size();          WavePoolCount = (pSamples) ? pSamples->size() : 0;
1342          const unsigned long ulRequiredSize = WavePoolHeaderSize + iOffsetSize * WavePoolCount;          const unsigned long ulRequiredSize = WavePoolHeaderSize + iOffsetSize * WavePoolCount;
1343          if (ptbl->GetSize() < ulRequiredSize) throw Exception("Fatal error, 'ptbl' chunk too small");          if (ptbl->GetSize() < ulRequiredSize) throw Exception("Fatal error, 'ptbl' chunk too small");
1344          uint8_t* pData = (uint8_t*) ptbl->LoadChunkData();          uint8_t* pData = (uint8_t*) ptbl->LoadChunkData();
# Line 1360  namespace DLS { Line 1363  namespace DLS {
1363       * exists already.       * exists already.
1364       */       */
1365      void File::__UpdateWavePoolTable() {      void File::__UpdateWavePoolTable() {
1366          WavePoolCount = pSamples->size();          WavePoolCount = (pSamples) ? pSamples->size() : 0;
1367          // resize wave pool table arrays          // resize wave pool table arrays
1368          if (pWavePoolTable)   delete[] pWavePoolTable;          if (pWavePoolTable)   delete[] pWavePoolTable;
1369          if (pWavePoolTableHi) delete[] pWavePoolTableHi;          if (pWavePoolTableHi) delete[] pWavePoolTableHi;
1370          pWavePoolTable   = new uint32_t[WavePoolCount];          pWavePoolTable   = new uint32_t[WavePoolCount];
1371          pWavePoolTableHi = new uint32_t[WavePoolCount];          pWavePoolTableHi = new uint32_t[WavePoolCount];
1372            if (!pSamples) return;
1373          // update offsets int wave pool table          // update offsets int wave pool table
1374          RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL);          RIFF::List* wvpl = pRIFF->GetSubList(LIST_TYPE_WVPL);
1375          uint64_t wvplFileOffset = wvpl->GetFilePos();          uint64_t wvplFileOffset = wvpl->GetFilePos();

Legend:
Removed from v.801  
changed lines
  Added in v.802

  ViewVC Help
Powered by ViewVC