本文整理汇总了C++中WaveTrack::ClearAndPaste方法的典型用法代码示例。如果您正苦于以下问题:C++ WaveTrack::ClearAndPaste方法的具体用法?C++ WaveTrack::ClearAndPaste怎么用?C++ WaveTrack::ClearAndPaste使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WaveTrack
的用法示例。
在下文中一共展示了WaveTrack::ClearAndPaste方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
bool Generator::Process()
{
if (GetDuration() < 0.0)
return false;
// Set up mOutputTracks.
// This effect needs Track::All for sync-lock grouping.
this->CopyInputTracks(Track::All);
// Iterate over the tracks
bool bGoodResult = true;
int ntrack = 0;
TrackListIterator iter(mOutputTracks);
Track* t = iter.First();
while (t != NULL)
{
if (t->GetKind() == Track::Wave && t->GetSelected()) {
WaveTrack* track = (WaveTrack*)t;
bool editClipCanMove;
gPrefs->Read(wxT("/GUI/EditClipCanMove"), &editClipCanMove, true);
//if we can't move clips, and we're generating into an empty space,
//make sure there's room.
if (!editClipCanMove &&
track->IsEmpty(mT0, mT1+1.0/track->GetRate()) &&
!track->IsEmpty(mT0, mT0+GetDuration()-(mT1-mT0)-1.0/track->GetRate()))
{
wxMessageBox(
_("There is not enough room available to generate the audio"),
_("Error"), wxICON_STOP);
Failure();
return false;
}
if (GetDuration() > 0.0)
{
AudacityProject *p = GetActiveProject();
// Create a temporary track
std::unique_ptr<WaveTrack> tmp(
mFactory->NewWaveTrack(track->GetSampleFormat(),
track->GetRate())
);
BeforeTrack(*track);
BeforeGenerate();
// Fill it with data
if (!GenerateTrack(&*tmp, *track, ntrack))
bGoodResult = false;
else {
// Transfer the data from the temporary track to the actual one
tmp->Flush();
SetTimeWarper(new StepTimeWarper(mT0+GetDuration(), GetDuration()-(mT1-mT0)));
bGoodResult = track->ClearAndPaste(p->GetSel0(), p->GetSel1(), &*tmp, true,
false, GetTimeWarper());
}
if (!bGoodResult) {
Failure();
return false;
}
}
else
{
// If the duration is zero, there's no need to actually
// generate anything
track->Clear(mT0, mT1);
}
ntrack++;
}
else if (t->IsSyncLockSelected()) {
t->SyncLockAdjust(mT1, mT0 + GetDuration());
}
// Move on to the next track
t = iter.Next();
}
Success();
this->ReplaceProcessedTracks(bGoodResult);
mT1 = mT0 + GetDuration(); // Update selection.
return true;
}
示例2: Process
//.........这里部分代码省略.........
Resampler resampler(outResampleCB,&rb,outSlideType);
audio outBuf[SBSMSOutBlockSize];
float outBufLeft[2*SBSMSOutBlockSize];
float outBufRight[2*SBSMSOutBlockSize];
// Samples in output after SBSMS
sampleCount samplesToOutput = rb.iface->getSamplesToOutput();
// Samples in output after resampling back
sampleCount samplesOut = (sampleCount) ((float)samplesToOutput * (srTrack/srProcess));
// Duration in track time
double duration = (mCurT1-mCurT0) * mTotalStretch;
if(duration > maxDuration)
maxDuration = duration;
TimeWarper *warper = createTimeWarper(mCurT0,mCurT1,maxDuration,rateStart,rateEnd,rateSlideType);
SetTimeWarper(warper);
rb.outputLeftTrack = mFactory->NewWaveTrack(leftTrack->GetSampleFormat(),
leftTrack->GetRate());
if(rightTrack)
rb.outputRightTrack = mFactory->NewWaveTrack(rightTrack->GetSampleFormat(),
rightTrack->GetRate());
long pos = 0;
long outputCount = -1;
// process
while(pos<samplesOut && outputCount) {
long frames;
if(pos+SBSMSOutBlockSize>samplesOut) {
frames = samplesOut - pos;
} else {
frames = SBSMSOutBlockSize;
}
outputCount = resampler.read(outBuf,frames);
for(int i = 0; i < outputCount; i++) {
outBufLeft[i] = outBuf[i][0];
if(rightTrack)
outBufRight[i] = outBuf[i][1];
}
pos += outputCount;
rb.outputLeftTrack->Append((samplePtr)outBufLeft, floatSample, outputCount);
if(rightTrack)
rb.outputRightTrack->Append((samplePtr)outBufRight, floatSample, outputCount);
double frac = (double)pos/(double)samplesOut;
int nWhichTrack = mCurTrackNum;
if(rightTrack) {
nWhichTrack = 2*(mCurTrackNum/2);
if (frac < 0.5)
frac *= 2.0; // Show twice as far for each track, because we're doing 2 at once.
else {
nWhichTrack++;
frac -= 0.5;
frac *= 2.0; // Show twice as far for each track, because we're doing 2 at once.
}
}
if (TrackProgress(nWhichTrack, frac))
return false;
}
rb.outputLeftTrack->Flush();
if(rightTrack)
rb.outputRightTrack->Flush();
bool bResult =
leftTrack->ClearAndPaste(mCurT0, mCurT1, rb.outputLeftTrack,
true, false, GetTimeWarper());
wxASSERT(bResult); // TO DO: Actually handle this.
wxUnusedVar(bResult);
if(rightTrack)
{
bResult =
rightTrack->ClearAndPaste(mCurT0, mCurT1, rb.outputRightTrack,
true, false, GetTimeWarper());
wxASSERT(bResult); // TO DO: Actually handle this.
}
}
mCurTrackNum++;
}
else if (mustSync && t->IsSyncLockSelected())
{
t->SyncLockAdjust(mCurT1, mCurT0 + (mCurT1 - mCurT0) * mTotalStretch);
}
//Iterate to the next track
t = iter.Next();
}
if (bGoodResult)
ReplaceProcessedTracks(bGoodResult);
// Update selection
mT0 = mCurT0;
mT1 = mCurT0 + maxDuration;
return bGoodResult;
}
示例3: Process
//------------------------- Processing methods -------------------------
bool EffectSineSweepGenerator::Process()
{
// taken `as is` from Audacity`s Generator.cpp to resolve
// a vc++ linking problem...
if (mDuration < 0.0)
return false;
BeforeGenerate();
// Set up mOutputTracks. This effect needs Track::All for grouping
this->CopyInputTracks(Track::All);
// Iterate over the tracks
bool bGoodResult = true;
int ntrack = 0;
TrackListIterator iter(mOutputTracks);
Track* t = iter.First();
while (t != NULL)
{
if (t->GetKind() == Track::Wave && t->GetSelected())
{
WaveTrack* track = (WaveTrack*)t;
bool editClipCanMove = true;
//gPrefs->Read(wxT("/GUI/EditClipCanMove"), &editClipCanMove, true);
//if we can't move clips, and we're generating into an empty space,
//make sure there's room.
if (!editClipCanMove &&
track->IsEmpty(mT0, mT1+1.0/track->GetRate()) &&
!track->IsEmpty(mT0, mT0+mDuration-(mT1-mT0)-1.0/track->GetRate()))
{
wxMessageBox(_("There is not enough room available to generate the audio"),
_("Error"), wxICON_STOP);
Failure();
return false;
}
if (mDuration > 0.0)
{
// Create a temporary track
WaveTrack *tmp = mFactory->NewWaveTrack(track->GetSampleFormat(),
track->GetRate());
//BeforeTrack(*track);
// Fill it with data
if (!GenerateTrack(tmp, *track, ntrack))
bGoodResult = false;
else
{
// Transfer the data from the temporary track to the actual one
tmp->Flush();
SetTimeWarper(new AFStepTimeWarper(mT0+mDuration, mDuration-(mT1-mT0)));
bGoodResult = track->ClearAndPaste(mT0, mT1, tmp, true,
false, GetTimeWarper());
delete tmp;
}
if (!bGoodResult)
{
Failure();
return false;
}
}
else
{
// If the duration is zero, there's no need to actually
// generate anything
track->Clear(mT0, mT1);
}
ntrack++;
}
else if (t->IsSyncLockSelected())
{
t->SyncLockAdjust(mT1, mT0 + mDuration);
}
// Move on to the next track
t = iter.Next();
}
Success();
this->ReplaceProcessedTracks(bGoodResult);
mT1 = mT0 + mDuration; // Update selection.
return true;
}
示例4: Process
//.........这里部分代码省略.........
// pre analysis
real fracPre = 0.0f;
if(bPreAnalyze) {
fracPre = 0.05f;
resampleBuf rbPre;
rbPre.block = maxBlockSize;
rbPre.buf = (audio*)calloc(rb.block,sizeof(audio));
rbPre.leftTrack = leftTrack;
rbPre.rightTrack = rightTrack?rightTrack:leftTrack;
rbPre.leftBuffer = (float*)calloc(maxBlockSize,sizeof(float));
rbPre.rightBuffer = (float*)calloc(maxBlockSize,sizeof(float));
rbPre.offset = start;
rbPre.end = end;
rbPre.ratio = srSBSMS/srIn;
rbPre.resampler = new Resampler(resampleCB, &rbPre);
si.rs = rbPre.resampler;
long pos = 0;
long lastPos = 0;
long ret = 0;
while(lastPos<samplesToProcess) {
ret = sbsms_pre_analyze(&samplesCB,&si,rb.sbsmser);
lastPos = pos;
pos += ret;
real completion = (real)lastPos/(real)samplesToProcess;
if (TrackProgress(0,fracPre*completion))
return false;
}
sbsms_pre_analyze_complete(rb.sbsmser);
sbsms_reset(rb.sbsmser);
si.rs = rb.resampler;
}
// process
while(pos<samplesOut && outputCount) {
long frames;
if(pos+blockSize>samplesOut) {
frames = samplesOut - pos;
} else {
frames = blockSize;
}
outputCount = pitch_process(rb.outBuf, frames, rb.pitch);
for(int i = 0; i < outputCount; i++) {
rb.outputLeftBuffer[i] = rb.outBuf[i][0];
if(rightTrack)
rb.outputRightBuffer[i] = rb.outBuf[i][1];
}
pos += outputCount;
rb.outputLeftTrack->Append((samplePtr)rb.outputLeftBuffer, floatSample, outputCount);
if(rightTrack)
rb.outputRightTrack->Append((samplePtr)rb.outputRightBuffer, floatSample, outputCount);
double frac = (double)pos/(double)samplesOut;
int nWhichTrack = mCurTrackNum;
if(rightTrack) {
nWhichTrack = 2*(mCurTrackNum/2);
if (frac < 0.5)
frac *= 2.0; // Show twice as far for each track, because we're doing 2 at once.
else {
nWhichTrack++;
frac -= 0.5;
frac *= 2.0; // Show twice as far for each track, because we're doing 2 at once.
}
}
if (TrackProgress(nWhichTrack, fracPre + (1.0-fracPre)*frac))
return false;
}
rb.outputLeftTrack->Flush();
if(rightTrack)
rb.outputRightTrack->Flush();
leftTrack->ClearAndPaste(mCurT0, mCurT1, rb.outputLeftTrack,
true, false, GetTimeWarper());
if(rightTrack) {
rightTrack->ClearAndPaste(mCurT0, mCurT1, rb.outputRightTrack,
true, false, GetTimeWarper());
}
}
mCurTrackNum++;
}
else if (mustSync && t->IsSynchroSelected())
{
t->SyncAdjust(mCurT1, mCurT0 + (mCurT1 - mCurT0) * mTotalStretch);
}
//Iterate to the next track
t = iter.Next();
}
if (bGoodResult)
ReplaceProcessedTracks(bGoodResult);
// Update selection
mT0 = mCurT0;
mT1 = mCurT0 + maxDuration;
return bGoodResult;
}