本文整理汇总了C++中WaveClip::Paste方法的典型用法代码示例。如果您正苦于以下问题:C++ WaveClip::Paste方法的具体用法?C++ WaveClip::Paste怎么用?C++ WaveClip::Paste使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WaveClip
的用法示例。
在下文中一共展示了WaveClip::Paste方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Join
bool WaveTrack::Join(double t0, double t1)
{
// Merge all WaveClips overlapping selection into one
WaveClipList::Node* it;
WaveClipList clipsToDelete;
WaveClip *newClip;
for (it=GetClipIterator(); it; it=it->GetNext())
{
WaveClip *clip = it->GetData();
if (clip->GetStartTime() < t1-(1.0/mRate) &&
clip->GetEndTime()-(1.0/mRate) > t0) {
// Put in sorted order
int i;
for(i=0; i<clipsToDelete.GetCount(); i++)
if (clipsToDelete[i]->GetStartTime() > clip->GetStartTime())
break;
//printf("Insert clip %.6f at position %d\n", clip->GetStartTime(), i);
clipsToDelete.Insert(i, clip);
}
}
newClip = CreateClip();
double t = clipsToDelete[0]->GetOffset();
newClip->SetOffset(t);
for(it=clipsToDelete.GetFirst(); it; it=it->GetNext())
{
WaveClip *clip = it->GetData();
//printf("t=%.6f adding clip (offset %.6f, %.6f ... %.6f)\n",
// t, clip->GetOffset(), clip->GetStartTime(), clip->GetEndTime());
if (clip->GetOffset() - t > (1.0 / mRate)) {
double addedSilence = (clip->GetOffset() - t);
//printf("Adding %.6f seconds of silence\n");
newClip->InsertSilence(t, addedSilence);
t += addedSilence;
}
//printf("Pasting at %.6f\n", t);
newClip->Paste(t, clip);
t = newClip->GetEndTime();
mClips.DeleteObject(clip);
delete clip;
}
return true;
}
示例2: Paste
bool WaveTrack::Paste(double t0, Track *src)
{
//printf("paste: entering WaveTrack::Paste\n");
if (src->GetKind() != Track::Wave)
return false;
//printf("paste: we have a wave track\n");
WaveTrack* other = (WaveTrack*)src;
//
// Pasting is a bit complicated, because with the existence of multiclip mode,
// we must guess the behaviour the user wants.
//
// Currently, two modes are implemented:
//
// - If a single clip should be pasted, and it should be pasted inside another
// clip, no new clips are generated. The audio is simply inserted.
// This resembles the old (pre-multiclip support) behaviour. However, if
// the clip is pasted outside of any clip, a new clip is generated. This is
// the only behaviour which is different to what was done before, but it
// shouldn't confuse users too much.
//
// - If multiple clips should be pasted, these are always pasted as single
// clips, and the current clip is splitted, when necessary. This may seem
// strange at first, but it probably is better than trying to auto-merge
// anything. The user can still merge the clips by hand (which should be
// a simple command reachable by a hotkey or single mouse click).
//
if (other->GetNumClips() == 0)
return false;
//printf("paste: we have at least one clip\n");
double insertDuration = other->GetEndTime();
WaveClipList::Node* it;
//printf("Check if we need to make room for the pasted data\n");
// Make room for the pasted data, unless the space being pasted in is empty of
// any clips
if (!IsEmpty(t0, t0+insertDuration-1.0/mRate)) {
for (it=GetClipIterator(); it; it=it->GetNext())
{
WaveClip* clip = it->GetData();
//printf("paste: offsetting already existing clip %i by %f seconds\n",
//(int)clip, insertDuration);
if (clip->GetStartTime() > t0-(1.0/mRate))
clip->Offset(insertDuration);
}
}
if (other->GetNumClips() == 1)
{
// Single clip mode
// printf("paste: checking for single clip mode!\n");
WaveClip *insideClip = NULL;
for (it=GetClipIterator(); it; it=it->GetNext())
{
WaveClip *clip = it->GetData();
// The 1.0/mRate is the time for one sample - kind of a fudge factor,
// because an overlap of less than a sample should not trigger
// traditional behaviour.
if (t0+src->GetEndTime()-1.0/mRate > clip->GetStartTime() &&
t0 < clip->GetEndTime() - 1.0/mRate)
{
//printf("t0=%.6f: inside clip is %.6f ... %.6f\n",
// t0, clip->GetStartTime(), clip->GetEndTime());
insideClip = clip;
break;
}
}
if (insideClip)
{
// Exhibit traditional behaviour
//printf("paste: traditional behaviour\n");
return insideClip->Paste(t0, other->GetClipByIndex(0));
}
// Just fall through and exhibit new behaviour
}
// Insert new clips
//printf("paste: multi clip mode!\n");
for (it=other->GetClipIterator(); it; it=it->GetNext())
{
WaveClip* clip = it->GetData();
WaveClip* newClip = new WaveClip(*clip, mDirManager);
//.........这里部分代码省略.........