/[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 1153 by schoenebeck, Sun Mar 18 19:38:47 2007 UTC revision 1154 by schoenebeck, Wed Apr 11 16:33:56 2007 UTC
# 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            // free the old array and update the member variables
498            if (SampleLoops) delete[] pSampleLoops;
499            pSampleLoops = pNewLoops;
500            SampleLoops++;
501        }
502    
503        /**
504         * Deletes an existing sample loop.
505         *
506         * @param pLoopDef - pointer to existing loop definition
507         * @throws Exception - if given loop definition does not exist
508         */
509        void Sampler::DeleteSampleLoop(sample_loop_t* pLoopDef) {
510            sample_loop_t* pNewLoops = new sample_loop_t[SampleLoops - 1];
511            // copy old loops array (skipping given loop)
512            for (int i = 0, o = 0; i < SampleLoops; i++) {
513                if (&pSampleLoops[i] == pLoopDef) continue;
514                if (o == SampleLoops - 1)
515                    throw Exception("Could not delete Sample Loop, because it does not exist");
516                pNewLoops[o] = pSampleLoops[i];
517                o++;
518            }
519            // free the old array and update the member variables
520            if (SampleLoops) delete[] pSampleLoops;
521            pSampleLoops = pNewLoops;
522            SampleLoops--;
523        }
524    
525    
526    
527  // *************** Sample ***************  // *************** Sample ***************

Legend:
Removed from v.1153  
changed lines
  Added in v.1154

  ViewVC Help
Powered by ViewVC