/[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 1050 by schoenebeck, Fri Mar 2 01:04:45 2007 UTC revision 1155 by schoenebeck, Wed Apr 11 18:11:09 2007 UTC
# Line 352  namespace DLS { Line 352  namespace DLS {
352          SaveString(CHUNK_ID_ITCH, lstINFO, Technician, String(""), UseFixedLengthStrings, 128);          SaveString(CHUNK_ID_ITCH, lstINFO, Technician, String(""), UseFixedLengthStrings, 128);
353          SaveString(CHUNK_ID_ISFT, lstINFO, Software, defaultSoftware, UseFixedLengthStrings,          SaveString(CHUNK_ID_ISFT, lstINFO, Software, defaultSoftware, UseFixedLengthStrings,
354                     resourceType == LIST_TYPE_INS ?                     resourceType == LIST_TYPE_INS ?
355                     (Software == "" ? defaultSoftware.length() : Software.length()) : 128);                     (Software == "" ? defaultSoftware.length()+1 : Software.length()+1) : 128);
356          SaveString(CHUNK_ID_IMED, lstINFO, Medium, String(""), UseFixedLengthStrings, 128);          SaveString(CHUNK_ID_IMED, lstINFO, Medium, String(""), UseFixedLengthStrings, 128);
357          SaveString(CHUNK_ID_ISRC, lstINFO, Source, String(""), UseFixedLengthStrings, 128);          SaveString(CHUNK_ID_ISRC, lstINFO, Source, String(""), UseFixedLengthStrings, 128);
358          SaveString(CHUNK_ID_ISRF, lstINFO, SourceForm, String(""), UseFixedLengthStrings, 128);          SaveString(CHUNK_ID_ISRF, lstINFO, SourceForm, String(""), UseFixedLengthStrings, 128);
# Line 481  namespace DLS { Line 481  namespace DLS {
481          }          }
482      }      }
483    
484        /**
485         * Adds a new sample loop with the provided loop definition.
486         *
487         * @param - points to a loop definition that is to be copied
488         */
489        void Sampler::AddSampleLoop(sample_loop_t* pLoopDef) {
490            sample_loop_t* pNewLoops = new sample_loop_t[SampleLoops + 1];
491            // copy old loops array
492            for (int i = 0; i < SampleLoops; i++) {
493                pNewLoops[i] = pSampleLoops[i];
494            }
495            // add the new loop
496            pNewLoops[SampleLoops] = *pLoopDef;
497            // auto correct size field
498            pNewLoops[SampleLoops].Size = sizeof(DLS::sample_loop_t);
499            // free the old array and update the member variables
500            if (SampleLoops) delete[] pSampleLoops;
501            pSampleLoops = pNewLoops;
502            SampleLoops++;
503        }
504    
505        /**
506         * Deletes an existing sample loop.
507         *
508         * @param pLoopDef - pointer to existing loop definition
509         * @throws Exception - if given loop definition does not exist
510         */
511        void Sampler::DeleteSampleLoop(sample_loop_t* pLoopDef) {
512            sample_loop_t* pNewLoops = new sample_loop_t[SampleLoops - 1];
513            // copy old loops array (skipping given loop)
514            for (int i = 0, o = 0; i < SampleLoops; i++) {
515                if (&pSampleLoops[i] == pLoopDef) continue;
516                if (o == SampleLoops - 1)
517                    throw Exception("Could not delete Sample Loop, because it does not exist");
518                pNewLoops[o] = pSampleLoops[i];
519                o++;
520            }
521            // free the old array and update the member variables
522            if (SampleLoops) delete[] pSampleLoops;
523            pSampleLoops = pNewLoops;
524            SampleLoops--;
525        }
526    
527    
528    
529  // *************** Sample ***************  // *************** Sample ***************
# Line 942  namespace DLS { Line 985  namespace DLS {
985          return pNewRegion;          return pNewRegion;
986      }      }
987    
988        void Instrument::MoveRegion(Region* pSrc, Region* pDst) {
989            RIFF::List* lrgn = pCkInstrument->GetSubList(LIST_TYPE_LRGN);
990            lrgn->MoveSubChunk(pSrc->pCkRegion, pDst ? pDst->pCkRegion : 0);
991    
992            pRegions->remove(pSrc);
993            RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pDst);
994            pRegions->insert(iter, pSrc);
995        }
996    
997      void Instrument::DeleteRegion(Region* pRegion) {      void Instrument::DeleteRegion(Region* pRegion) {
998          if (!pRegions) return;          if (!pRegions) return;
999          RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pRegion);          RegionList::iterator iter = find(pRegions->begin(), pRegions->end(), pRegion);

Legend:
Removed from v.1050  
changed lines
  Added in v.1155

  ViewVC Help
Powered by ViewVC