/[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 1209 by persson, Sun May 27 13:54:24 2007 UTC revision 1388 by persson, Sun Oct 7 11:10:02 2007 UTC
# Line 441  namespace DLS { Line 441  namespace DLS {
441          UUID uuid;          UUID uuid;
442          UuidCreate(&uuid);          UuidCreate(&uuid);
443          pDLSID->ulData1 = uuid.Data1;          pDLSID->ulData1 = uuid.Data1;
444          pDLSID->usData1 = uuid.Data2;          pDLSID->usData2 = uuid.Data2;
445          pDLSID->usData2 = uuid.Data3;          pDLSID->usData3 = uuid.Data3;
446          memcpy(pDLSID->abData, uuid.Data4, 8);          memcpy(pDLSID->abData, uuid.Data4, 8);
447    
448  #elif defined(__APPLE__)  #elif defined(__APPLE__)
# Line 487  namespace DLS { Line 487  namespace DLS {
487              SamplerOptions = wsmp->ReadUint32();              SamplerOptions = wsmp->ReadUint32();
488              SampleLoops    = wsmp->ReadUint32();              SampleLoops    = wsmp->ReadUint32();
489          } else { // 'wsmp' chunk missing          } else { // 'wsmp' chunk missing
490              uiHeaderSize   = 0;              uiHeaderSize   = 20;
491              UnityNote      = 64;              UnityNote      = 60;
492              FineTune       = 0; // +- 0 cents              FineTune       = 0; // +- 0 cents
493              Gain           = 0; // 0 dB              Gain           = 0; // 0 dB
494              SamplerOptions = F_WSMP_NO_COMPRESSION;              SamplerOptions = F_WSMP_NO_COMPRESSION;
# Line 512  namespace DLS { Line 512  namespace DLS {
512          if (pSampleLoops) delete[] pSampleLoops;          if (pSampleLoops) delete[] pSampleLoops;
513      }      }
514    
515        void Sampler::SetGain(int32_t gain) {
516            Gain = gain;
517        }
518    
519      /**      /**
520       * Apply all sample player options to the respective RIFF chunk. You       * Apply all sample player options to the respective RIFF chunk. You
521       * have to call File::Save() to make changes persistent.       * have to call File::Save() to make changes persistent.
# Line 519  namespace DLS { Line 523  namespace DLS {
523      void Sampler::UpdateChunks() {      void Sampler::UpdateChunks() {
524          // make sure 'wsmp' chunk exists          // make sure 'wsmp' chunk exists
525          RIFF::Chunk* wsmp = pParentList->GetSubChunk(CHUNK_ID_WSMP);          RIFF::Chunk* wsmp = pParentList->GetSubChunk(CHUNK_ID_WSMP);
526            int wsmpSize = uiHeaderSize + SampleLoops * 16;
527          if (!wsmp) {          if (!wsmp) {
528              uiHeaderSize = 20;              wsmp = pParentList->AddSubChunk(CHUNK_ID_WSMP, wsmpSize);
529              wsmp = pParentList->AddSubChunk(CHUNK_ID_WSMP, uiHeaderSize + SampleLoops * 16);          } else if (wsmp->GetSize() != wsmpSize) {
530                wsmp->Resize(wsmpSize);
531          }          }
532          uint8_t* pData = (uint8_t*) wsmp->LoadChunkData();          uint8_t* pData = (uint8_t*) wsmp->LoadChunkData();
533          // update headers size          // update headers size
# Line 913  namespace DLS { Line 919  namespace DLS {
919      }      }
920    
921      /**      /**
922         * Modifies the key range of this Region and makes sure the respective
923         * chunks are in correct order.
924         *
925         * @param Low  - lower end of key range
926         * @param High - upper end of key range
927         */
928        void Region::SetKeyRange(uint16_t Low, uint16_t High) {
929            KeyRange.low  = Low;
930            KeyRange.high = High;
931    
932            // make sure regions are already loaded
933            Instrument* pInstrument = (Instrument*) GetParent();
934            if (!pInstrument->pRegions) pInstrument->LoadRegions();
935            if (!pInstrument->pRegions) return;
936    
937            // find the r which is the first one to the right of this region
938            // at its new position
939            Region* r = NULL;
940            Region* prev_region = NULL;
941            for (
942                Instrument::RegionList::iterator iter = pInstrument->pRegions->begin();
943                iter != pInstrument->pRegions->end(); iter++
944            ) {
945                if ((*iter)->KeyRange.low > this->KeyRange.low) {
946                    r = *iter;
947                    break;
948                }
949                prev_region = *iter;
950            }
951    
952            // place this region before r if it's not already there
953            if (prev_region != this) pInstrument->MoveRegion(this, r);
954        }
955    
956        /**
957       * Apply Region settings to the respective RIFF chunks. You have to       * Apply Region settings to the respective RIFF chunks. You have to
958       * call File::Save() to make changes persistent.       * call File::Save() to make changes persistent.
959       *       *
# Line 963  namespace DLS { Line 1004  namespace DLS {
1004                  }                  }
1005              }              }
1006          }          }
         if (index < 0) throw Exception("Could not save Region, could not find Region's sample");  
1007          WavePoolTableIndex = index;          WavePoolTableIndex = index;
1008          // update 'wlnk' chunk          // update 'wlnk' chunk
1009          store16(&pData[0], WaveLinkOptionFlags);          store16(&pData[0], WaveLinkOptionFlags);

Legend:
Removed from v.1209  
changed lines
  Added in v.1388

  ViewVC Help
Powered by ViewVC