本文整理汇总了C++中TrackProgress函数的典型用法代码示例。如果您正苦于以下问题:C++ TrackProgress函数的具体用法?C++ TrackProgress怎么用?C++ TrackProgress使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TrackProgress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
bool EffectAmplify::ProcessOne(int count, WaveTrack *t,
sampleCount start, sampleCount len)
{
sampleCount s = start;
sampleCount originalLen = len;
sampleCount blockSize = t->GetMaxBlockSize();
sampleType *buffer = new sampleType[blockSize];
while (len) {
unsigned int block = t->GetBestBlockSize(s);
if (block > len)
block = len;
t->Get(buffer, s, block);
for (unsigned int i = 0; i < block; i++) {
buffer[i] = (sampleType) (buffer[i] * ratio);
}
t->Set(buffer, s, block);
len -= block;
s += block;
if (TrackProgress(count, (s-start)/(double)originalLen))
break;
}
delete[] buffer;
return true;
}
示例2: while
bool EffectInvert::ProcessOne(int count, WaveTrack *t,
sampleCount start, sampleCount len)
{
// keep track of two blocks whose data we will swap
sampleCount s = start;
sampleCount originalLen = len;
sampleCount blockSize = t->GetMaxBlockSize();
sampleType *buffer = new sampleType[blockSize];
while (len > 0) {
unsigned int block = t->GetBestBlockSize(s);
if (block > len)
block = len;
t->Get(buffer, s, block);
for (unsigned int i = 0; i < block; i++) {
buffer[i] = (sampleType) (-buffer[i]);
}
t->Set(buffer, s, block);
len -= block;
s += block;
TrackProgress(count, (s-start)/(double)originalLen);
}
delete[] buffer;
return true;
}
示例3: while
bool BlockGenerator::GenerateTrack(WaveTrack *tmp,
const WaveTrack &track,
int ntrack)
{
bool bGoodResult = true;
numSamples = track.TimeToLongSamples(GetDuration());
sampleCount i = 0;
float *data = new float[tmp->GetMaxBlockSize()];
sampleCount block = 0;
while ((i < numSamples) && bGoodResult) {
block = tmp->GetBestBlockSize(i);
if (block > (numSamples - i))
block = numSamples - i;
GenerateBlock(data, track, block);
// Add the generated data to the temporary track
tmp->Append((samplePtr)data, floatSample, block);
i += block;
// Update the progress meter
if (TrackProgress(ntrack, (double)i / numSamples))
bGoodResult = false;
}
delete[] data;
return bGoodResult;
}
示例4: iter
bool EffectRepeat::Process()
{
this->CopyInputWaveTracks(); // Set up mOutputWaveTracks.
bool bGoodResult = true;
TrackListIterator iter(mOutputWaveTracks);
WaveTrack *track = (WaveTrack *) iter.First();
int nTrack = 0;
double maxDestLen = 0.0; // used to change selection to generated bit
while ((track != NULL) && bGoodResult) {
double trackStart = track->GetStartTime();
double trackEnd = track->GetEndTime();
double t0 = mT0 < trackStart? trackStart: mT0;
double t1 = mT1 > trackEnd? trackEnd: mT1;
if (t1 <= t0)
continue;
sampleCount start = track->TimeToLongSamples(t0);
sampleCount end = track->TimeToLongSamples(t1);
sampleCount len = (sampleCount)(end - start);
double tLen = track->LongSamplesToTime(len);
double tc = t0 + tLen;
if (len <= 0)
continue;
Track *dest;
track->Copy(t0, t1, &dest);
for(int j=0; j<repeatCount; j++)
{
if (!track->Paste(tc, dest) ||
TrackProgress(nTrack, j / repeatCount)) // TrackProgress returns true on Cancel.
{
bGoodResult = false;
break;
}
tc += tLen;
}
if (tc > maxDestLen)
maxDestLen = tc;
delete dest;
track = (WaveTrack *) iter.Next();
nTrack++;
}
if (bGoodResult)
{
// Change selection to just the generated bits.
mT0 = mT1;
mT1 = maxDestLen;
}
this->ReplaceProcessedWaveTracks(bGoodResult);
return bGoodResult;
}
示例5: while
bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track,
sampleCount start, sampleCount len)
{
bool rc = true;
sampleCount s = 0;
sampleCount idealBlockLen = track->GetMaxBlockSize() * 4;
if (idealBlockLen % windowSize != 0)
idealBlockLen += (windowSize - (idealBlockLen % windowSize));
float *buffer = new float[idealBlockLen];
float *datawindow = new float[windowSize];
int i;
while((s < len)&&((len-s)>(windowSize/2))) {
sampleCount block = idealBlockLen;
if (s + block > len)
block = len - s;
track->Get((samplePtr) buffer, floatSample, start + s, block);
for(i=0; i<(block-windowSize/2); i+=windowSize/2) {
int wcopy = windowSize;
if (i + wcopy > block)
wcopy = block - i;
int j;
for(j=0; j<wcopy; j++)
datawindow[j] = buffer[i+j];
for(j=wcopy; j<windowSize; j++)
datawindow[j] = 0;
RemoveClicks(windowSize, datawindow);
for(j=0; j<wcopy; j++)
buffer[i+j] = datawindow[j];
}
track->Set((samplePtr) buffer, floatSample, start + s, block);
s += block;
if (TrackProgress(count, s / (double) len)) {
rc = false;
break;
}
}
delete[] buffer;
delete[] datawindow;
return rc;
}
示例6: while
//ProcessOne() takes a track, transforms it to bunch of buffer-blocks,
//and executes ProcessData, on it...
// uses mMult and mOffset to normalize a track. Needs to have them set before being called
bool EffectNormalize::ProcessOne(WaveTrack * track, wxString msg)
{
bool rc = true;
sampleCount s;
//Transform the marker timepoints to samples
sampleCount start = track->TimeToLongSamples(mCurT0);
sampleCount end = track->TimeToLongSamples(mCurT1);
//Get the length of the buffer (as double). len is
//used simply to calculate a progress meter, so it is easier
//to make it a double now than it is to do it later
double len = (double)(end - start);
//Initiate a processing buffer. This buffer will (most likely)
//be shorter than the length of the track being processed.
float *buffer = new float[track->GetMaxBlockSize()];
//Go through the track one buffer at a time. s counts which
//sample the current buffer starts at.
s = start;
while (s < end) {
//Get a block of samples (smaller than the size of the buffer)
sampleCount block = track->GetBestBlockSize(s);
//Adjust the block size if it is the final block in the track
if (s + block > end)
block = end - s;
//Get the samples from the track and put them in the buffer
track->Get((samplePtr) buffer, floatSample, s, block);
//Process the buffer.
ProcessData(buffer, block);
//Copy the newly-changed samples back onto the track.
track->Set((samplePtr) buffer, floatSample, s, block);
//Increment s one blockfull of samples
s += block;
//Update the Progress meter
if (TrackProgress(mCurTrackNum,
0.5+((double)(s - start) / len)/2.0, msg)) {
rc = false; //lda .. break, not return, so that buffer is deleted
break;
}
}
//Clean up the buffer
delete[] buffer;
//Return true because the effect processing succeeded ... unless cancelled
return rc;
}
示例7: while
//ProcessOne() takes a track, transforms it to bunch of buffer-blocks,
//and executes ProcessSimpleMono on these blocks
bool EffectSimpleMono::ProcessOne(WaveTrack * track,
longSampleCount start, longSampleCount end)
{
longSampleCount s;
//Get the length of the buffer (as double). len is
//used simple to calculate a progress meter, so it is easier
//to make it a double now than it is to do it later
double len = (double)(end - start);
//Initiate a processing buffer. This buffer will (most likely)
//be shorter than the length of the track being processed.
float *buffer = new float[track->GetMaxBlockSize()];
//Go through the track one buffer at a time. s counts which
//sample the current buffer starts at.
s = start;
while (s < end) {
//Get a block of samples (smaller than the size of the buffer)
sampleCount block = track->GetBestBlockSize(s);
//Adjust the block size if it is the final block in the track
if (s + block > end)
block = end - s;
//Get the samples from the track and put them in the buffer
track->Get((samplePtr) buffer, floatSample, s, block);
//Process the buffer. If it fails, clean up and exit.
if (!ProcessSimpleMono(buffer, block)) {
delete[]buffer;
//Return false because the effect failed.
return false;
}
//Processing succeeded. copy the newly-changed samples back
//onto the track.
track->Set((samplePtr) buffer, floatSample, s, block);
//Increment s one blockfull of samples
s += block;
//Update the Progress meter
if (TrackProgress(mCurTrackNum, s / len))
return false;
}
//Clean up the buffer
delete[]buffer;
//Return true because the effect processing succeeded.
return true;
}
示例8: InterpolateAudio
bool EffectRepair::ProcessOne(int count, WaveTrack * track,
sampleCount start,
size_t len,
size_t repairStart, size_t repairLen)
{
Floats buffer{ len };
track->Get((samplePtr) buffer.get(), floatSample, start, len);
InterpolateAudio(buffer.get(), len, repairStart, repairLen);
track->Set((samplePtr)&buffer[repairStart], floatSample,
start + repairStart, repairLen);
return !TrackProgress(count, 1.0); // TrackProgress returns true on Cancel.
}
示例9: while
bool EffectEcho::ProcessOne(int count, WaveTrack * track,
sampleCount start, sampleCount len)
{
sampleCount s = 0;
sampleCount blockSize = (sampleCount) (track->GetRate() * delay);
//do nothing if the delay is less than 1 sample or greater than
//the length of the selection
if (blockSize < 1 || blockSize > len)
return true;
float *buffer0 = new float[blockSize];
float *buffer1 = new float[blockSize];
float *ptr0 = buffer0;
float *ptr1 = buffer1;
bool first = true;
while (s < len) {
sampleCount block = blockSize;
if (s + block > len)
block = len - s;
track->Get((samplePtr)ptr0, floatSample, start + s, block);
if (!first) {
for (sampleCount i = 0; i < block; i++)
ptr0[i] += ptr1[i] * decay;
track->Set((samplePtr)ptr0, floatSample, start + s, block);
}
float *ptrtemp = ptr0;
ptr0 = ptr1;
ptr1 = ptrtemp;
first = false;
s += block;
if (TrackProgress(count, s / (double) len)) {
delete[]buffer0;
delete[]buffer1;
return false;
}
}
delete[]buffer0;
delete[]buffer1;
return true;
}
示例10: InterpolateAudio
bool EffectRepair::ProcessOne(int count, WaveTrack * track,
sampleCount start,
sampleCount len,
sampleCount repairStart, sampleCount repairLen)
{
float *buffer = new float[len];
track->Get((samplePtr) buffer, floatSample, start, len);
InterpolateAudio(buffer, len, repairStart, repairLen);
track->Set((samplePtr)&buffer[repairStart], floatSample,
start + repairStart, repairLen);
delete[] buffer;
return !TrackProgress(count, 1.0); // TrackProgress returns true on Cancel.
}
示例11: while
bool EffectEcho::ProcessOne(int count, WaveTrack * t,
sampleCount start, sampleCount len)
{
sampleCount s = start;
sampleCount blockSize = (sampleCount) (t->rate * delay);
sampleCount originalLen = len;
if (blockSize < 1 || blockSize > len)
return true;
sampleType *buffer0 = new sampleType[blockSize];
sampleType *buffer1 = new sampleType[blockSize];
sampleType *ptr0 = buffer0;
sampleType *ptr1 = buffer1;
bool first = true;
while (len) {
sampleCount block = blockSize;
if (block > len)
block = len;
t->Get(ptr0, s, block);
if (!first) {
for (sampleCount i = 0; i < block; i++)
ptr0[i] += (sampleType) (ptr1[i] * decay);
t->Set(ptr0, s, block);
}
sampleType *ptrtemp = ptr0;
ptr0 = ptr1;
ptr1 = ptrtemp;
first = false;
len -= block;
s += block;
TrackProgress(count, (s-start)/(double)originalLen);
}
delete[]buffer0;
delete[]buffer1;
return true;
}
示例12: while
bool EffectStereoToMono::ProcessOne(int count)
{
float curLeftFrame;
float curRightFrame;
float curMonoFrame;
sampleCount idealBlockLen = mLeftTrack->GetMaxBlockSize() * 2;
sampleCount index = mStart;
float *leftBuffer = new float[idealBlockLen];
float *rightBuffer = new float[idealBlockLen];
bool bResult = true;
while (index < mEnd) {
bResult &= mLeftTrack->Get((samplePtr)leftBuffer, floatSample, index, idealBlockLen);
bResult &= mRightTrack->Get((samplePtr)rightBuffer, floatSample, index, idealBlockLen);
sampleCount limit = idealBlockLen;
if ((index + idealBlockLen) > mEnd) {
limit = mEnd - index;
}
for (sampleCount i = 0; i < limit; ++i) {
index++;
curLeftFrame = leftBuffer[i];
curRightFrame = rightBuffer[i];
curMonoFrame = (curLeftFrame + curRightFrame) / 2.0;
leftBuffer[i] = curMonoFrame;
}
bResult &= mOutTrack->Append((samplePtr)leftBuffer, floatSample, limit);
if (TrackProgress(count, 2.*((double)index / (double)(mEnd - mStart))))
return false;
}
double minStart = wxMin(mLeftTrack->GetStartTime(), mRightTrack->GetStartTime());
bResult &= mLeftTrack->Clear(mLeftTrack->GetStartTime(), mLeftTrack->GetEndTime());
bResult &= mOutTrack->Flush();
bResult &= mLeftTrack->Paste(minStart, mOutTrack);
mLeftTrack->SetLinked(false);
mRightTrack->SetLinked(false);
mLeftTrack->SetChannel(Track::MonoChannel);
mOutputTracks->Remove(mRightTrack);
delete mRightTrack;
delete [] leftBuffer;
delete [] rightBuffer;
return bResult;
}
示例13: while
bool EffectReverse::ProcessOneClip(int count, WaveTrack *track,
sampleCount start, sampleCount len,
sampleCount originalStart, sampleCount originalEnd)
{
bool rc = true;
// keep track of two blocks whose data we will swap
sampleCount first = start;
sampleCount second;
sampleCount blockSize = track->GetMaxBlockSize();
float tmp;
float *buffer1 = new float[blockSize];
float *buffer2 = new float[blockSize];
sampleCount originalLen = (sampleCount)originalEnd-originalStart;
while (len > 1) {
sampleCount block = track->GetBestBlockSize(first);
if (block > len / 2)
block = len / 2;
second = first + (len - block);
track->Get((samplePtr)buffer1, floatSample, first, block);
track->Get((samplePtr)buffer2, floatSample, second, block);
for (int i = 0; i < block; i++) {
tmp = buffer1[i];
buffer1[i] = buffer2[block-i-1];
buffer2[block-i-1] = tmp;
}
track->Set((samplePtr)buffer1, floatSample, first, block);
track->Set((samplePtr)buffer2, floatSample, second, block);
len -= 2 * block;
first += block;
if( TrackProgress(count, 2*(first-originalStart) / (double) originalLen) ) {
rc = false;
break;
}
}
delete[] buffer1;
delete[] buffer2;
return rc;
}
示例14: while
bool EffectReverse::ProcessOneClip(int count, WaveTrack *track,
sampleCount start, sampleCount len,
sampleCount originalStart, sampleCount originalEnd)
{
bool rc = true;
// keep track of two blocks whose data we will swap
auto first = start;
auto blockSize = track->GetMaxBlockSize();
float tmp;
Floats buffer1{ blockSize };
Floats buffer2{ blockSize };
auto originalLen = originalEnd - originalStart;
while (len > 1) {
auto block =
limitSampleBufferSize( track->GetBestBlockSize(first), len / 2 );
auto second = first + (len - block);
track->Get((samplePtr)buffer1.get(), floatSample, first, block);
track->Get((samplePtr)buffer2.get(), floatSample, second, block);
for (decltype(block) i = 0; i < block; i++) {
tmp = buffer1[i];
buffer1[i] = buffer2[block-i-1];
buffer2[block-i-1] = tmp;
}
track->Set((samplePtr)buffer1.get(), floatSample, first, block);
track->Set((samplePtr)buffer2.get(), floatSample, second, block);
len -= 2 * block;
first += block;
if( TrackProgress(count, 2 * ( first - originalStart ).as_double() /
originalLen.as_double() ) ) {
rc = false;
break;
}
}
return rc;
}
示例15: printf
bool EffectSineSweepGenerator::GenerateTrack(WaveTrack *tmp, const WaveTrack &track, int ntrack)
{
#ifdef __AUDEBUG__
printf("elsg: GENERATETRACK\n"); fflush(stdout); // ************DEBUG
#endif
bool bGoodResult = true;
//numSamples = track.TimeToLongSamples(mDuration);
sampleCount numSamples;
//Filter has different length
if(ntrack == m_pSsg->GetFilterChannel())
numSamples = sampleCount(m_pSsg->GetFilterLength());
else
numSamples = sampleCount(m_pSsg->GetBuffersLength());
sampleCount i = 0;
AFSample *data = new AFSample[tmp->GetMaxBlockSize()];
sampleCount block = 0;
while ((i < numSamples) && bGoodResult)
{
block = tmp->GetBestBlockSize(i);
if (block > (numSamples - i))
block = numSamples - i;
// GenerateBlock(data, track, block);
m_pSsg->FillBlock(data, AFSampleCount(block), AFSampleCount(i), ntrack);
// Add the generated data to the temporary track
tmp->Append((samplePtr)data, floatSample, block);
i += block;
// Update the progress meter
if (TrackProgress(ntrack, (double)i / numSamples))
bGoodResult = false;
}
tmp->Flush();
delete[] data;
return bGoodResult;
}