/[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 1184 by persson, Sun May 13 13:24:22 2007 UTC revision 2609 by schoenebeck, Sun Jun 8 19:00:30 2014 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-2007 by Christian Schoenebeck                      *   *   Copyright (C) 2003-2013 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 23  Line 23 
23    
24  #include "DLS.h"  #include "DLS.h"
25    
26    #include <algorithm>
27  #include <time.h>  #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"  #include "helper.h"
36    
37  // macros to decode connection transforms  // macros to decode connection transforms
# Line 220  namespace DLS { Line 227  namespace DLS {
227              }              }
228          }          }
229      }      }
230        
231        /**
232         * Not yet implemented in this version, since the .gig format does
233         * not need to copy DLS articulators and so far nobody used pure
234         * DLS instrument AFAIK.
235         */
236        void Articulator::CopyAssign(const Articulator* orig) {
237            //TODO: implement deep copy assignment for this class
238        }
239    
240    
241    
# Line 233  namespace DLS { Line 249  namespace DLS {
249       * @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
250       */       */
251      Info::Info(RIFF::List* list) {      Info::Info(RIFF::List* list) {
252          FixedStringLengths = NULL;          pFixedStringLengths = NULL;
253          pResourceListChunk = list;          pResourceListChunk = list;
254          if (list) {          if (list) {
255              RIFF::List* lstINFO = list->GetSubList(LIST_TYPE_INFO);              RIFF::List* lstINFO = list->GetSubList(LIST_TYPE_INFO);
# Line 262  namespace DLS { Line 278  namespace DLS {
278      Info::~Info() {      Info::~Info() {
279      }      }
280    
281        /**
282         * Forces specific Info fields to be of a fixed length when being saved
283         * to a file. By default the respective RIFF chunk of an Info field
284         * will have a size analogue to its actual string length. With this
285         * method however this behavior can be overridden, allowing to force an
286         * arbitrary fixed size individually for each Info field.
287         *
288         * This method is used as a workaround for the gig format, not for DLS.
289         *
290         * @param lengths - NULL terminated array of string_length_t elements
291         */
292        void Info::SetFixedStringLengths(const string_length_t* lengths) {
293            pFixedStringLengths = lengths;
294        }
295    
296      /** @brief Load given INFO field.      /** @brief Load given INFO field.
297       *       *
298       * 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
# Line 289  namespace DLS { Line 320  namespace DLS {
320       */       */
321      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) {
322          int size = 0;          int size = 0;
323          if (FixedStringLengths) {          if (pFixedStringLengths) {
324              for (int i = 0 ; FixedStringLengths[i].length ; i++) {              for (int i = 0 ; pFixedStringLengths[i].length ; i++) {
325                  if (FixedStringLengths[i].chunkId == ChunkID) {                  if (pFixedStringLengths[i].chunkId == ChunkID) {
326                      size = FixedStringLengths[i].length;                      size = pFixedStringLengths[i].length;
327                        break;
328                  }                  }
329              }              }
330          }          }
# Line 360  namespace DLS { Line 392  namespace DLS {
392          SaveString(CHUNK_ID_ISRF, lstINFO, SourceForm, String(""));          SaveString(CHUNK_ID_ISRF, lstINFO, SourceForm, String(""));
393          SaveString(CHUNK_ID_ITCH, lstINFO, Technician, String(""));          SaveString(CHUNK_ID_ITCH, lstINFO, Technician, String(""));
394      }      }
395        
396        /**
397         * Make a deep copy of the Info object given by @a orig and assign it to
398         * this object.
399         *
400         * @param orig - original Info object to be copied from
401         */
402        void Info::CopyAssign(const Info* orig) {
403            Name = orig->Name;
404            ArchivalLocation = orig->ArchivalLocation;
405            CreationDate = orig->CreationDate;
406            Comments = orig->Comments;
407            Product = orig->Product;
408            Copyright = orig->Copyright;
409            Artists = orig->Artists;
410            Genre = orig->Genre;
411            Keywords = orig->Keywords;
412            Engineer = orig->Engineer;
413            Technician = orig->Technician;
414            Software = orig->Software;
415            Medium = orig->Medium;
416            Source = orig->Source;
417            SourceForm = orig->SourceForm;
418            Commissioned = orig->Commissioned;
419            Subject = orig->Subject;
420            //FIXME: hmm, is copying this pointer a good idea?
421            pFixedStringLengths = orig->pFixedStringLengths;
422        }
423    
424    
425    
# Line 407  namespace DLS { Line 467  namespace DLS {
467       */       */
468      void Resource::UpdateChunks() {      void Resource::UpdateChunks() {
469          pInfo->UpdateChunks();          pInfo->UpdateChunks();
470          //TODO: save DLSID  
471            if (pDLSID) {
472                // make sure 'dlid' chunk exists
473                RIFF::Chunk* ckDLSID = pResourceList->GetSubChunk(CHUNK_ID_DLID);
474                if (!ckDLSID) ckDLSID = pResourceList->AddSubChunk(CHUNK_ID_DLID, 16);
475                uint8_t* pData = (uint8_t*)ckDLSID->LoadChunkData();
476                // update 'dlid' chunk
477                store32(&pData[0], pDLSID->ulData1);
478                store16(&pData[4], pDLSID->usData2);
479                store16(&pData[6], pDLSID->usData3);
480                memcpy(&pData[8], pDLSID->abData, 8);
481            }
482      }      }
483    
484        /**
485         * Generates a new DLSID for the resource.
486         */
487        void Resource::GenerateDLSID() {
488    #if defined(WIN32) || defined(__APPLE__) || defined(HAVE_UUID_GENERATE)
489    
490            if (!pDLSID) pDLSID = new dlsid_t;
491    
492    #ifdef WIN32
493    
494            UUID uuid;
495            UuidCreate(&uuid);
496            pDLSID->ulData1 = uuid.Data1;
497            pDLSID->usData2 = uuid.Data2;
498            pDLSID->usData3 = uuid.Data3;
499            memcpy(pDLSID->abData, uuid.Data4, 8);
500    
501    #elif defined(__APPLE__)
502    
503            CFUUIDRef uuidRef = CFUUIDCreate(NULL);
504            CFUUIDBytes uuid = CFUUIDGetUUIDBytes(uuidRef);
505            CFRelease(uuidRef);
506            pDLSID->ulData1 = uuid.byte0 | uuid.byte1 << 8 | uuid.byte2 << 16 | uuid.byte3 << 24;
507            pDLSID->usData2 = uuid.byte4 | uuid.byte5 << 8;
508            pDLSID->usData3 = uuid.byte6 | uuid.byte7 << 8;
509            pDLSID->abData[0] = uuid.byte8;
510            pDLSID->abData[1] = uuid.byte9;
511            pDLSID->abData[2] = uuid.byte10;
512            pDLSID->abData[3] = uuid.byte11;
513            pDLSID->abData[4] = uuid.byte12;
514            pDLSID->abData[5] = uuid.byte13;
515            pDLSID->abData[6] = uuid.byte14;
516            pDLSID->abData[7] = uuid.byte15;
517    #else
518            uuid_t uuid;
519            uuid_generate(uuid);
520            pDLSID->ulData1 = uuid[0] | uuid[1] << 8 | uuid[2] << 16 | uuid[3] << 24;
521            pDLSID->usData2 = uuid[4] | uuid[5] << 8;
522            pDLSID->usData3 = uuid[6] | uuid[7] << 8;
523            memcpy(pDLSID->abData, &uuid[8], 8);
524    #endif
525    #endif
526        }
527        
528        /**
529         * Make a deep copy of the Resource object given by @a orig and assign it
530         * to this object.
531         *
532         * @param orig - original Resource object to be copied from
533         */
534        void Resource::CopyAssign(const Resource* orig) {
535            pInfo->CopyAssign(orig->pInfo);
536        }
537    
538    
539  // *************** Sampler ***************  // *************** Sampler ***************
# Line 426  namespace DLS { Line 550  namespace DLS {
550              SamplerOptions = wsmp->ReadUint32();              SamplerOptions = wsmp->ReadUint32();
551              SampleLoops    = wsmp->ReadUint32();              SampleLoops    = wsmp->ReadUint32();
552          } else { // 'wsmp' chunk missing          } else { // 'wsmp' chunk missing
553              uiHeaderSize   = 0;              uiHeaderSize   = 20;
554              UnityNote      = 64;              UnityNote      = 60;
555              FineTune       = 0; // +- 0 cents              FineTune       = 0; // +- 0 cents
556              Gain           = 0; // 0 dB              Gain           = 0; // 0 dB
557              SamplerOptions = F_WSMP_NO_COMPRESSION;              SamplerOptions = F_WSMP_NO_COMPRESSION;
# Line 451  namespace DLS { Line 575  namespace DLS {
575          if (pSampleLoops) delete[] pSampleLoops;          if (pSampleLoops) delete[] pSampleLoops;
576      }      }
577    
578        void Sampler::SetGain(int32_t gain) {
579            Gain = gain;
580        }
581    
582      /**      /**
583       * Apply all sample player options to the respective RIFF chunk. You       * Apply all sample player options to the respective RIFF chunk. You
584       * have to call File::Save() to make changes persistent.       * have to call File::Save() to make changes persistent.
# Line 458  namespace DLS { Line 586  namespace DLS {
586      void Sampler::UpdateChunks() {      void Sampler::UpdateChunks() {
587          // make sure 'wsmp' chunk exists          // make sure 'wsmp' chunk exists
588          RIFF::Chunk* wsmp = pParentList->GetSubChunk(CHUNK_ID_WSMP);          RIFF::Chunk* wsmp = pParentList->GetSubChunk(CHUNK_ID_WSMP);
589            int wsmpSize = uiHeaderSize + SampleLoops * 16;
590          if (!wsmp) {          if (!wsmp) {
591              uiHeaderSize = 20;              wsmp = pParentList->AddSubChunk(CHUNK_ID_WSMP, wsmpSize);
592              wsmp = pParentList->AddSubChunk(CHUNK_ID_WSMP, uiHeaderSize + SampleLoops * 16);          } else if (wsmp->GetSize() != wsmpSize) {
593                wsmp->Resize(wsmpSize);
594          }          }
595          uint8_t* pData = (uint8_t*) wsmp->LoadChunkData();          uint8_t* pData = (uint8_t*) wsmp->LoadChunkData();
596          // update headers size          // update headers size
# Line 488  namespace DLS { Line 618  namespace DLS {
618      /**      /**
619       * Adds a new sample loop with the provided loop definition.       * Adds a new sample loop with the provided loop definition.
620       *       *
621       * @param - points to a loop definition that is to be copied       * @param pLoopDef - points to a loop definition that is to be copied
622       */       */
623      void Sampler::AddSampleLoop(sample_loop_t* pLoopDef) {      void Sampler::AddSampleLoop(sample_loop_t* pLoopDef) {
624          sample_loop_t* pNewLoops = new sample_loop_t[SampleLoops + 1];          sample_loop_t* pNewLoops = new sample_loop_t[SampleLoops + 1];
# Line 517  namespace DLS { Line 647  namespace DLS {
647          // copy old loops array (skipping given loop)          // copy old loops array (skipping given loop)
648          for (int i = 0, o = 0; i < SampleLoops; i++) {          for (int i = 0, o = 0; i < SampleLoops; i++) {
649              if (&pSampleLoops[i] == pLoopDef) continue;              if (&pSampleLoops[i] == pLoopDef) continue;
650              if (o == SampleLoops - 1)              if (o == SampleLoops - 1) {
651                    delete[] pNewLoops;
652                  throw Exception("Could not delete Sample Loop, because it does not exist");                  throw Exception("Could not delete Sample Loop, because it does not exist");
653                }
654              pNewLoops[o] = pSampleLoops[i];              pNewLoops[o] = pSampleLoops[i];
655              o++;              o++;
656          }          }
# Line 527  namespace DLS { Line 659  namespace DLS {
659          pSampleLoops = pNewLoops;          pSampleLoops = pNewLoops;
660          SampleLoops--;          SampleLoops--;
661      }      }
662        
663        /**
664         * Make a deep copy of the Sampler object given by @a orig and assign it
665         * to this object.
666         *
667         * @param orig - original Sampler object to be copied from
668         */
669        void Sampler::CopyAssign(const Sampler* orig) {
670            // copy trivial scalars
671            UnityNote = orig->UnityNote;
672            FineTune = orig->FineTune;
673            Gain = orig->Gain;
674            NoSampleDepthTruncation = orig->NoSampleDepthTruncation;
675            NoSampleCompression = orig->NoSampleCompression;
676            SamplerOptions = orig->SamplerOptions;
677            
678            // copy sample loops
679            if (SampleLoops) delete[] pSampleLoops;
680            pSampleLoops = new sample_loop_t[orig->SampleLoops];
681            memcpy(pSampleLoops, orig->pSampleLoops, orig->SampleLoops * sizeof(sample_loop_t));
682            SampleLoops = orig->SampleLoops;
683        }
684    
685    
686  // *************** Sample ***************  // *************** Sample ***************
# Line 591  namespace DLS { Line 744  namespace DLS {
744          RIFF::List* pParent = pWaveList->GetParent();          RIFF::List* pParent = pWaveList->GetParent();
745          pParent->DeleteSubChunk(pWaveList);          pParent->DeleteSubChunk(pWaveList);
746      }      }
747        
748        /**
749         * Make a deep copy of the Sample object given by @a orig (without the
750         * actual sample waveform data however) and assign it to this object.
751         *
752         * This is a special internal variant of CopyAssign() which only copies the
753         * most mandatory member variables. It will be called by gig::Sample
754         * descendent instead of CopyAssign() since gig::Sample has its own
755         * implementation to access and copy the actual sample waveform data.
756         *
757         * @param orig - original Sample object to be copied from
758         */
759        void Sample::CopyAssignCore(const Sample* orig) {
760            // handle base classes
761            Resource::CopyAssign(orig);
762            // handle actual own attributes of this class
763            FormatTag = orig->FormatTag;
764            Channels = orig->Channels;
765            SamplesPerSecond = orig->SamplesPerSecond;
766            AverageBytesPerSecond = orig->AverageBytesPerSecond;
767            BlockAlign = orig->BlockAlign;
768            BitDepth = orig->BitDepth;
769            SamplesTotal = orig->SamplesTotal;
770            FrameSize = orig->FrameSize;
771        }
772        
773        /**
774         * Make a deep copy of the Sample object given by @a orig and assign it to
775         * this object.
776         *
777         * @param orig - original Sample object to be copied from
778         */
779        void Sample::CopyAssign(const Sample* orig) {
780            CopyAssignCore(orig);
781            
782            // copy sample waveform data (reading directly from disc)
783            Resize(orig->GetSize());
784            char* buf = (char*) LoadSampleData();
785            Sample* pOrig = (Sample*) orig; //HACK: circumventing the constness here for now
786            const unsigned long restorePos = pOrig->pCkData->GetPos();
787            pOrig->SetPos(0);
788            for (unsigned long todo = pOrig->GetSize(), i = 0; todo; ) {
789                const int iReadAtOnce = 64*1024;
790                unsigned long n = (iReadAtOnce < todo) ? iReadAtOnce : todo;
791                n = pOrig->Read(&buf[i], n);
792                if (!n) break;
793                todo -= n;
794                i += (n * pOrig->FrameSize);
795            }
796            pOrig->pCkData->SetPos(restorePos);
797        }
798    
799      /** @brief Load sample data into RAM.      /** @brief Load sample data into RAM.
800       *       *
# Line 641  namespace DLS { Line 845  namespace DLS {
845       * @returns number of sample points or 0 if FormatTag != DLS_WAVE_FORMAT_PCM       * @returns number of sample points or 0 if FormatTag != DLS_WAVE_FORMAT_PCM
846       * @see FrameSize, FormatTag       * @see FrameSize, FormatTag
847       */       */
848      unsigned long Sample::GetSize() {      unsigned long Sample::GetSize() const {
849          if (FormatTag != DLS_WAVE_FORMAT_PCM) return 0;          if (FormatTag != DLS_WAVE_FORMAT_PCM) return 0;
850          return (pCkData) ? pCkData->GetSize() / FrameSize : 0;          return (pCkData) ? pCkData->GetSize() / FrameSize : 0;
851      }      }
# Line 852  namespace DLS { Line 1056  namespace DLS {
1056      }      }
1057    
1058      /**      /**
1059         * Modifies the key range of this Region and makes sure the respective
1060         * chunks are in correct order.
1061         *
1062         * @param Low  - lower end of key range
1063         * @param High - upper end of key range
1064         */
1065        void Region::SetKeyRange(uint16_t Low, uint16_t High) {
1066            KeyRange.low  = Low;
1067            KeyRange.high = High;
1068    
1069            // make sure regions are already loaded
1070            Instrument* pInstrument = (Instrument*) GetParent();
1071            if (!pInstrument->pRegions) pInstrument->LoadRegions();
1072            if (!pInstrument->pRegions) return;
1073    
1074            // find the r which is the first one to the right of this region
1075            // at its new position
1076            Region* r = NULL;
1077            Region* prev_region = NULL;
1078            for (
1079                Instrument::RegionList::iterator iter = pInstrument->pRegions->begin();
1080                iter != pInstrument->pRegions->end(); iter++
1081            ) {
1082                if ((*iter)->KeyRange.low > this->KeyRange.low) {
1083                    r = *iter;
1084                    break;
1085                }
1086                prev_region = *iter;
1087            }
1088    
1089            // place this region before r if it's not already there
1090            if (prev_region != this) pInstrument->MoveRegion(this, r);
1091        }
1092    
1093        /**
1094       * Apply Region settings to the respective RIFF chunks. You have to       * Apply Region settings to the respective RIFF chunks. You have to
1095       * call File::Save() to make changes persistent.       * call File::Save() to make changes persistent.
1096       *       *
# Line 902  namespace DLS { Line 1141  namespace DLS {
1141                  }                  }
1142              }              }
1143          }          }
         if (index < 0) throw Exception("Could not save Region, could not find Region's sample");  
1144          WavePoolTableIndex = index;          WavePoolTableIndex = index;
1145          // update 'wlnk' chunk          // update 'wlnk' chunk
1146          store16(&pData[0], WaveLinkOptionFlags);          store16(&pData[0], WaveLinkOptionFlags);
# Line 910  namespace DLS { Line 1148  namespace DLS {
1148          store32(&pData[4], Channel);          store32(&pData[4], Channel);
1149          store32(&pData[8], WavePoolTableIndex);          store32(&pData[8], WavePoolTableIndex);
1150      }      }
1151        
1152        /**
1153         * Make a (semi) deep copy of the Region object given by @a orig and assign
1154         * it to this object.
1155         *
1156         * Note that the sample pointer referenced by @a orig is simply copied as
1157         * memory address. Thus the respective sample is shared, not duplicated!
1158         *
1159         * @param orig - original Region object to be copied from
1160         */
1161        void Region::CopyAssign(const Region* orig) {
1162            // handle base classes
1163            Resource::CopyAssign(orig);
1164            Articulator::CopyAssign(orig);
1165            Sampler::CopyAssign(orig);
1166            // handle actual own attributes of this class
1167            // (the trivial ones)
1168            VelocityRange = orig->VelocityRange;
1169            KeyGroup = orig->KeyGroup;
1170            Layer = orig->Layer;
1171            SelfNonExclusive = orig->SelfNonExclusive;
1172            PhaseMaster = orig->PhaseMaster;
1173            PhaseGroup = orig->PhaseGroup;
1174            MultiChannel = orig->MultiChannel;
1175            Channel = orig->Channel;
1176            // only take the raw sample reference if the two Region objects are
1177            // part of the same file
1178            if (GetParent()->GetParent() == orig->GetParent()->GetParent()) {
1179                WavePoolTableIndex = orig->WavePoolTableIndex;
1180                pSample = orig->pSample;
1181            } else {
1182                WavePoolTableIndex = -1;
1183                pSample = NULL;
1184            }
1185            FormatOptionFlags = orig->FormatOptionFlags;
1186            WaveLinkOptionFlags = orig->WaveLinkOptionFlags;
1187            // handle the last, a bit sensible attribute
1188            SetKeyRange(orig->KeyRange.low, orig->KeyRange.high);
1189        }
1190    
1191    
1192  // *************** Instrument ***************  // *************** Instrument ***************
# Line 1061  namespace DLS { Line 1337  namespace DLS {
1337          RIFF::List* pParent = pCkInstrument->GetParent();          RIFF::List* pParent = pCkInstrument->GetParent();
1338          pParent->DeleteSubChunk(pCkInstrument);          pParent->DeleteSubChunk(pCkInstrument);
1339      }      }
1340        
1341        void Instrument::CopyAssignCore(const Instrument* orig) {
1342            // handle base classes
1343            Resource::CopyAssign(orig);
1344            Articulator::CopyAssign(orig);
1345            // handle actual own attributes of this class
1346            // (the trivial ones)
1347            IsDrum = orig->IsDrum;
1348            MIDIBank = orig->MIDIBank;
1349            MIDIBankCoarse = orig->MIDIBankCoarse;
1350            MIDIBankFine = orig->MIDIBankFine;
1351            MIDIProgram = orig->MIDIProgram;
1352        }
1353        
1354        /**
1355         * Make a (semi) deep copy of the Instrument object given by @a orig and assign
1356         * it to this object.
1357         *
1358         * Note that all sample pointers referenced by @a orig are simply copied as
1359         * memory address. Thus the respective samples are shared, not duplicated!
1360         *
1361         * @param orig - original Instrument object to be copied from
1362         */
1363        void Instrument::CopyAssign(const Instrument* orig) {
1364            CopyAssignCore(orig);
1365            // delete all regions first
1366            while (Regions) DeleteRegion(GetFirstRegion());
1367            // now recreate and copy regions
1368            {
1369                RegionList::const_iterator it = orig->pRegions->begin();
1370                for (int i = 0; i < orig->Regions; ++i, ++it) {
1371                    Region* dstRgn = AddRegion();
1372                    //NOTE: Region does semi-deep copy !
1373                    dstRgn->CopyAssign(*it);
1374                }
1375            }
1376        }
1377    
1378    
1379  // *************** File ***************  // *************** File ***************
# Line 1314  namespace DLS { Line 1626  namespace DLS {
1626      }      }
1627    
1628      /**      /**
1629         * Returns extension file of given index. Extension files are used
1630         * sometimes to circumvent the 2 GB file size limit of the RIFF format and
1631         * of certain operating systems in general. In this case, instead of just
1632         * using one file, the content is spread among several files with similar
1633         * file name scheme. This is especially used by some GigaStudio sound
1634         * libraries.
1635         *
1636         * @param index - index of extension file
1637         * @returns sought extension file, NULL if index out of bounds
1638         * @see GetFileName()
1639         */
1640        RIFF::File* File::GetExtensionFile(int index) {
1641            if (index < 0 || index >= ExtensionFiles.size()) return NULL;
1642            std::list<RIFF::File*>::iterator iter = ExtensionFiles.begin();
1643            for (int i = 0; iter != ExtensionFiles.end(); ++iter, ++i)
1644                if (i == index) return *iter;
1645            return NULL;
1646        }
1647    
1648        /** @brief File name of this DLS file.
1649         *
1650         * This method returns the file name as it was provided when loading
1651         * the respective DLS file. However in case the File object associates
1652         * an empty, that is new DLS file, which was not yet saved to disk,
1653         * this method will return an empty string.
1654         *
1655         * @see GetExtensionFile()
1656         */
1657        String File::GetFileName() {
1658            return pRIFF->GetFileName();
1659        }
1660        
1661        /**
1662         * You may call this method store a future file name, so you don't have to
1663         * to pass it to the Save() call later on.
1664         */
1665        void File::SetFileName(const String& name) {
1666            pRIFF->SetFileName(name);
1667        }
1668    
1669        /**
1670       * Apply all the DLS file's current instruments, samples and settings to       * Apply all the DLS file's current instruments, samples and settings to
1671       * the respective RIFF chunks. You have to call Save() to make changes       * the respective RIFF chunks. You have to call Save() to make changes
1672       * persistent.       * persistent.
# Line 1390  namespace DLS { Line 1743  namespace DLS {
1743      void File::Save(const String& Path) {      void File::Save(const String& Path) {
1744          UpdateChunks();          UpdateChunks();
1745          pRIFF->Save(Path);          pRIFF->Save(Path);
1746          __UpdateWavePoolTableChunk();          UpdateFileOffsets();
1747      }      }
1748    
1749      /** @brief Save changes to same file.      /** @brief Save changes to same file.
# Line 1405  namespace DLS { Line 1758  namespace DLS {
1758      void File::Save() {      void File::Save() {
1759          UpdateChunks();          UpdateChunks();
1760          pRIFF->Save();          pRIFF->Save();
1761            UpdateFileOffsets();
1762        }
1763    
1764        /** @brief Updates all file offsets stored all over the file.
1765         *
1766         * This virtual method is called whenever the overall file layout has been
1767         * changed (i.e. file or individual RIFF chunks have been resized). It is
1768         * then the responsibility of this method to update all file offsets stored
1769         * in the file format. For example samples are referenced by instruments by
1770         * file offsets. The gig format also stores references to instrument
1771         * scripts as file offsets, and thus it overrides this method to update
1772         * those file offsets as well.
1773         */
1774        void File::UpdateFileOffsets() {
1775          __UpdateWavePoolTableChunk();          __UpdateWavePoolTableChunk();
1776      }      }
1777    

Legend:
Removed from v.1184  
changed lines
  Added in v.2609

  ViewVC Help
Powered by ViewVC