Example #1
0
bool WaveTrack::Copy(double t0, double t1, Track **dest)
{
   if (t1 < t0)
      return false;

   sampleCount s0, s1;

   TimeToSamplesClip(t0, &s0);
   TimeToSamplesClip(t1, &s1);

   WaveTrack *newTrack = new WaveTrack(mDirManager);
   newTrack->Init(*this);

   delete newTrack->mSequence;
   newTrack->mSequence = NULL;
   
   if (!mSequence->Copy(s0, s1, &newTrack->mSequence)) {
      // Error
      *dest = NULL;
      delete newTrack;
      return false;
   }

   newTrack->GetEnvelope()->CopyFrom(GetEnvelope(), t0, t1);

   *dest = newTrack;
   MarkChanged();
   return true;
}
Example #2
0
bool WaveTrack::Cut(double t0, double t1, Track **dest)
{
   bool success;
   sampleCount s0, s1;
   WaveTrack *newTrack;

   if (t1 < t0)
      return false;

   TimeToSamplesClip(t0, &s0);
   TimeToSamplesClip(t1, &s1);

   newTrack = new WaveTrack(mDirManager);
   delete newTrack->mSequence;
   newTrack->mSequence = NULL;
   success = mSequence->Copy(s0, s1, &newTrack->mSequence);
   if (success)
      success = mSequence->Delete(s0, s1-s0);
   
   if (!success) {
      *dest = NULL;
      delete newTrack;
      return false;
   }

   newTrack->GetEnvelope()->CopyFrom(GetEnvelope(), t0, t1);
   mEnvelope->CollapseRegion(t0, t1);

   *dest = newTrack;
   MarkChanged();
   return true;
}