/[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 2393 by schoenebeck, Mon Mar 12 14:59:10 2012 UTC revision 2394 by schoenebeck, Mon Jan 7 23:23:58 2013 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-2009 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 227  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 383  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 487  namespace DLS { Line 524  namespace DLS {
524  #endif  #endif
525  #endif  #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 612  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 1029  namespace DLS { Line 1097  namespace DLS {
1097          store32(&pData[4], Channel);          store32(&pData[4], Channel);
1098          store32(&pData[8], WavePoolTableIndex);          store32(&pData[8], WavePoolTableIndex);
1099      }      }
1100        
1101        /**
1102         * Make a (semi) deep copy of the Region object given by @a orig and assign
1103         * it to this object.
1104         *
1105         * Note that the sample pointer referenced by @a orig is simply copied as
1106         * memory address. Thus the respective sample is shared, not duplicated!
1107         *
1108         * @param orig - original Region object to be copied from
1109         */
1110        void Region::CopyAssign(const Region* orig) {
1111            // handle base classes
1112            Resource::CopyAssign(orig);
1113            Articulator::CopyAssign(orig);
1114            Sampler::CopyAssign(orig);
1115            // handle actual own attributes of this class
1116            // (the trivial ones)
1117            VelocityRange = orig->VelocityRange;
1118            KeyGroup = orig->KeyGroup;
1119            Layer = orig->Layer;
1120            SelfNonExclusive = orig->SelfNonExclusive;
1121            PhaseMaster = orig->PhaseMaster;
1122            PhaseGroup = orig->PhaseGroup;
1123            MultiChannel = orig->MultiChannel;
1124            Channel = orig->Channel;
1125            WavePoolTableIndex = orig->WavePoolTableIndex;
1126            pSample = orig->pSample;
1127            FormatOptionFlags = orig->FormatOptionFlags;
1128            WaveLinkOptionFlags = orig->WaveLinkOptionFlags;
1129            // handle the last, a bit sensible attribute
1130            SetKeyRange(orig->KeyRange.low, orig->KeyRange.high);
1131        }
1132    
1133    
1134  // *************** Instrument ***************  // *************** Instrument ***************
# Line 1180  namespace DLS { Line 1279  namespace DLS {
1279          RIFF::List* pParent = pCkInstrument->GetParent();          RIFF::List* pParent = pCkInstrument->GetParent();
1280          pParent->DeleteSubChunk(pCkInstrument);          pParent->DeleteSubChunk(pCkInstrument);
1281      }      }
1282        
1283        void Instrument::CopyAssignCore(const Instrument* orig) {
1284            // handle base classes
1285            Resource::CopyAssign(orig);
1286            Articulator::CopyAssign(orig);
1287            // handle actual own attributes of this class
1288            // (the trivial ones)
1289            IsDrum = orig->IsDrum;
1290            MIDIBank = orig->MIDIBank;
1291            MIDIBankCoarse = orig->MIDIBankCoarse;
1292            MIDIBankFine = orig->MIDIBankFine;
1293            MIDIProgram = orig->MIDIProgram;
1294        }
1295        
1296        /**
1297         * Make a (semi) deep copy of the Instrument object given by @a orig and assign
1298         * it to this object.
1299         *
1300         * Note that all sample pointers referenced by @a orig are simply copied as
1301         * memory address. Thus the respective samples are shared, not duplicated!
1302         *
1303         * @param orig - original Instrument object to be copied from
1304         */
1305        void Instrument::CopyAssign(const Instrument* orig) {
1306            CopyAssignCore(orig);
1307            // delete all regions first
1308            while (Regions) DeleteRegion(GetFirstRegion());
1309            // now recreate and copy regions
1310            {
1311                RegionList::const_iterator it = orig->pRegions->begin();
1312                for (int i = 0; i < orig->Regions; ++i, ++it) {
1313                    Region* dstRgn = AddRegion();
1314                    //NOTE: Region does semi-deep copy !
1315                    dstRgn->CopyAssign(*it);
1316                }
1317            }
1318        }
1319    
1320    
1321  // *************** File ***************  // *************** File ***************

Legend:
Removed from v.2393  
changed lines
  Added in v.2394

  ViewVC Help
Powered by ViewVC