mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-01 15:43:44 +02:00
Fewer mentions of type sampleCount; more type deduction for variables
* sampleCount: Remove unnecessary casts to sampleCount Type agnosticism for some other variables that were not sampleCount... Remove many mentions of sampleCount with auto and decltype... Use sf_count_t not sampleCount some uses of size_t Use long long for argument passed to wxString::ToLongLong More cautions in SBSMSEffect.cpp...
This commit is contained in:
commit
96fc293c60
@ -1841,9 +1841,9 @@ int AudioIO::StartStream(const WaveTrackArray &playbackTracks,
|
||||
if( mNumPlaybackChannels > 0 ) {
|
||||
// Allocate output buffers. For every output track we allocate
|
||||
// a ring buffer of five seconds
|
||||
sampleCount playbackBufferSize =
|
||||
auto playbackBufferSize =
|
||||
(sampleCount)lrint(mRate * mPlaybackRingBufferSecs);
|
||||
sampleCount playbackMixBufferSize =
|
||||
auto playbackMixBufferSize =
|
||||
(sampleCount)mPlaybackSamplesToCopy;
|
||||
|
||||
mPlaybackBuffers = new RingBuffer* [mPlaybackTracks.size()];
|
||||
@ -1881,7 +1881,7 @@ int AudioIO::StartStream(const WaveTrackArray &playbackTracks,
|
||||
{
|
||||
// Allocate input buffers. For every input track we allocate
|
||||
// a ring buffer of five seconds
|
||||
sampleCount captureBufferSize =
|
||||
auto captureBufferSize =
|
||||
(sampleCount)(mRate * mCaptureRingBufferSecs + 0.5);
|
||||
|
||||
// In the extraordinarily rare case that we can't even afford 100 samples, just give up.
|
||||
@ -1920,9 +1920,9 @@ int AudioIO::StartStream(const WaveTrackArray &playbackTracks,
|
||||
bDone = false;
|
||||
|
||||
// In the extraordinarily rare case that we can't even afford 100 samples, just give up.
|
||||
sampleCount playbackBufferSize =
|
||||
auto playbackBufferSize =
|
||||
(sampleCount)lrint(mRate * mPlaybackRingBufferSecs);
|
||||
sampleCount playbackMixBufferSize =
|
||||
auto playbackMixBufferSize =
|
||||
(sampleCount)mPlaybackSamplesToCopy;
|
||||
if(playbackBufferSize < 100 || playbackMixBufferSize < 100)
|
||||
{
|
||||
|
@ -335,7 +335,7 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
|
||||
gPrefs->Flush();
|
||||
|
||||
// Rememebr the old blocksize, so that we can restore it later.
|
||||
int oldBlockSize = Sequence::GetMaxDiskBlockSize();
|
||||
auto oldBlockSize = Sequence::GetMaxDiskBlockSize();
|
||||
Sequence::SetMaxDiskBlockSize(blockSize * 1024);
|
||||
|
||||
wxBusyCursor busy;
|
||||
|
@ -205,8 +205,7 @@ void *BlockFile::CalcSummary(samplePtr buffer, sampleCount len,
|
||||
void BlockFile::CalcSummaryFromBuffer(const float *fbuffer, sampleCount len,
|
||||
float *summary256, float *summary64K)
|
||||
{
|
||||
sampleCount sumLen;
|
||||
sampleCount i, j, jcount;
|
||||
decltype(len) sumLen;
|
||||
|
||||
float min, max;
|
||||
float sumsq;
|
||||
@ -217,16 +216,16 @@ void BlockFile::CalcSummaryFromBuffer(const float *fbuffer, sampleCount len,
|
||||
sumLen = (len + 255) / 256;
|
||||
int summaries = 256;
|
||||
|
||||
for (i = 0; i < sumLen; i++) {
|
||||
for (decltype(sumLen) i = 0; i < sumLen; i++) {
|
||||
min = fbuffer[i * 256];
|
||||
max = fbuffer[i * 256];
|
||||
sumsq = ((float)min) * ((float)min);
|
||||
jcount = 256;
|
||||
decltype(len) jcount = 256;
|
||||
if (jcount > len - i * 256) {
|
||||
jcount = len - i * 256;
|
||||
fraction = 1.0 - (jcount / 256.0);
|
||||
}
|
||||
for (j = 1; j < jcount; j++) {
|
||||
for (decltype(jcount) j = 1; j < jcount; j++) {
|
||||
float f1 = fbuffer[i * 256 + j];
|
||||
sumsq += ((float)f1) * ((float)f1);
|
||||
if (f1 < min)
|
||||
@ -242,7 +241,7 @@ void BlockFile::CalcSummaryFromBuffer(const float *fbuffer, sampleCount len,
|
||||
summary256[i * 3 + 1] = max;
|
||||
summary256[i * 3 + 2] = rms; // The rms is correct, but this may be for less than 256 samples in last loop.
|
||||
}
|
||||
for (i = sumLen; i < mSummaryInfo.frames256; i++) {
|
||||
for (auto i = sumLen; i < mSummaryInfo.frames256; i++) {
|
||||
// filling in the remaining bits with non-harming/contributing values
|
||||
// rms values are not "non-harming", so keep count of them:
|
||||
summaries--;
|
||||
@ -257,12 +256,12 @@ void BlockFile::CalcSummaryFromBuffer(const float *fbuffer, sampleCount len,
|
||||
// Recalc 64K summaries
|
||||
sumLen = (len + 65535) / 65536;
|
||||
|
||||
for (i = 0; i < sumLen; i++) {
|
||||
for (decltype(sumLen) i = 0; i < sumLen; i++) {
|
||||
min = summary256[3 * i * 256];
|
||||
max = summary256[3 * i * 256 + 1];
|
||||
sumsq = (float)summary256[3 * i * 256 + 2];
|
||||
sumsq *= sumsq;
|
||||
for (j = 1; j < 256; j++) { // we can overflow the useful summary256 values here, but have put non-harmful values in them
|
||||
for (decltype(len) j = 1; j < 256; j++) { // we can overflow the useful summary256 values here, but have put non-harmful values in them
|
||||
if (summary256[3 * (i * 256 + j)] < min)
|
||||
min = summary256[3 * (i * 256 + j)];
|
||||
if (summary256[3 * (i * 256 + j) + 1] > max)
|
||||
@ -278,7 +277,7 @@ void BlockFile::CalcSummaryFromBuffer(const float *fbuffer, sampleCount len,
|
||||
summary64K[i * 3 + 1] = max;
|
||||
summary64K[i * 3 + 2] = rms;
|
||||
}
|
||||
for (i = sumLen; i < mSummaryInfo.frames64K; i++) {
|
||||
for (auto i = sumLen; i < mSummaryInfo.frames64K; i++) {
|
||||
wxASSERT_MSG(false, wxT("Out of data for mSummaryInfo")); // Do we ever get here?
|
||||
summary64K[i * 3] = 0.0f; // probably should be FLT_MAX, need a test case
|
||||
summary64K[i * 3 + 1] = 0.0f; // probably should be -FLT_MAX, need a test case
|
||||
@ -289,7 +288,7 @@ void BlockFile::CalcSummaryFromBuffer(const float *fbuffer, sampleCount len,
|
||||
min = summary64K[0];
|
||||
max = summary64K[1];
|
||||
|
||||
for (i = 1; i < sumLen; i++) {
|
||||
for (decltype(sumLen) i = 1; i < sumLen; i++) {
|
||||
if (summary64K[3*i] < min)
|
||||
min = summary64K[3*i];
|
||||
if (summary64K[3*i+1] > max)
|
||||
|
@ -194,7 +194,7 @@ static void RemoveDependencies(AudacityProject *project,
|
||||
continue;
|
||||
|
||||
// Convert it from an aliased file to an actual file in the project.
|
||||
unsigned int len = aliasBlockFile->GetLength();
|
||||
auto len = aliasBlockFile->GetLength();
|
||||
BlockFilePtr newBlockFile;
|
||||
{
|
||||
SampleBuffer buffer(len, format);
|
||||
|
@ -561,14 +561,15 @@ void FreqWindow::GetAudio()
|
||||
WaveTrack *track = (WaveTrack *)t;
|
||||
if (selcount==0) {
|
||||
mRate = track->GetRate();
|
||||
sampleCount start, end;
|
||||
start = track->TimeToLongSamples(p->mViewInfo.selectedRegion.t0());
|
||||
end = track->TimeToLongSamples(p->mViewInfo.selectedRegion.t1());
|
||||
mDataLen = (sampleCount)(end - start);
|
||||
if (mDataLen > 10485760) {
|
||||
auto start = track->TimeToLongSamples(p->mViewInfo.selectedRegion.t0());
|
||||
auto end = track->TimeToLongSamples(p->mViewInfo.selectedRegion.t1());
|
||||
auto dataLen = end - start;
|
||||
if (dataLen > 10485760) {
|
||||
warning = true;
|
||||
mDataLen = 10485760;
|
||||
}
|
||||
else
|
||||
mDataLen = dataLen;
|
||||
mData = new float[mDataLen];
|
||||
track->Get((samplePtr)mData, floatSample, start, mDataLen);
|
||||
}
|
||||
@ -580,8 +581,7 @@ void FreqWindow::GetAudio()
|
||||
mDataLen = 0;
|
||||
return;
|
||||
}
|
||||
sampleCount start;
|
||||
start = track->TimeToLongSamples(p->mViewInfo.selectedRegion.t0());
|
||||
auto start = track->TimeToLongSamples(p->mViewInfo.selectedRegion.t0());
|
||||
float *buffer2 = new float[mDataLen];
|
||||
track->Get((samplePtr)buffer2, floatSample, start, mDataLen);
|
||||
for (int i = 0; i < mDataLen; i++)
|
||||
|
@ -3372,7 +3372,7 @@ double AudacityProject::NearestZeroCrossing(double t0)
|
||||
WaveTrack *one = (WaveTrack *)track;
|
||||
int oneWindowSize = (int)(one->GetRate() / 100);
|
||||
float *oneDist = new float[oneWindowSize];
|
||||
sampleCount s = one->TimeToLongSamples(t0);
|
||||
auto s = one->TimeToLongSamples(t0);
|
||||
// fillTwo to ensure that missing values are treated as 2, and hence do not
|
||||
// get used as zero crossings.
|
||||
one->Get((samplePtr)oneDist, floatSample,
|
||||
|
18
src/Mix.cpp
18
src/Mix.cpp
@ -150,7 +150,7 @@ void MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
|
||||
|
||||
|
||||
|
||||
int maxBlockLen = mixLeft->GetIdealBlockSize();
|
||||
auto maxBlockLen = mixLeft->GetIdealBlockSize();
|
||||
|
||||
// If the caller didn't specify a time range, use the whole range in which
|
||||
// any input track had clips in it.
|
||||
@ -172,7 +172,7 @@ void MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
|
||||
_("Mixing and rendering tracks"));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
sampleCount blockLen = mixer.Process(maxBlockLen);
|
||||
auto blockLen = mixer.Process(maxBlockLen);
|
||||
|
||||
if (blockLen == 0)
|
||||
break;
|
||||
@ -338,9 +338,7 @@ Mixer::Mixer(const WaveTrackConstArray &inputTracks,
|
||||
mQueueLen[i] = 0;
|
||||
}
|
||||
|
||||
int envLen = mInterleavedBufferSize;
|
||||
if (mQueueMaxLen > envLen)
|
||||
envLen = mQueueMaxLen;
|
||||
const auto envLen = std::max(mQueueMaxLen, mInterleavedBufferSize);
|
||||
mEnvValues = new double[envLen];
|
||||
}
|
||||
|
||||
@ -418,7 +416,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
|
||||
const double tstep = 1.0 / trackRate;
|
||||
int sampleSize = SAMPLE_SIZE(floatSample);
|
||||
|
||||
sampleCount out = 0;
|
||||
decltype(mMaxOut) out = 0;
|
||||
|
||||
/* time is floating point. Sample rate is integer. The number of samples
|
||||
* has to be integer, but the multiplication gives a float result, which we
|
||||
@ -438,7 +436,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
|
||||
const double tEnd = backwards
|
||||
? std::max(startTime, mT1)
|
||||
: std::min(endTime, mT1);
|
||||
const sampleCount endPos = track->TimeToLongSamples(tEnd);
|
||||
const auto endPos = track->TimeToLongSamples(tEnd);
|
||||
// Find the time corresponding to the start of the queue, for use with time track
|
||||
double t = (*pos + (backwards ? *queueLen : - *queueLen)) / trackRate;
|
||||
|
||||
@ -488,7 +486,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
|
||||
}
|
||||
}
|
||||
|
||||
sampleCount thisProcessLen = mProcessLen;
|
||||
auto thisProcessLen = mProcessLen;
|
||||
bool last = (*queueLen < mProcessLen);
|
||||
if (last) {
|
||||
thisProcessLen = *queueLen;
|
||||
@ -557,7 +555,7 @@ sampleCount Mixer::MixSameRate(int *channelFlags, WaveTrackCache &cache,
|
||||
sampleCount *pos)
|
||||
{
|
||||
const WaveTrack *const track = cache.GetTrack();
|
||||
int slen = mMaxOut;
|
||||
auto slen = mMaxOut;
|
||||
int c;
|
||||
const double t = *pos / track->GetRate();
|
||||
const double trackEndTime = track->GetEndTime();
|
||||
@ -625,7 +623,7 @@ sampleCount Mixer::Process(sampleCount maxToProcess)
|
||||
// return 0;
|
||||
|
||||
int i, j;
|
||||
sampleCount maxOut = 0;
|
||||
decltype(Process(0)) maxOut = 0;
|
||||
int *channelFlags = new int[mNumChannels];
|
||||
|
||||
mMaxOut = maxToProcess;
|
||||
|
@ -632,8 +632,8 @@ void MixerTrackCluster::UpdateMeter(const double t0, const double t1)
|
||||
//delete[] maxRight;
|
||||
//delete[] rmsRight;
|
||||
|
||||
sampleCount startSample = (sampleCount)((mLeftTrack->GetRate() * t0) + 0.5);
|
||||
sampleCount nFrames = (sampleCount)((mLeftTrack->GetRate() * (t1 - t0)) + 0.5);
|
||||
auto startSample = (sampleCount)((mLeftTrack->GetRate() * t0) + 0.5);
|
||||
auto nFrames = (sampleCount)((mLeftTrack->GetRate() * (t1 - t0)) + 0.5);
|
||||
float* meterFloatsArray = NULL;
|
||||
float* tempFloatsArray = new float[nFrames];
|
||||
bool bSuccess = mLeftTrack->Get((samplePtr)tempFloatsArray, floatSample, startSample, nFrames);
|
||||
|
106
src/Sequence.cpp
106
src/Sequence.cpp
@ -146,7 +146,7 @@ bool Sequence::ConvertToSampleFormat(sampleFormat format, bool* pbChanged)
|
||||
const sampleFormat oldFormat = mSampleFormat;
|
||||
mSampleFormat = format;
|
||||
|
||||
const sampleCount oldMinSamples = mMinSamples, oldMaxSamples = mMaxSamples;
|
||||
const auto oldMinSamples = mMinSamples, oldMaxSamples = mMaxSamples;
|
||||
// These are the same calculations as in the constructor.
|
||||
mMinSamples = sMaxDiskBlockSize / SAMPLE_SIZE(mSampleFormat) / 2;
|
||||
mMaxSamples = mMinSamples * 2;
|
||||
@ -165,7 +165,7 @@ bool Sequence::ConvertToSampleFormat(sampleFormat format, bool* pbChanged)
|
||||
SeqBlock &oldSeqBlock = mBlock[i];
|
||||
const auto &oldBlockFile = oldSeqBlock.f;
|
||||
|
||||
sampleCount len = oldBlockFile->GetLength();
|
||||
const auto len = oldBlockFile->GetLength();
|
||||
|
||||
bSuccess = (oldBlockFile->ReadData(bufferOld.ptr(), oldFormat, 0, len) > 0);
|
||||
if (!bSuccess)
|
||||
@ -183,7 +183,7 @@ bool Sequence::ConvertToSampleFormat(sampleFormat format, bool* pbChanged)
|
||||
// from the old blocks... Oh no!
|
||||
|
||||
// Using Blockify will handle the cases where len > the NEW mMaxSamples. Previous code did not.
|
||||
const sampleCount blockstart = oldSeqBlock.start;
|
||||
const auto blockstart = oldSeqBlock.start;
|
||||
const unsigned prevSize = newBlockArray.size();
|
||||
Blockify(newBlockArray, blockstart, bufferNew.ptr(), len);
|
||||
bSuccess = (newBlockArray.size() > prevSize);
|
||||
@ -239,8 +239,6 @@ bool Sequence::GetMinMax(sampleCount start, sampleCount len,
|
||||
unsigned int block0 = FindBlock(start);
|
||||
unsigned int block1 = FindBlock(start + len - 1);
|
||||
|
||||
sampleCount s0;
|
||||
|
||||
// First calculate the min/max of the blocks in the middle of this region;
|
||||
// this is very fast because we have the min/max of every entire block
|
||||
// already in memory.
|
||||
@ -266,7 +264,7 @@ bool Sequence::GetMinMax(sampleCount start, sampleCount len,
|
||||
theFile->GetMinMax(&block0Min, &block0Max, &block0RMS);
|
||||
|
||||
if (block0Min < min || block0Max > max) {
|
||||
s0 = start - theBlock.start;
|
||||
auto s0 = start - theBlock.start;
|
||||
const auto maxl0 = theBlock.start + theFile->GetLength() - start;
|
||||
wxASSERT(maxl0 <= mMaxSamples); // Vaughan, 2011-10-19
|
||||
const auto l0 = limitSampleBufferSize ( maxl0, len );
|
||||
@ -290,12 +288,11 @@ bool Sequence::GetMinMax(sampleCount start, sampleCount len,
|
||||
|
||||
if (block1Min < min || block1Max > max) {
|
||||
|
||||
s0 = 0;
|
||||
const auto l0 = (start + len) - theBlock.start;
|
||||
wxASSERT(l0 <= mMaxSamples); // Vaughan, 2011-10-19
|
||||
|
||||
float partialMin, partialMax, partialRMS;
|
||||
theFile->GetMinMax(s0, l0,
|
||||
theFile->GetMinMax(0, l0,
|
||||
&partialMin, &partialMax, &partialRMS);
|
||||
if (partialMin < min)
|
||||
min = partialMin;
|
||||
@ -326,8 +323,6 @@ bool Sequence::GetRMS(sampleCount start, sampleCount len,
|
||||
unsigned int block0 = FindBlock(start);
|
||||
unsigned int block1 = FindBlock(start + len - 1);
|
||||
|
||||
sampleCount s0;
|
||||
|
||||
// First calculate the rms of the blocks in the middle of this region;
|
||||
// this is very fast because we have the rms of every entire block
|
||||
// already in memory.
|
||||
@ -337,7 +332,7 @@ bool Sequence::GetRMS(sampleCount start, sampleCount len,
|
||||
const auto &theFile = theBlock.f;
|
||||
theFile->GetMinMax(&blockMin, &blockMax, &blockRMS);
|
||||
|
||||
const sampleCount fileLen = theFile->GetLength();
|
||||
const auto fileLen = theFile->GetLength();
|
||||
sumsq += blockRMS * blockRMS * fileLen;
|
||||
length += fileLen;
|
||||
}
|
||||
@ -348,7 +343,7 @@ bool Sequence::GetRMS(sampleCount start, sampleCount len,
|
||||
{
|
||||
const SeqBlock &theBlock = mBlock[block0];
|
||||
const auto &theFile = theBlock.f;
|
||||
s0 = start - theBlock.start;
|
||||
auto s0 = start - theBlock.start;
|
||||
const auto maxl0 = theBlock.start + theFile->GetLength() - start;
|
||||
wxASSERT(maxl0 <= mMaxSamples); // Vaughan, 2011-10-19
|
||||
const auto l0 = limitSampleBufferSize( maxl0, len );
|
||||
@ -364,12 +359,11 @@ bool Sequence::GetRMS(sampleCount start, sampleCount len,
|
||||
const SeqBlock &theBlock = mBlock[block1];
|
||||
const auto &theFile = theBlock.f;
|
||||
|
||||
s0 = 0;
|
||||
const auto l0 = (start + len) - theBlock.start;
|
||||
wxASSERT(l0 <= mMaxSamples); // PRL: I think Vaughan missed this
|
||||
|
||||
float partialMin, partialMax, partialRMS;
|
||||
theFile->GetMinMax(s0, l0, &partialMin, &partialMax, &partialRMS);
|
||||
theFile->GetMinMax(0, l0, &partialMin, &partialMax, &partialRMS);
|
||||
sumsq += partialRMS * partialRMS * l0;
|
||||
length += l0;
|
||||
}
|
||||
@ -484,7 +478,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
}
|
||||
|
||||
const BlockArray &srcBlock = src->mBlock;
|
||||
sampleCount addedLen = src->mNumSamples;
|
||||
auto addedLen = src->mNumSamples;
|
||||
const unsigned int srcNumBlocks = srcBlock.size();
|
||||
int sampleSize = SAMPLE_SIZE(mSampleFormat);
|
||||
|
||||
@ -508,8 +502,8 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
const int b = (s == mNumSamples) ? mBlock.size() - 1 : FindBlock(s);
|
||||
wxASSERT((b >= 0) && (b < (int)numBlocks));
|
||||
SeqBlock *const pBlock = &mBlock[b];
|
||||
const sampleCount length = pBlock->f->GetLength();
|
||||
const sampleCount largerBlockLen = addedLen + length;
|
||||
const auto length = pBlock->f->GetLength();
|
||||
const auto largerBlockLen = addedLen + length;
|
||||
// PRL: when insertion point is the first sample of a block,
|
||||
// and the following test fails, perhaps we could test
|
||||
// whether coalescence with the previous block is possible.
|
||||
@ -550,7 +544,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
newBlock.insert(newBlock.end(), mBlock.begin(), mBlock.begin() + b);
|
||||
|
||||
SeqBlock &splitBlock = mBlock[b];
|
||||
sampleCount splitLen = splitBlock.f->GetLength();
|
||||
auto splitLen = splitBlock.f->GetLength();
|
||||
int splitPoint = s - splitBlock.start;
|
||||
|
||||
unsigned int i;
|
||||
@ -576,16 +570,16 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
// copied in as is, and the last two get merged with the last
|
||||
// half of the split block.
|
||||
|
||||
const sampleCount srcFirstTwoLen =
|
||||
const auto srcFirstTwoLen =
|
||||
srcBlock[0].f->GetLength() + srcBlock[1].f->GetLength();
|
||||
const sampleCount leftLen = splitPoint + srcFirstTwoLen;
|
||||
const auto leftLen = splitPoint + srcFirstTwoLen;
|
||||
|
||||
const SeqBlock &penultimate = srcBlock[srcNumBlocks - 2];
|
||||
const sampleCount srcLastTwoLen =
|
||||
const auto srcLastTwoLen =
|
||||
penultimate.f->GetLength() +
|
||||
srcBlock[srcNumBlocks - 1].f->GetLength();
|
||||
const sampleCount rightSplit = splitBlock.f->GetLength() - splitPoint;
|
||||
const sampleCount rightLen = rightSplit + srcLastTwoLen;
|
||||
const auto rightLen = rightSplit + srcLastTwoLen;
|
||||
|
||||
SampleBuffer sampleBuffer(std::max(leftLen, rightLen), mSampleFormat);
|
||||
|
||||
@ -606,7 +600,7 @@ bool Sequence::Paste(sampleCount s, const Sequence *src)
|
||||
newBlock.push_back(SeqBlock(file, block.start + s));
|
||||
}
|
||||
|
||||
sampleCount lastStart = penultimate.start;
|
||||
auto lastStart = penultimate.start;
|
||||
src->Get(srcNumBlocks - 2, sampleBuffer.ptr(), mSampleFormat,
|
||||
lastStart, srcLastTwoLen);
|
||||
Read(sampleBuffer.ptr() + srcLastTwoLen * sampleSize, mSampleFormat,
|
||||
@ -648,7 +642,7 @@ bool Sequence::InsertSilence(sampleCount s0, sampleCount len)
|
||||
|
||||
Sequence sTrack(mDirManager, mSampleFormat);
|
||||
|
||||
sampleCount idealSamples = GetIdealBlockSize();
|
||||
auto idealSamples = GetIdealBlockSize();
|
||||
|
||||
sampleCount pos = 0;
|
||||
|
||||
@ -778,7 +772,7 @@ sampleCount Sequence::GetBestBlockSize(sampleCount start) const
|
||||
const SeqBlock &block = mBlock[b];
|
||||
sampleCount result = (block.start + block.f->GetLength() - start);
|
||||
|
||||
sampleCount length;
|
||||
decltype(result) length;
|
||||
while(result < mMinSamples && b+1<numBlocks &&
|
||||
((length = mBlock[b+1].f->GetLength()) + result) <= mMaxSamples) {
|
||||
b++;
|
||||
@ -792,8 +786,6 @@ sampleCount Sequence::GetBestBlockSize(sampleCount start) const
|
||||
|
||||
bool Sequence::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
{
|
||||
sampleCount nValue;
|
||||
|
||||
/* handle waveblock tag and its attributes */
|
||||
if (!wxStrcmp(tag, wxT("waveblock"))) {
|
||||
SeqBlock wb;
|
||||
@ -804,6 +796,8 @@ bool Sequence::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
const wxChar *attr = *attrs++;
|
||||
const wxChar *value = *attrs++;
|
||||
|
||||
long long nValue = 0;
|
||||
|
||||
if (!value)
|
||||
break;
|
||||
|
||||
@ -857,6 +851,8 @@ bool Sequence::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
|
||||
if (!value)
|
||||
break;
|
||||
|
||||
long long nValue = 0;
|
||||
|
||||
const wxString strValue = value; // promote string, we need this for all
|
||||
|
||||
if (!wxStrcmp(attr, wxT("maxsamples")))
|
||||
@ -1115,7 +1111,7 @@ bool Sequence::CopyWrite(SampleBuffer &scratch,
|
||||
// we copy the old block entirely into memory, dereference it,
|
||||
// make the change, and then write the NEW block to disk.
|
||||
|
||||
const sampleCount length = b.f->GetLength();
|
||||
const auto length = b.f->GetLength();
|
||||
wxASSERT(length <= mMaxSamples);
|
||||
wxASSERT(start + len <= length);
|
||||
wxASSERT(start >= 0);
|
||||
@ -1151,8 +1147,7 @@ bool Sequence::Get(int b, samplePtr buffer, sampleFormat format,
|
||||
while (len) {
|
||||
const SeqBlock &block = mBlock[b];
|
||||
const sampleCount bstart = (start - (block.start));
|
||||
const sampleCount blen =
|
||||
std::min(len, block.f->GetLength() - bstart);
|
||||
const auto blen = std::min(len, block.f->GetLength() - bstart);
|
||||
|
||||
Read(buffer, format, block, bstart, blen);
|
||||
|
||||
@ -1186,7 +1181,7 @@ bool Sequence::Set(samplePtr buffer, sampleFormat format,
|
||||
while (len != 0) {
|
||||
SeqBlock &block = mBlock[b];
|
||||
const sampleCount bstart = start - block.start;
|
||||
const sampleCount fileLength = block.f->GetLength();
|
||||
const auto fileLength = block.f->GetLength();
|
||||
const auto blen = limitSampleBufferSize( fileLength - bstart, len );
|
||||
|
||||
if (buffer) {
|
||||
@ -1269,7 +1264,7 @@ struct MinMaxSumsq
|
||||
bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
|
||||
int len, const sampleCount *where)
|
||||
{
|
||||
const sampleCount s0 = std::max(sampleCount(0), where[0]);
|
||||
const auto s0 = std::max(sampleCount(0), where[0]);
|
||||
if (s0 >= mNumSamples)
|
||||
// None of the samples asked for are in range. Abandon.
|
||||
return false;
|
||||
@ -1277,18 +1272,18 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
|
||||
// In case where[len - 1] == where[len], raise the limit by one,
|
||||
// so we load at least one pixel for column len - 1
|
||||
// ... unless the mNumSamples ceiling applies, and then there are other defenses
|
||||
const sampleCount s1 =
|
||||
const auto s1 =
|
||||
std::min(mNumSamples, std::max(1 + where[len - 1], where[len]));
|
||||
float *temp = new float[mMaxSamples];
|
||||
|
||||
int pixel = 0;
|
||||
|
||||
sampleCount srcX = s0;
|
||||
sampleCount nextSrcX = 0;
|
||||
auto srcX = s0;
|
||||
decltype(srcX) nextSrcX = 0;
|
||||
int lastRmsDenom = 0;
|
||||
int lastDivisor = 0;
|
||||
sampleCount whereNow = std::min(s1 - 1, where[0]);
|
||||
sampleCount whereNext = 0;
|
||||
auto whereNow = std::min(s1 - 1, where[0]);
|
||||
decltype(whereNow) whereNext = 0;
|
||||
// Loop over block files, opening and reading and closing each
|
||||
// not more than once
|
||||
unsigned nBlocks = mBlock.size();
|
||||
@ -1302,7 +1297,7 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
|
||||
// Find the range of sample values for this block that
|
||||
// are in the display.
|
||||
SeqBlock &seqBlock = mBlock[b];
|
||||
const sampleCount start = seqBlock.start;
|
||||
const auto start = seqBlock.start;
|
||||
nextSrcX = std::min(s1, start + seqBlock.f->GetLength());
|
||||
|
||||
// The column for pixel p covers samples from
|
||||
@ -1349,7 +1344,7 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
|
||||
std::max(sampleCount(0), (srcX - start) / divisor);
|
||||
const sampleCount inclusiveEndPosition =
|
||||
std::min((mMaxSamples / divisor) - 1, (nextSrcX - 1 - start) / divisor);
|
||||
const sampleCount num = 1 + inclusiveEndPosition - startPosition;
|
||||
const auto num = 1 + inclusiveEndPosition - startPosition;
|
||||
if (num <= 0) {
|
||||
// What? There was a zero length block file?
|
||||
wxASSERT(false);
|
||||
@ -1389,7 +1384,7 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
|
||||
break;
|
||||
}
|
||||
|
||||
sampleCount filePosition = startPosition;
|
||||
auto filePosition = startPosition;
|
||||
|
||||
// The previous pixel column might straddle blocks.
|
||||
// If so, impute some of the data to it.
|
||||
@ -1422,7 +1417,7 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
|
||||
// and the range of positions for those columns
|
||||
// (normally one or more, for that one column)
|
||||
int pixelX = pixel + 1;
|
||||
sampleCount positionX = 0;
|
||||
decltype(filePosition) positionX = 0;
|
||||
while (pixelX < nextPixel &&
|
||||
filePosition ==
|
||||
(positionX = (std::min(s1 - 1, where[pixelX]) - start) / divisor)
|
||||
@ -1465,12 +1460,12 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
|
||||
sampleCount Sequence::GetIdealAppendLen()
|
||||
{
|
||||
int numBlocks = mBlock.size();
|
||||
const sampleCount max = GetMaxBlockSize();
|
||||
const auto max = GetMaxBlockSize();
|
||||
|
||||
if (numBlocks == 0)
|
||||
return max;
|
||||
|
||||
const sampleCount lastBlockLen = mBlock.back().f->GetLength();
|
||||
const auto lastBlockLen = mBlock.back().f->GetLength();
|
||||
if (lastBlockLen == max)
|
||||
return max;
|
||||
else
|
||||
@ -1486,8 +1481,8 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format,
|
||||
|
||||
// If the last block is not full, we need to add samples to it
|
||||
int numBlocks = mBlock.size();
|
||||
sampleCount length;
|
||||
SeqBlock *pLastBlock;
|
||||
decltype(pLastBlock->f->GetLength()) length;
|
||||
SampleBuffer buffer2(mMaxSamples, mSampleFormat);
|
||||
if (numBlocks > 0 &&
|
||||
(length =
|
||||
@ -1523,8 +1518,8 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format,
|
||||
}
|
||||
// Append the rest as NEW blocks
|
||||
while (len) {
|
||||
const sampleCount idealSamples = GetIdealBlockSize();
|
||||
const sampleCount l = std::min(idealSamples, len);
|
||||
const auto idealSamples = GetIdealBlockSize();
|
||||
const auto l = std::min(idealSamples, len);
|
||||
BlockFilePtr pFile;
|
||||
if (format == mSampleFormat) {
|
||||
pFile = mDirManager->NewSimpleBlockFile(buffer, l, mSampleFormat,
|
||||
@ -1561,14 +1556,13 @@ void Sequence::Blockify(BlockArray &list, sampleCount start, samplePtr buffer, s
|
||||
{
|
||||
if (len <= 0)
|
||||
return;
|
||||
|
||||
const int num = (len + (mMaxSamples - 1)) / mMaxSamples;
|
||||
auto num = (len + (mMaxSamples - 1)) / mMaxSamples;
|
||||
list.reserve(list.size() + num);
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
for (decltype(num) i = 0; i < num; i++) {
|
||||
SeqBlock b;
|
||||
|
||||
const sampleCount offset = i * len / num;
|
||||
const auto offset = i * len / num;
|
||||
b.start = start + offset;
|
||||
int newLen = ((i + 1) * len / num) - offset;
|
||||
samplePtr bufStart = buffer + (offset * SAMPLE_SIZE(mSampleFormat));
|
||||
@ -1602,12 +1596,12 @@ bool Sequence::Delete(sampleCount start, sampleCount len)
|
||||
// block and the resulting length is not too small, perform the
|
||||
// deletion within this block:
|
||||
SeqBlock *pBlock;
|
||||
sampleCount length;
|
||||
decltype(pBlock->f->GetLength()) length;
|
||||
|
||||
// One buffer for reuse in various branches here
|
||||
SampleBuffer scratch;
|
||||
// The maximum size that will ever be needed
|
||||
const sampleCount scratchSize = mMaxSamples + mMinSamples;
|
||||
const auto scratchSize = mMaxSamples + mMinSamples;
|
||||
|
||||
if (b0 == b1 && (length = (pBlock = &mBlock[b0])->f->GetLength()) - len >= mMinSamples) {
|
||||
SeqBlock &b = *pBlock;
|
||||
@ -1660,8 +1654,8 @@ bool Sequence::Delete(sampleCount start, sampleCount len)
|
||||
newBlock.push_back(SeqBlock(pFile, preBlock.start));
|
||||
} else {
|
||||
const SeqBlock &prepreBlock = mBlock[b0 - 1];
|
||||
const sampleCount prepreLen = prepreBlock.f->GetLength();
|
||||
const sampleCount sum = prepreLen + preBufferLen;
|
||||
const auto prepreLen = prepreBlock.f->GetLength();
|
||||
const auto sum = prepreLen + preBufferLen;
|
||||
|
||||
if (!scratch.ptr())
|
||||
scratch.Allocate(scratchSize, mSampleFormat);
|
||||
@ -1700,8 +1694,8 @@ bool Sequence::Delete(sampleCount start, sampleCount len)
|
||||
newBlock.push_back(SeqBlock(file, start));
|
||||
} else {
|
||||
SeqBlock &postpostBlock = mBlock[b1 + 1];
|
||||
sampleCount postpostLen = postpostBlock.f->GetLength();
|
||||
sampleCount sum = postpostLen + postBufferLen;
|
||||
const auto postpostLen = postpostBlock.f->GetLength();
|
||||
const auto sum = postpostLen + postBufferLen;
|
||||
|
||||
if (!scratch.ptr())
|
||||
// Last use of scratch, can ask for smaller
|
||||
|
@ -1312,14 +1312,14 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
||||
const double toffset = clip->GetOffset();
|
||||
double rate = clip->GetRate();
|
||||
const double t0 = std::max(0.0, zoomInfo.PositionToTime(0, -leftOffset) - toffset);
|
||||
const sampleCount s0 = sampleCount(floor(t0 * rate));
|
||||
const sampleCount snSamples = clip->GetNumSamples();
|
||||
const auto s0 = sampleCount(floor(t0 * rate));
|
||||
const auto snSamples = clip->GetNumSamples();
|
||||
if (s0 > snSamples)
|
||||
return;
|
||||
|
||||
const double t1 = zoomInfo.PositionToTime(rect.width - 1, -leftOffset) - toffset;
|
||||
const sampleCount s1 = sampleCount(ceil(t1 * rate));
|
||||
const sampleCount slen = std::min(snSamples - s0, s1 - s0 + 1);
|
||||
const auto s1 = sampleCount(ceil(t1 * rate));
|
||||
sampleCount slen = std::min(snSamples - s0, s1 - s0 + 1);
|
||||
if (slen <= 0)
|
||||
return;
|
||||
|
||||
@ -1330,14 +1330,13 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
||||
int *ypos = new int[slen];
|
||||
int *clipped = NULL;
|
||||
int clipcnt = 0;
|
||||
sampleCount s;
|
||||
|
||||
if (mShowClipping)
|
||||
clipped = new int[slen];
|
||||
|
||||
dc.SetPen(muted ? muteSamplePen : samplePen);
|
||||
|
||||
for (s = 0; s < slen; s++) {
|
||||
for (decltype(slen) s = 0; s < slen; s++) {
|
||||
const double time = toffset + (s + s0) / rate;
|
||||
const int xx = // An offset into the rectangle rect
|
||||
std::max(-10000, std::min(10000,
|
||||
@ -1356,7 +1355,7 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
||||
}
|
||||
|
||||
// Draw lines
|
||||
for (s = 0; s < slen - 1; s++) {
|
||||
for (decltype(slen) s = 0; s < slen - 1; s++) {
|
||||
AColor::Line(dc,
|
||||
rect.x + xpos[s], rect.y + ypos[s],
|
||||
rect.x + xpos[s + 1], rect.y + ypos[s + 1]);
|
||||
@ -1371,7 +1370,7 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
||||
pr.height = tickSize;
|
||||
//different colour when draggable.
|
||||
dc.SetBrush( bigPoints ? dragsampleBrush : sampleBrush);
|
||||
for (s = 0; s < slen; s++) {
|
||||
for (decltype(slen) s = 0; s < slen; s++) {
|
||||
if (ypos[s] >= 0 && ypos[s] < rect.height) {
|
||||
pr.x = rect.x + xpos[s] - tickSize/2;
|
||||
pr.y = rect.y + ypos[s] - tickSize/2;
|
||||
@ -1384,7 +1383,7 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &
|
||||
if (clipcnt) {
|
||||
dc.SetPen(muted ? muteClippedPen : clippedPen);
|
||||
while (--clipcnt >= 0) {
|
||||
s = clipped[clipcnt];
|
||||
auto s = clipped[clipcnt];
|
||||
AColor::Line(dc, rect.x + s, rect.y, rect.x + s, rect.y + rect.height);
|
||||
}
|
||||
}
|
||||
@ -1576,7 +1575,7 @@ struct ClipParameters
|
||||
|
||||
//trim selection so that it only contains the actual samples
|
||||
if (ssel0 != ssel1 && ssel1 > (sampleCount)(0.5 + trackLen * rate)) {
|
||||
ssel1 = (sampleCount)(0.5 + trackLen * rate);
|
||||
ssel1 = 0.5 + trackLen * rate;
|
||||
}
|
||||
|
||||
// The variable "hiddenMid" will be the rectangle containing the
|
||||
@ -1844,13 +1843,13 @@ void TrackArtist::DrawClipWaveform(const WaveTrack *track,
|
||||
if (portion.inFisheye) {
|
||||
if (!showIndividualSamples) {
|
||||
fisheyeDisplay.Allocate();
|
||||
const sampleCount numSamples = clip->GetNumSamples();
|
||||
const auto numSamples = clip->GetNumSamples();
|
||||
// Get wave display data for different magnification
|
||||
int jj = 0;
|
||||
for (; jj < rect.width; ++jj) {
|
||||
const double time =
|
||||
zoomInfo.PositionToTime(jj, -leftOffset) - tOffset;
|
||||
const sampleCount sample = (sampleCount)floor(time * rate + 0.5);
|
||||
const auto sample = (sampleCount)floor(time * rate + 0.5);
|
||||
if (sample < 0) {
|
||||
++rect.x;
|
||||
++skippedLeft;
|
||||
@ -2428,7 +2427,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
|
||||
float *const uncached =
|
||||
inFisheye ? &specCache.freq[(fisheyeColumn++) * half] : 0;
|
||||
|
||||
sampleCount w0 = w1;
|
||||
auto w0 = w1;
|
||||
w1 = sampleCount(0.5 + rate *
|
||||
(zoomInfo.PositionToTime(xx + 1, -leftOffset) - tOffset)
|
||||
);
|
||||
|
@ -2342,9 +2342,9 @@ void TrackPanel::StartSnappingFreqSelection (const WaveTrack *pTrack)
|
||||
|
||||
// Grab samples, just for this track, at these times
|
||||
std::vector<float> frequencySnappingData;
|
||||
const sampleCount start =
|
||||
const auto start =
|
||||
pTrack->TimeToLongSamples(mViewInfo->selectedRegion.t0());
|
||||
const sampleCount end =
|
||||
const auto end =
|
||||
pTrack->TimeToLongSamples(mViewInfo->selectedRegion.t1());
|
||||
const auto length =
|
||||
std::min(frequencySnappingData.max_size(),
|
||||
@ -3248,7 +3248,7 @@ namespace {
|
||||
// WaveClip::GetClipAtX doesn't work unless the clip is on the screen and can return bad info otherwise
|
||||
// instead calculate the time manually
|
||||
double rate = pTrack->GetRate();
|
||||
sampleCount s0 = (sampleCount)(time * rate + 0.5);
|
||||
auto s0 = (sampleCount)(time * rate + 0.5);
|
||||
|
||||
if (s0 >= 0)
|
||||
return pTrack->GetClipAtSample(s0);
|
||||
@ -4507,15 +4507,15 @@ void TrackPanel::HandleSampleEditingDrag( wxMouseEvent & event )
|
||||
|
||||
//Now, redraw all samples between current and last redrawn sample, inclusive
|
||||
//Go from the smaller to larger sample.
|
||||
const int start = std::min( s0, mDrawingLastDragSample);
|
||||
const int end = std::max( s0, mDrawingLastDragSample);
|
||||
const auto start = std::min( s0, mDrawingLastDragSample);
|
||||
const auto end = std::max( s0, mDrawingLastDragSample);
|
||||
const int size = end - start + 1;
|
||||
if (size == 1) {
|
||||
mDrawingTrack->Set((samplePtr)&newLevel, floatSample, start, size);
|
||||
}
|
||||
else {
|
||||
std::vector<float> values(size);
|
||||
for (sampleCount i = start; i <= end; ++i) {
|
||||
for (auto i = start; i <= end; ++i) {
|
||||
//This interpolates each sample linearly:
|
||||
values[i - start] =
|
||||
mDrawingLastDragSampleValue + (newLevel - mDrawingLastDragSampleValue) *
|
||||
@ -6657,7 +6657,7 @@ bool TrackPanel::HitTestSamples(Track *track, wxRect &rect, const wxMouseEvent &
|
||||
|
||||
// Just get one sample.
|
||||
float oneSample;
|
||||
sampleCount s0 = (sampleCount)(tt * rate + 0.5);
|
||||
auto s0 = (sampleCount)(tt * rate + 0.5);
|
||||
wavetrack->Get((samplePtr)&oneSample, floatSample, s0, 1);
|
||||
|
||||
// Get y distance of envelope point from center line (in pixels).
|
||||
|
@ -100,15 +100,15 @@ sampleCount VoiceKey::OnForward (WaveTrack & t, sampleCount start, sampleCount l
|
||||
}
|
||||
else {
|
||||
|
||||
sampleCount lastsubthresholdsample; // keeps track of the sample number of the last sample to not exceed the threshold
|
||||
|
||||
//Change the millisecond-based parameters into sample-based parameters
|
||||
double rate = t.GetRate(); //Translates seconds to samples
|
||||
unsigned int WindowSizeInt = (unsigned int)(rate * mWindowSize); //Size of window to examine
|
||||
unsigned int SignalWindowSizeInt = (unsigned int)(rate * mSignalWindowSize); //This much signal is necessary to trip key
|
||||
|
||||
auto samplesleft = len - WindowSizeInt; //Indexes the number of samples remaining in the selection
|
||||
lastsubthresholdsample = start; //start this off at the selection start
|
||||
auto lastsubthresholdsample = start; //start this off at the selection start
|
||||
// keeps track of the sample number of the last sample to not exceed the threshold
|
||||
|
||||
int blockruns=0; //keeps track of the number of consecutive above-threshold blocks
|
||||
|
||||
|
||||
@ -247,15 +247,15 @@ sampleCount VoiceKey::OnBackward (WaveTrack & t, sampleCount end, sampleCount le
|
||||
}
|
||||
else {
|
||||
|
||||
sampleCount lastsubthresholdsample; // keeps track of the sample number of the last sample to not exceed the threshold
|
||||
|
||||
//Change the millisecond-based parameters into sample-based parameters
|
||||
double rate = t.GetRate(); //Translates seconds to samples
|
||||
unsigned int WindowSizeInt = (unsigned int)(rate * mWindowSize); //Size of window to examine
|
||||
//unsigned int SilentWindowSizeInt = (unsigned int)(rate * mSilentWindowSize); //This much signal is necessary to trip key
|
||||
|
||||
auto samplesleft = len - WindowSizeInt; //Indexes the number of samples remaining in the selection
|
||||
lastsubthresholdsample = end; //start this off at the end
|
||||
auto lastsubthresholdsample = end; //start this off at the end
|
||||
// keeps track of the sample number of the last sample to not exceed the threshold
|
||||
|
||||
int blockruns=0; //keeps track of the number of consecutive above-threshold blocks
|
||||
|
||||
|
||||
@ -384,8 +384,6 @@ sampleCount VoiceKey::OffForward (WaveTrack & t, sampleCount start, sampleCount
|
||||
}
|
||||
else {
|
||||
|
||||
sampleCount lastsubthresholdsample; // keeps track of the sample number of the last sample to not exceed the threshold
|
||||
|
||||
|
||||
//Change the millisecond-based parameters into sample-based parameters
|
||||
double rate = t.GetRate(); //Translates seconds to samples
|
||||
@ -393,7 +391,9 @@ sampleCount VoiceKey::OffForward (WaveTrack & t, sampleCount start, sampleCount
|
||||
unsigned int SilentWindowSizeInt = (unsigned int)(rate * mSilentWindowSize); //This much signal is necessary to trip key
|
||||
|
||||
auto samplesleft = len - WindowSizeInt; //Indexes the number of samples remaining in the selection
|
||||
lastsubthresholdsample = start; //start this off at the selection start
|
||||
auto lastsubthresholdsample = start; //start this off at the selection start
|
||||
// keeps track of the sample number of the last sample to not exceed the threshold
|
||||
|
||||
int blockruns=0; //keeps track of the number of consecutive above-threshold blocks
|
||||
|
||||
//This loop goes through the selection a block at a time. If a long enough run
|
||||
@ -520,15 +520,15 @@ sampleCount VoiceKey::OffBackward (WaveTrack & t, sampleCount end, sampleCount l
|
||||
}
|
||||
else {
|
||||
|
||||
sampleCount lastsubthresholdsample; // keeps track of the sample number of the last sample to not exceed the threshold
|
||||
|
||||
//Change the millisecond-based parameters into sample-based parameters
|
||||
double rate = t.GetRate(); //Translates seconds to samples
|
||||
unsigned int WindowSizeInt = (unsigned int)(rate * mWindowSize); //Size of window to examine
|
||||
//unsigned int SilentWindowSizeInt = (unsigned int)(rate * mSilentWindowSize); //This much signal is necessary to trip key
|
||||
|
||||
auto samplesleft = len - WindowSizeInt; //Indexes the number of samples remaining in the selection
|
||||
lastsubthresholdsample = end; //start this off at the end
|
||||
auto lastsubthresholdsample = end; //start this off at the end
|
||||
// keeps track of the sample number of the last sample to not exceed the threshold
|
||||
|
||||
int blockruns=0; //keeps track of the number of consecutive above-threshold blocks
|
||||
|
||||
//This loop goes through the selection a block at a time in reverse order. If a long enough run
|
||||
@ -839,8 +839,8 @@ double VoiceKey::TestEnergy (WaveTrack & t, sampleCount start, sampleCount len)
|
||||
{
|
||||
|
||||
double sum = 1;
|
||||
sampleCount s = start; //Keep track of start
|
||||
sampleCount originalLen = len; //Keep track of the length of block to process (its not the length of t)
|
||||
auto s = start; //Keep track of start
|
||||
auto originalLen = len; //Keep track of the length of block to process (its not the length of t)
|
||||
const auto blockSize = limitSampleBufferSize(
|
||||
t.GetMaxBlockSize(), len); //Determine size of sampling buffer
|
||||
float *buffer = new float[blockSize]; //Get a sampling buffer
|
||||
@ -880,8 +880,8 @@ double VoiceKey::TestSignChanges(WaveTrack & t, sampleCount start, sampleCount l
|
||||
{
|
||||
|
||||
|
||||
sampleCount s = start; //Keep track of start
|
||||
sampleCount originalLen = len; //Keep track of the length of block to process (its not the length of t)
|
||||
auto s = start; //Keep track of start
|
||||
auto originalLen = len; //Keep track of the length of block to process (its not the length of t)
|
||||
const auto blockSize = limitSampleBufferSize(
|
||||
t.GetMaxBlockSize(), len); //Determine size of sampling buffer
|
||||
unsigned long signchanges = 1;
|
||||
@ -936,8 +936,8 @@ double VoiceKey::TestDirectionChanges(WaveTrack & t, sampleCount start, sampleCo
|
||||
{
|
||||
|
||||
|
||||
sampleCount s = start; //Keep track of start
|
||||
sampleCount originalLen = len; //Keep track of the length of block to process (its not the length of t)
|
||||
auto s = start; //Keep track of start
|
||||
auto originalLen = len; //Keep track of the length of block to process (its not the length of t)
|
||||
const auto blockSize = limitSampleBufferSize(
|
||||
t.GetMaxBlockSize(), len); //Determine size of sampling buffer
|
||||
unsigned long directionchanges = 1;
|
||||
|
@ -364,7 +364,7 @@ double WaveClip::GetStartTime() const
|
||||
|
||||
double WaveClip::GetEndTime() const
|
||||
{
|
||||
sampleCount numSamples = mSequence->GetNumSamples();
|
||||
auto numSamples = mSequence->GetNumSamples();
|
||||
|
||||
double maxLen = mOffset + double(numSamples+mAppendBufferLen)/mRate;
|
||||
// JS: calculated value is not the length;
|
||||
@ -375,7 +375,7 @@ double WaveClip::GetEndTime() const
|
||||
|
||||
sampleCount WaveClip::GetStartSample() const
|
||||
{
|
||||
return (sampleCount)floor(mOffset * mRate + 0.5);
|
||||
return floor(mOffset * mRate + 0.5);
|
||||
}
|
||||
|
||||
sampleCount WaveClip::GetEndSample() const
|
||||
@ -390,19 +390,19 @@ sampleCount WaveClip::GetNumSamples() const
|
||||
|
||||
bool WaveClip::WithinClip(double t) const
|
||||
{
|
||||
sampleCount ts = (sampleCount)floor(t * mRate + 0.5);
|
||||
auto ts = (sampleCount)floor(t * mRate + 0.5);
|
||||
return ts > GetStartSample() && ts < GetEndSample() + mAppendBufferLen;
|
||||
}
|
||||
|
||||
bool WaveClip::BeforeClip(double t) const
|
||||
{
|
||||
sampleCount ts = (sampleCount)floor(t * mRate + 0.5);
|
||||
auto ts = (sampleCount)floor(t * mRate + 0.5);
|
||||
return ts <= GetStartSample();
|
||||
}
|
||||
|
||||
bool WaveClip::AfterClip(double t) const
|
||||
{
|
||||
sampleCount ts = (sampleCount)floor(t * mRate + 0.5);
|
||||
auto ts = (sampleCount)floor(t * mRate + 0.5);
|
||||
return ts >= GetEndSample() + mAppendBufferLen;
|
||||
}
|
||||
|
||||
@ -472,11 +472,9 @@ fillWhere(std::vector<sampleCount> &where, int len, double bias, double correcti
|
||||
{
|
||||
// Be careful to make the first value non-negative
|
||||
const double w0 = 0.5 + correction + bias + t0 * rate;
|
||||
where[0] = sampleCount(std::max(0.0, floor(w0)));
|
||||
for (sampleCount x = 1; x < len + 1; x++)
|
||||
where[x] = sampleCount(
|
||||
floor(w0 + double(x) * samplesPerPixel)
|
||||
);
|
||||
where[0] = std::max(0.0, floor(w0));
|
||||
for (decltype(len) x = 1; x < len + 1; x++)
|
||||
where[x] = floor(w0 + double(x) * samplesPerPixel);
|
||||
}
|
||||
|
||||
}
|
||||
@ -608,7 +606,7 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
|
||||
|
||||
/* handle values in the append buffer */
|
||||
|
||||
int numSamples = mSequence->GetNumSamples();
|
||||
auto numSamples = mSequence->GetNumSamples();
|
||||
int a;
|
||||
|
||||
// Not all of the required columns might be in the sequence.
|
||||
@ -626,10 +624,8 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
|
||||
sampleFormat seqFormat = mSequence->GetSampleFormat();
|
||||
bool didUpdate = false;
|
||||
for(i=a; i<p1; i++) {
|
||||
sampleCount left;
|
||||
left = where[i] - numSamples;
|
||||
sampleCount right;
|
||||
right = where[i + 1] - numSamples;
|
||||
auto left = where[i] - numSamples;
|
||||
auto right = where[i + 1] - numSamples;
|
||||
|
||||
//wxCriticalSectionLocker locker(mAppendCriticalSection);
|
||||
|
||||
@ -641,7 +637,6 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
|
||||
if (right > left) {
|
||||
float *b;
|
||||
sampleCount len = right-left;
|
||||
sampleCount j;
|
||||
|
||||
if (seqFormat == floatSample)
|
||||
b = &((float *)mAppendBuffer.ptr())[left];
|
||||
@ -658,7 +653,7 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
|
||||
theMax = theMin = val;
|
||||
sumsq = val * val;
|
||||
}
|
||||
for(j=1; j<len; j++) {
|
||||
for(decltype(len) j = 1; j < len; j++) {
|
||||
const float val = b[j];
|
||||
theMax = std::max(theMax, val);
|
||||
theMin = std::min(theMin, val);
|
||||
@ -730,11 +725,11 @@ void ComputeSpectrogramGainFactors
|
||||
// This is the reciprocal of the bin number of 1000 Hz:
|
||||
const double factor = ((double)rate / (double)fftLen) / 1000.0;
|
||||
|
||||
const int half = fftLen / 2;
|
||||
int half = fftLen / 2;
|
||||
gainFactors.reserve(half);
|
||||
// Don't take logarithm of zero! Let bin 0 replicate the gain factor for bin 1.
|
||||
gainFactors.push_back(frequencyGain*log10(factor));
|
||||
for (sampleCount x = 1; x < half; x++) {
|
||||
for (decltype(half) x = 1; x < half; x++) {
|
||||
gainFactors.push_back(frequencyGain*log10(factor * x));
|
||||
}
|
||||
}
|
||||
@ -806,12 +801,13 @@ bool SpecCache::CalculateOneSpectrum
|
||||
float *adj = scratch + padding;
|
||||
|
||||
{
|
||||
sampleCount myLen = windowSize;
|
||||
auto myLen = windowSize;
|
||||
// Take a window of the track centered at this sample.
|
||||
start -= windowSize >> 1;
|
||||
if (start < 0) {
|
||||
// Near the start of the clip, pad left with zeroes as needed.
|
||||
for (sampleCount ii = start; ii < 0; ++ii)
|
||||
// Start is at least -windowSize / 2
|
||||
for (auto ii = start; ii < 0; ++ii)
|
||||
*adj++ = 0;
|
||||
myLen += start;
|
||||
start = 0;
|
||||
@ -821,7 +817,7 @@ bool SpecCache::CalculateOneSpectrum
|
||||
if (start + myLen > numSamples) {
|
||||
// Near the end of the clip, pad right with zeroes as needed.
|
||||
int newlen = numSamples - start;
|
||||
for (sampleCount ii = newlen; ii < (sampleCount)myLen; ++ii)
|
||||
for (decltype(myLen) ii = newlen; ii < myLen; ++ii)
|
||||
adj[ii] = 0;
|
||||
myLen = newlen;
|
||||
copy = true;
|
||||
@ -983,7 +979,7 @@ void SpecCache::Populate
|
||||
for (int jj = 0; jj < 2; ++jj) {
|
||||
const int lowerBoundX = jj == 0 ? 0 : copyEnd;
|
||||
const int upperBoundX = jj == 0 ? copyBegin : numPixels;
|
||||
for (sampleCount xx = lowerBoundX; xx < upperBoundX; ++xx)
|
||||
for (auto xx = lowerBoundX; xx < upperBoundX; ++xx)
|
||||
CalculateOneSpectrum(
|
||||
settings, waveTrackCache, xx, numSamples,
|
||||
offset, rate, pixelsPerSecond,
|
||||
@ -994,7 +990,7 @@ void SpecCache::Populate
|
||||
// Need to look beyond the edges of the range to accumulate more
|
||||
// time reassignments.
|
||||
// I'm not sure what's a good stopping criterion?
|
||||
sampleCount xx = lowerBoundX;
|
||||
auto xx = lowerBoundX;
|
||||
const double pixelsPerSample = pixelsPerSecond / rate;
|
||||
const int limit = std::min(int(0.5 + fftLen * pixelsPerSample), 100);
|
||||
for (int ii = 0; ii < limit; ++ii)
|
||||
@ -1024,7 +1020,7 @@ void SpecCache::Populate
|
||||
|
||||
// Now Convert to dB terms. Do this only after accumulating
|
||||
// power values, which may cross columns with the time correction.
|
||||
for (sampleCount xx = lowerBoundX; xx < upperBoundX; ++xx) {
|
||||
for (auto xx = lowerBoundX; xx < upperBoundX; ++xx) {
|
||||
float *const results = &freq[half * xx];
|
||||
const HFFT hFFT = settings.hFFT;
|
||||
for (int ii = 0; ii < hFFT->Points; ++ii) {
|
||||
@ -1200,7 +1196,7 @@ void WaveClip::TimeToSamplesClip(double t0, sampleCount *s0) const
|
||||
else if (t0 > mOffset + double(mSequence->GetNumSamples())/mRate)
|
||||
*s0 = mSequence->GetNumSamples();
|
||||
else
|
||||
*s0 = (sampleCount)floor(((t0 - mOffset) * mRate) + 0.5);
|
||||
*s0 = floor(((t0 - mOffset) * mRate) + 0.5);
|
||||
}
|
||||
|
||||
void WaveClip::ClearDisplayRect() const
|
||||
@ -1225,8 +1221,8 @@ bool WaveClip::Append(samplePtr buffer, sampleFormat format,
|
||||
{
|
||||
//wxLogDebug(wxT("Append: len=%lli"), (long long) len);
|
||||
|
||||
sampleCount maxBlockSize = mSequence->GetMaxBlockSize();
|
||||
sampleCount blockSize = mSequence->GetIdealAppendLen();
|
||||
auto maxBlockSize = mSequence->GetMaxBlockSize();
|
||||
auto blockSize = mSequence->GetIdealAppendLen();
|
||||
sampleFormat seqFormat = mSequence->GetSampleFormat();
|
||||
|
||||
if (!mAppendBuffer.ptr())
|
||||
@ -1461,7 +1457,7 @@ bool WaveClip::InsertSilence(double t, double len)
|
||||
{
|
||||
sampleCount s0;
|
||||
TimeToSamplesClip(t, &s0);
|
||||
sampleCount slen = (sampleCount)floor(len * mRate + 0.5);
|
||||
auto slen = (sampleCount)floor(len * mRate + 0.5);
|
||||
|
||||
if (!GetSequence()->InsertSilence(s0, slen))
|
||||
{
|
||||
@ -1705,7 +1701,7 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
|
||||
sampleCount pos = 0;
|
||||
bool error = false;
|
||||
int outGenerated = 0;
|
||||
sampleCount numSamples = mSequence->GetNumSamples();
|
||||
auto numSamples = mSequence->GetNumSamples();
|
||||
|
||||
auto newSequence =
|
||||
std::make_unique<Sequence>(mSequence->GetDirManager(), mSequence->GetSampleFormat());
|
||||
|
@ -1361,23 +1361,23 @@ bool WaveTrack::Silence(double t0, double t1)
|
||||
if (t1 < t0)
|
||||
return false;
|
||||
|
||||
sampleCount start = (sampleCount)floor(t0 * mRate + 0.5);
|
||||
sampleCount len = (sampleCount)floor(t1 * mRate + 0.5) - start;
|
||||
auto start = (sampleCount)floor(t0 * mRate + 0.5);
|
||||
auto len = (sampleCount)floor(t1 * mRate + 0.5) - start;
|
||||
bool result = true;
|
||||
|
||||
for (const auto &clip : mClips)
|
||||
{
|
||||
sampleCount clipStart = clip->GetStartSample();
|
||||
sampleCount clipEnd = clip->GetEndSample();
|
||||
auto clipStart = clip->GetStartSample();
|
||||
auto clipEnd = clip->GetEndSample();
|
||||
|
||||
if (clipEnd > start && clipStart < start+len)
|
||||
{
|
||||
// Clip sample region and Get/Put sample region overlap
|
||||
sampleCount samplesToCopy = start+len - clipStart;
|
||||
auto samplesToCopy = start+len - clipStart;
|
||||
if (samplesToCopy > clip->GetNumSamples())
|
||||
samplesToCopy = clip->GetNumSamples();
|
||||
sampleCount inclipDelta = 0;
|
||||
sampleCount startDelta = clipStart - start;
|
||||
auto startDelta = clipStart - start;
|
||||
decltype(startDelta) inclipDelta = 0;
|
||||
if (startDelta < 0)
|
||||
{
|
||||
inclipDelta = -startDelta; // make positive value
|
||||
@ -1428,8 +1428,8 @@ bool WaveTrack::InsertSilence(double t, double len)
|
||||
//Analyses selected region for possible Joined clips and disjoins them
|
||||
bool WaveTrack::Disjoin(double t0, double t1)
|
||||
{
|
||||
sampleCount minSamples = TimeToLongSamples( WAVETRACK_MERGE_POINT_TOLERANCE );
|
||||
sampleCount maxAtOnce = 1048576;
|
||||
auto minSamples = TimeToLongSamples( WAVETRACK_MERGE_POINT_TOLERANCE );
|
||||
size_t maxAtOnce = 1048576;
|
||||
float *buffer = new float[ maxAtOnce ];
|
||||
Regions regions;
|
||||
|
||||
@ -1456,8 +1456,8 @@ bool WaveTrack::Disjoin(double t0, double t1)
|
||||
clip->TimeToSamplesClip( startTime, &start );
|
||||
clip->TimeToSamplesClip( endTime, &end );
|
||||
|
||||
sampleCount len = ( end - start );
|
||||
for( sampleCount done = 0; done < len; done += maxAtOnce )
|
||||
auto len = ( end - start );
|
||||
for( decltype(len) done = 0; done < len; done += maxAtOnce )
|
||||
{
|
||||
auto numSamples = limitSampleBufferSize( maxAtOnce, len - done );
|
||||
|
||||
@ -1465,7 +1465,7 @@ bool WaveTrack::Disjoin(double t0, double t1)
|
||||
numSamples );
|
||||
for( decltype(numSamples) i = 0; i < numSamples; i++ )
|
||||
{
|
||||
sampleCount curSamplePos = start + done + i;
|
||||
auto curSamplePos = start + done + i;
|
||||
|
||||
//start a NEW sequence
|
||||
if( buffer[ i ] == 0.0 && seqStart == -1 )
|
||||
@ -1474,7 +1474,7 @@ bool WaveTrack::Disjoin(double t0, double t1)
|
||||
{
|
||||
if( seqStart != -1 )
|
||||
{
|
||||
sampleCount seqEnd;
|
||||
decltype(end) seqEnd;
|
||||
|
||||
//consider the end case, where selection ends in zeroes
|
||||
if( curSamplePos == end - 1 && buffer[ i ] == 0.0 )
|
||||
@ -1597,8 +1597,8 @@ sampleCount WaveTrack::GetBlockStart(sampleCount s) const
|
||||
{
|
||||
for (const auto &clip : mClips)
|
||||
{
|
||||
const sampleCount startSample = (sampleCount)floor(0.5 + clip->GetStartTime()*mRate);
|
||||
const sampleCount endSample = startSample + clip->GetNumSamples();
|
||||
const auto startSample = (sampleCount)floor(0.5 + clip->GetStartTime()*mRate);
|
||||
const auto endSample = startSample + clip->GetNumSamples();
|
||||
if (s >= startSample && s < endSample)
|
||||
return startSample + clip->GetSequence()->GetBlockStart(s - startSample);
|
||||
}
|
||||
@ -1608,12 +1608,12 @@ sampleCount WaveTrack::GetBlockStart(sampleCount s) const
|
||||
|
||||
sampleCount WaveTrack::GetBestBlockSize(sampleCount s) const
|
||||
{
|
||||
sampleCount bestBlockSize = GetMaxBlockSize();
|
||||
auto bestBlockSize = GetMaxBlockSize();
|
||||
|
||||
for (const auto &clip : mClips)
|
||||
{
|
||||
sampleCount startSample = (sampleCount)floor(clip->GetStartTime()*mRate + 0.5);
|
||||
sampleCount endSample = startSample + clip->GetNumSamples();
|
||||
auto startSample = (sampleCount)floor(clip->GetStartTime()*mRate + 0.5);
|
||||
auto endSample = startSample + clip->GetNumSamples();
|
||||
if (s >= startSample && s < endSample)
|
||||
{
|
||||
bestBlockSize = clip->GetSequence()->GetBestBlockSize(s - startSample);
|
||||
@ -1851,7 +1851,7 @@ bool WaveTrack::Unlock() const
|
||||
|
||||
AUDACITY_DLL_API sampleCount WaveTrack::TimeToLongSamples(double t0) const
|
||||
{
|
||||
return (sampleCount)floor(t0 * mRate + 0.5);
|
||||
return floor(t0 * mRate + 0.5);
|
||||
}
|
||||
|
||||
double WaveTrack::LongSamplesToTime(sampleCount pos) const
|
||||
@ -2025,17 +2025,17 @@ bool WaveTrack::Get(samplePtr buffer, sampleFormat format,
|
||||
|
||||
for (const auto &clip: mClips)
|
||||
{
|
||||
sampleCount clipStart = clip->GetStartSample();
|
||||
sampleCount clipEnd = clip->GetEndSample();
|
||||
auto clipStart = clip->GetStartSample();
|
||||
auto clipEnd = clip->GetEndSample();
|
||||
|
||||
if (clipEnd > start && clipStart < start+len)
|
||||
{
|
||||
// Clip sample region and Get/Put sample region overlap
|
||||
sampleCount samplesToCopy = start+len - clipStart;
|
||||
auto samplesToCopy = start+len - clipStart;
|
||||
if (samplesToCopy > clip->GetNumSamples())
|
||||
samplesToCopy = clip->GetNumSamples();
|
||||
sampleCount inclipDelta = 0;
|
||||
sampleCount startDelta = clipStart - start;
|
||||
auto startDelta = clipStart - start;
|
||||
decltype(startDelta) inclipDelta = 0;
|
||||
if (startDelta < 0)
|
||||
{
|
||||
inclipDelta = -startDelta; // make positive value
|
||||
@ -2062,17 +2062,17 @@ bool WaveTrack::Set(samplePtr buffer, sampleFormat format,
|
||||
|
||||
for (const auto &clip: mClips)
|
||||
{
|
||||
sampleCount clipStart = clip->GetStartSample();
|
||||
sampleCount clipEnd = clip->GetEndSample();
|
||||
auto clipStart = clip->GetStartSample();
|
||||
auto clipEnd = clip->GetEndSample();
|
||||
|
||||
if (clipEnd > start && clipStart < start+len)
|
||||
{
|
||||
// Clip sample region and Get/Put sample region overlap
|
||||
sampleCount samplesToCopy = start+len - clipStart;
|
||||
auto samplesToCopy = start+len - clipStart;
|
||||
if (samplesToCopy > clip->GetNumSamples())
|
||||
samplesToCopy = clip->GetNumSamples();
|
||||
sampleCount inclipDelta = 0;
|
||||
sampleCount startDelta = clipStart - start;
|
||||
auto startDelta = clipStart - start;
|
||||
decltype(startDelta) inclipDelta = 0;
|
||||
if (startDelta < 0)
|
||||
{
|
||||
inclipDelta = -startDelta; // make positive value
|
||||
@ -2106,7 +2106,7 @@ void WaveTrack::GetEnvelopeValues(double *buffer, size_t bufferLen,
|
||||
// be set twice. Unfortunately, there is no easy way around this since the clips are not
|
||||
// stored in increasing time order. If they were, we could just track the time as the
|
||||
// buffer is filled.
|
||||
for (int i = 0; i < bufferLen; i++)
|
||||
for (decltype(bufferLen) i = 0; i < bufferLen; i++)
|
||||
{
|
||||
buffer[i] = 1.0;
|
||||
}
|
||||
@ -2127,7 +2127,7 @@ void WaveTrack::GetEnvelopeValues(double *buffer, size_t bufferLen,
|
||||
|
||||
if (rt0 < dClipStartTime)
|
||||
{
|
||||
sampleCount nDiff = (sampleCount)floor((dClipStartTime - rt0) * mRate + 0.5);
|
||||
auto nDiff = (sampleCount)floor((dClipStartTime - rt0) * mRate + 0.5);
|
||||
rbuf += nDiff;
|
||||
wxASSERT(nDiff <= rlen);
|
||||
rlen -= nDiff;
|
||||
@ -2171,10 +2171,8 @@ WaveClip* WaveTrack::GetClipAtSample(sampleCount sample)
|
||||
{
|
||||
for (const auto &clip: mClips)
|
||||
{
|
||||
sampleCount start, len;
|
||||
|
||||
start = clip->GetStartSample();
|
||||
len = clip->GetNumSamples();
|
||||
auto start = clip->GetStartSample();
|
||||
auto len = clip->GetNumSamples();
|
||||
|
||||
if (sample >= start && sample < start + len)
|
||||
return clip.get();
|
||||
@ -2623,7 +2621,7 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
|
||||
sampleCount start, sampleCount len)
|
||||
{
|
||||
if (format == floatSample && len > 0) {
|
||||
const sampleCount end = start + len;
|
||||
const auto end = start + len;
|
||||
|
||||
bool fillFirst = (mNValidBuffers < 1);
|
||||
bool fillSecond = (mNValidBuffers < 2);
|
||||
@ -2669,9 +2667,9 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
|
||||
|
||||
// Refill buffers as needed
|
||||
if (fillFirst) {
|
||||
const sampleCount start0 = mPTrack->GetBlockStart(start);
|
||||
const auto start0 = mPTrack->GetBlockStart(start);
|
||||
if (start0 >= 0) {
|
||||
const sampleCount len0 = mPTrack->GetBestBlockSize(start0);
|
||||
const auto len0 = mPTrack->GetBestBlockSize(start0);
|
||||
wxASSERT(len0 <= mBufferSize);
|
||||
if (!mPTrack->Get(samplePtr(mBuffers[0].data), floatSample, start0, len0))
|
||||
return 0;
|
||||
@ -2693,11 +2691,11 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
|
||||
wxASSERT(!fillSecond || mNValidBuffers > 0);
|
||||
if (fillSecond) {
|
||||
mNValidBuffers = 1;
|
||||
const sampleCount end0 = mBuffers[0].end();
|
||||
const auto end0 = mBuffers[0].end();
|
||||
if (end > end0) {
|
||||
const sampleCount start1 = mPTrack->GetBlockStart(end0);
|
||||
const auto start1 = mPTrack->GetBlockStart(end0);
|
||||
if (start1 == end0) {
|
||||
const sampleCount len1 = mPTrack->GetBestBlockSize(start1);
|
||||
const auto len1 = mPTrack->GetBestBlockSize(start1);
|
||||
wxASSERT(len1 <= mBufferSize);
|
||||
if (!mPTrack->Get(samplePtr(mBuffers[1].data), floatSample, start1, len1))
|
||||
return 0;
|
||||
@ -2710,7 +2708,7 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
|
||||
wxASSERT(mNValidBuffers < 2 || mBuffers[0].end() == mBuffers[1].start);
|
||||
|
||||
samplePtr buffer = 0;
|
||||
sampleCount remaining = len;
|
||||
auto remaining = len;
|
||||
|
||||
// Possibly get an initial portion that is uncached
|
||||
|
||||
@ -2731,8 +2729,9 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
|
||||
|
||||
// Now satisfy the request from the buffers
|
||||
for (int ii = 0; ii < mNValidBuffers && remaining > 0; ++ii) {
|
||||
const sampleCount starti = start - mBuffers[ii].start;
|
||||
const sampleCount leni = std::min(remaining, mBuffers[ii].len - starti);
|
||||
const auto starti = start - mBuffers[ii].start;
|
||||
const auto leni =
|
||||
std::min( sampleCount( remaining ), mBuffers[ii].len - starti );
|
||||
if (initLen == 0 && leni == len) {
|
||||
// All is contiguous already. We can completely avoid copying
|
||||
return samplePtr(mBuffers[ii].data + starti);
|
||||
|
@ -298,7 +298,7 @@ BlockFilePtr LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar
|
||||
sampleCount len, sampleFormat format)
|
||||
{
|
||||
wxFileNameWrapper fileName;
|
||||
sampleCount summaryLen = 0;
|
||||
size_t summaryLen = 0;
|
||||
bool noRMS = false;
|
||||
long nValue;
|
||||
|
||||
@ -324,6 +324,7 @@ BlockFilePtr LegacyBlockFile::BuildFromXML(const wxString &projDir, const wxChar
|
||||
else if (!wxStrcmp(attr, wxT("format")) && XMLValueChecker::IsValidSampleFormat(nValue))
|
||||
format = (sampleFormat)nValue;
|
||||
else if (!wxStrcmp(attr, wxT("summarylen")) && (nValue > 0))
|
||||
// Note attribute "summarylen" was written as int, no need for 64 bits
|
||||
summaryLen = nValue;
|
||||
}
|
||||
}
|
||||
|
@ -98,15 +98,15 @@ bool CompareAudioCommand::Apply(CommandExecutionContext context)
|
||||
double errorThreshold = GetDouble(wxT("Threshold"));
|
||||
|
||||
// Initialize buffers for track data to be analyzed
|
||||
int buffSize = min(mTrack0->GetMaxBlockSize(), mTrack1->GetMaxBlockSize());
|
||||
auto buffSize = std::min(mTrack0->GetMaxBlockSize(), mTrack1->GetMaxBlockSize());
|
||||
float *buff0 = new float[buffSize];
|
||||
float *buff1 = new float[buffSize];
|
||||
|
||||
// Compare tracks block by block
|
||||
long s0 = mTrack0->TimeToLongSamples(mT0);
|
||||
long s1 = mTrack0->TimeToLongSamples(mT1);
|
||||
long position = s0;
|
||||
long length = s1 - s0;
|
||||
auto s0 = mTrack0->TimeToLongSamples(mT0);
|
||||
auto s1 = mTrack0->TimeToLongSamples(mT1);
|
||||
auto position = s0;
|
||||
auto length = s1 - s0;
|
||||
while (position < s1)
|
||||
{
|
||||
// Get a block of data into the buffers
|
||||
|
@ -111,7 +111,7 @@ int EffectAmplify::GetAudioOutCount()
|
||||
|
||||
sampleCount EffectAmplify::ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen)
|
||||
{
|
||||
for (sampleCount i = 0; i < blockLen; i++)
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++)
|
||||
{
|
||||
outBlock[0][i] = inBlock[0][i] * mRatio;
|
||||
}
|
||||
|
@ -254,16 +254,14 @@ void EffectAutoDuck::End()
|
||||
|
||||
bool EffectAutoDuck::Process()
|
||||
{
|
||||
sampleCount i;
|
||||
|
||||
if (GetNumWaveTracks() == 0 || !mControlTrack)
|
||||
return false;
|
||||
|
||||
bool cancel = false;
|
||||
|
||||
sampleCount start =
|
||||
auto start =
|
||||
mControlTrack->TimeToLongSamples(mT0 + mOuterFadeDownLen);
|
||||
sampleCount end =
|
||||
auto end =
|
||||
mControlTrack->TimeToLongSamples(mT1 - mOuterFadeUpLen);
|
||||
|
||||
if (end <= start)
|
||||
@ -277,7 +275,7 @@ bool EffectAutoDuck::Process()
|
||||
if (maxPause < mOuterFadeDownLen + mOuterFadeUpLen)
|
||||
maxPause = mOuterFadeDownLen + mOuterFadeUpLen;
|
||||
|
||||
sampleCount minSamplesPause =
|
||||
auto minSamplesPause =
|
||||
mControlTrack->TimeToLongSamples(maxPause);
|
||||
|
||||
double threshold = DB_TO_LINEAR(mThresholdDb);
|
||||
@ -288,7 +286,7 @@ bool EffectAutoDuck::Process()
|
||||
int rmsPos = 0;
|
||||
float rmsSum = 0;
|
||||
float *rmsWindow = new float[kRMSWindowSize];
|
||||
for (i = 0; i < kRMSWindowSize; i++)
|
||||
for (size_t i = 0; i < kRMSWindowSize; i++)
|
||||
rmsWindow[i] = 0;
|
||||
|
||||
float *buf = new float[kBufSize];
|
||||
@ -302,15 +300,15 @@ bool EffectAutoDuck::Process()
|
||||
// to make the progress bar appear more natural, we first look for all
|
||||
// duck regions and apply them all at once afterwards
|
||||
AutoDuckRegionArray regions;
|
||||
sampleCount pos = start;
|
||||
auto pos = start;
|
||||
|
||||
while (pos < end)
|
||||
{
|
||||
const auto len = limitSampleBufferSize( kBufSize, end - pos );
|
||||
|
||||
mControlTrack->Get((samplePtr)buf, floatSample, pos, (sampleCount)len);
|
||||
mControlTrack->Get((samplePtr)buf, floatSample, pos, len);
|
||||
|
||||
for (i = pos; i < pos + len; i++)
|
||||
for (auto i = pos; i < pos + len; i++)
|
||||
{
|
||||
rmsSum -= rmsWindow[rmsPos];
|
||||
rmsWindow[rmsPos] = buf[i - pos] * buf[i - pos];
|
||||
@ -393,7 +391,7 @@ bool EffectAutoDuck::Process()
|
||||
|
||||
WaveTrack* t = (WaveTrack*)iterTrack;
|
||||
|
||||
for (i = 0; i < (int)regions.GetCount(); i++)
|
||||
for (size_t i = 0; i < regions.GetCount(); i++)
|
||||
{
|
||||
const AutoDuckRegion& region = regions[i];
|
||||
if (ApplyDuckFade(trackNumber, t, region.t0, region.t1))
|
||||
@ -513,18 +511,18 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNumber, WaveTrack* t,
|
||||
{
|
||||
bool cancel = false;
|
||||
|
||||
sampleCount start = t->TimeToLongSamples(t0);
|
||||
sampleCount end = t->TimeToLongSamples(t1);
|
||||
auto start = t->TimeToLongSamples(t0);
|
||||
auto end = t->TimeToLongSamples(t1);
|
||||
|
||||
float *buf = new float[kBufSize];
|
||||
sampleCount pos = start;
|
||||
auto pos = start;
|
||||
|
||||
int fadeDownSamples = t->TimeToLongSamples(
|
||||
auto fadeDownSamples = t->TimeToLongSamples(
|
||||
mOuterFadeDownLen + mInnerFadeDownLen);
|
||||
if (fadeDownSamples < 1)
|
||||
fadeDownSamples = 1;
|
||||
|
||||
int fadeUpSamples = t->TimeToLongSamples(
|
||||
auto fadeUpSamples = t->TimeToLongSamples(
|
||||
mOuterFadeUpLen + mInnerFadeUpLen);
|
||||
if (fadeUpSamples < 1)
|
||||
fadeUpSamples = 1;
|
||||
@ -538,7 +536,7 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNumber, WaveTrack* t,
|
||||
|
||||
t->Get((samplePtr)buf, floatSample, pos, len);
|
||||
|
||||
for (sampleCount i = pos; i < pos + len; i++)
|
||||
for (auto i = pos; i < pos + len; i++)
|
||||
{
|
||||
float gainDown = fadeDownStep * (i - start);
|
||||
float gainUp = fadeUpStep * (end - i);;
|
||||
|
@ -361,7 +361,7 @@ sampleCount EffectBassTreble::InstanceProcess(EffectBassTrebleState & data,
|
||||
data.a0Treble, data.a1Treble, data.a2Treble,
|
||||
data.b0Treble, data.b1Treble, data.b2Treble);
|
||||
|
||||
for (sampleCount i = 0; i < blockLen; i++) {
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++) {
|
||||
obuf[i] = DoFilter(data, ibuf[i]) * data.gain;
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ void EffectChangePitch::DeduceFrequencies()
|
||||
|
||||
double trackStart = track->GetStartTime();
|
||||
double t0 = mT0 < trackStart? trackStart: mT0;
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
|
||||
int analyzeSize = windowSize * numWindows;
|
||||
float * buffer;
|
||||
|
@ -252,8 +252,8 @@ bool EffectChangeSpeed::Process()
|
||||
// Process only if the right marker is to the right of the left marker
|
||||
if (mCurT1 > mCurT0) {
|
||||
//Transform the marker timepoints to samples
|
||||
sampleCount start = pOutWaveTrack->TimeToLongSamples(mCurT0);
|
||||
sampleCount end = pOutWaveTrack->TimeToLongSamples(mCurT1);
|
||||
auto start = pOutWaveTrack->TimeToLongSamples(mCurT0);
|
||||
auto end = pOutWaveTrack->TimeToLongSamples(mCurT1);
|
||||
|
||||
//ProcessOne() (implemented below) processes a single track
|
||||
if (!ProcessOne(pOutWaveTrack, start, end))
|
||||
@ -485,11 +485,11 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
|
||||
|
||||
// Initiate processing buffers, most likely shorter than
|
||||
// the length of the selection being processed.
|
||||
sampleCount inBufferSize = track->GetMaxBlockSize();
|
||||
auto inBufferSize = track->GetMaxBlockSize();
|
||||
|
||||
float * inBuffer = new float[inBufferSize];
|
||||
|
||||
sampleCount outBufferSize =
|
||||
auto outBufferSize =
|
||||
(sampleCount)((mFactor * inBufferSize) + 10);
|
||||
float * outBuffer = new float[outBufferSize];
|
||||
|
||||
@ -499,11 +499,10 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
|
||||
//Go through the track one buffer at a time. samplePos counts which
|
||||
//sample the current buffer starts at.
|
||||
bool bResult = true;
|
||||
sampleCount blockSize;
|
||||
sampleCount samplePos = start;
|
||||
auto samplePos = start;
|
||||
while (samplePos < end) {
|
||||
//Get a blockSize of samples (smaller than the size of the buffer)
|
||||
blockSize = track->GetBestBlockSize(samplePos);
|
||||
auto blockSize = track->GetBestBlockSize(samplePos);
|
||||
|
||||
//Adjust the block size if it is the final block in the track
|
||||
if (samplePos + blockSize > end)
|
||||
|
@ -172,9 +172,9 @@ bool EffectClickRemoval::Process()
|
||||
double t1 = mT1 > trackEnd? trackEnd: mT1;
|
||||
|
||||
if (t1 > t0) {
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
|
||||
if (!ProcessOne(count, track, start, len))
|
||||
{
|
||||
@ -207,17 +207,17 @@ bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount st
|
||||
return false;
|
||||
}
|
||||
|
||||
sampleCount idealBlockLen = track->GetMaxBlockSize() * 4;
|
||||
auto idealBlockLen = track->GetMaxBlockSize() * 4;
|
||||
if (idealBlockLen % windowSize != 0)
|
||||
idealBlockLen += (windowSize - (idealBlockLen % windowSize));
|
||||
|
||||
bool bResult = true;
|
||||
sampleCount s = 0;
|
||||
decltype(len) s = 0;
|
||||
float *buffer = new float[idealBlockLen];
|
||||
float *datawindow = new float[windowSize];
|
||||
while ((s < len) && ((len - s) > windowSize/2))
|
||||
{
|
||||
sampleCount block = idealBlockLen;
|
||||
auto block = idealBlockLen;
|
||||
if (s + block > len)
|
||||
block = len - s;
|
||||
|
||||
|
@ -366,11 +366,11 @@ bool EffectCompressor::InitPass1()
|
||||
DisableSecondPass();
|
||||
|
||||
// Find the maximum block length required for any track
|
||||
sampleCount maxlen=0;
|
||||
size_t maxlen = 0;
|
||||
SelectedTrackListOfKindIterator iter(Track::Wave, mTracks);
|
||||
WaveTrack *track = (WaveTrack *) iter.First();
|
||||
while (track) {
|
||||
sampleCount len=track->GetMaxBlockSize();
|
||||
auto len = track->GetMaxBlockSize();
|
||||
if(len > maxlen)
|
||||
maxlen = len;
|
||||
//Iterate to the next track
|
||||
|
@ -69,8 +69,8 @@ bool ContrastDialog::GetDB(float &dB)
|
||||
if(mT1 > t->GetEndTime())
|
||||
mT1 = t->GetEndTime();
|
||||
|
||||
sampleCount SelT0 = t->TimeToLongSamples(mT0);
|
||||
sampleCount SelT1 = t->TimeToLongSamples(mT1);
|
||||
auto SelT0 = t->TimeToLongSamples(mT0);
|
||||
auto SelT1 = t->TimeToLongSamples(mT1);
|
||||
|
||||
if(SelT0 > SelT1)
|
||||
{
|
||||
|
@ -524,7 +524,7 @@ sampleCount EffectDistortion::InstanceProcess(EffectDistortionState& data, float
|
||||
data.param1 = mParams.mParam1;
|
||||
data.repeats = mParams.mRepeats;
|
||||
|
||||
for (sampleCount i = 0; i < blockLen; i++) {
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++) {
|
||||
if (update && ((data.skipcount++) % skipsamples == 0)) {
|
||||
MakeTable();
|
||||
}
|
||||
|
@ -117,13 +117,13 @@ bool EffectDtmf::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames
|
||||
// extra samples may get created as mDuration may now be > mT1 - mT0;
|
||||
// However we are making our best efforts at creating what was asked for.
|
||||
|
||||
sampleCount nT0 = (sampleCount)floor(mT0 * mSampleRate + 0.5);
|
||||
sampleCount nT1 = (sampleCount)floor((mT0 + duration) * mSampleRate + 0.5);
|
||||
auto nT0 = (sampleCount)floor(mT0 * mSampleRate + 0.5);
|
||||
auto nT1 = (sampleCount)floor((mT0 + duration) * mSampleRate + 0.5);
|
||||
numSamplesSequence = nT1 - nT0; // needs to be exact number of samples selected
|
||||
|
||||
//make under-estimates if anything, and then redistribute the few remaining samples
|
||||
numSamplesTone = (sampleCount)floor(dtmfTone * mSampleRate);
|
||||
numSamplesSilence = (sampleCount)floor(dtmfSilence * mSampleRate);
|
||||
numSamplesTone = floor(dtmfTone * mSampleRate);
|
||||
numSamplesSilence = floor(dtmfSilence * mSampleRate);
|
||||
|
||||
// recalculate the sum, and spread the difference - due to approximations.
|
||||
// Since diff should be in the order of "some" samples, a division (resulting in zero)
|
||||
@ -153,7 +153,7 @@ bool EffectDtmf::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames
|
||||
sampleCount EffectDtmf::ProcessBlock(float **WXUNUSED(inbuf), float **outbuf, sampleCount size)
|
||||
{
|
||||
float *buffer = outbuf[0];
|
||||
sampleCount processed = 0;
|
||||
decltype(size) processed = 0;
|
||||
|
||||
// for the whole dtmf sequence, we will be generating either tone or silence
|
||||
// according to a bool value, and this might be done in small chunks of size
|
||||
@ -527,14 +527,14 @@ bool EffectDtmf::MakeDtmfTone(float *buffer, sampleCount len, float fs, wxChar t
|
||||
|
||||
// now generate the wave: 'last' is used to avoid phase errors
|
||||
// when inside the inner for loop of the Process() function.
|
||||
for(sampleCount i=0; i<len; i++) {
|
||||
for(decltype(len) i = 0; i < len; i++) {
|
||||
buffer[i]=amplitude*0.5*(sin(A*(i+last))+sin(B*(i+last)));
|
||||
}
|
||||
|
||||
// generate a fade-in of duration 1/250th of second
|
||||
if (last == 0) {
|
||||
A = (fs / kFadeInOut);
|
||||
for(sampleCount i = 0; i < A; i++) {
|
||||
for(size_t i = 0; i < A; i++) {
|
||||
buffer[i] *= i/A;
|
||||
}
|
||||
}
|
||||
@ -544,11 +544,11 @@ bool EffectDtmf::MakeDtmfTone(float *buffer, sampleCount len, float fs, wxChar t
|
||||
// we are at the last buffer of 'len' size, so, offset is to
|
||||
// backup 'A' samples, from 'len'
|
||||
A = (fs / kFadeInOut);
|
||||
sampleCount offset = len - (sampleCount)(fs / kFadeInOut);
|
||||
auto offset = len - decltype(len)(fs / kFadeInOut);
|
||||
// protect against negative offset, which can occur if too a
|
||||
// small selection is made
|
||||
if (offset >= 0) {
|
||||
for(sampleCount i = 0; i < A; i++) {
|
||||
for(size_t i = 0; i < A; i++) {
|
||||
buffer[i + offset] *= (1 - (i / A));
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ sampleCount EffectEcho::ProcessBlock(float **inBlock, float **outBlock, sampleCo
|
||||
float *ibuf = inBlock[0];
|
||||
float *obuf = outBlock[0];
|
||||
|
||||
for (sampleCount i = 0; i < blockLen; i++, histPos++)
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++, histPos++)
|
||||
{
|
||||
if (histPos == histLen)
|
||||
{
|
||||
|
@ -1289,7 +1289,6 @@ bool Effect::ProcessPass()
|
||||
|
||||
ChannelName map[3];
|
||||
|
||||
sampleCount prevBufferSize = 0;
|
||||
mBufferSize = 0;
|
||||
mBlockSize = 0;
|
||||
|
||||
@ -1374,12 +1373,12 @@ bool Effect::ProcessPass()
|
||||
SetSampleRate(left->GetRate());
|
||||
|
||||
// Get the block size the client wants to use
|
||||
sampleCount max = left->GetMaxBlockSize() * 2;
|
||||
auto max = left->GetMaxBlockSize() * 2;
|
||||
mBlockSize = SetBlockSize(max);
|
||||
|
||||
// Calculate the buffer size to be at least the max rounded up to the clients
|
||||
// selected block size.
|
||||
prevBufferSize = mBufferSize;
|
||||
const auto prevBufferSize = mBufferSize;
|
||||
mBufferSize = ((max + (mBlockSize - 1)) / mBlockSize) * mBlockSize;
|
||||
|
||||
// If the buffer size has changed, then (re)allocate the buffers
|
||||
@ -1536,24 +1535,23 @@ bool Effect::ProcessTrack(int count,
|
||||
// there is no further input data to process, the loop continues to call the
|
||||
// effect with an empty input buffer until the effect has had a chance to
|
||||
// return all of the remaining delayed samples.
|
||||
sampleCount inLeftPos = leftStart;
|
||||
sampleCount inRightPos = rightStart;
|
||||
sampleCount outLeftPos = leftStart;
|
||||
sampleCount outRightPos = rightStart;
|
||||
auto inLeftPos = leftStart;
|
||||
auto inRightPos = rightStart;
|
||||
auto outLeftPos = leftStart;
|
||||
auto outRightPos = rightStart;
|
||||
|
||||
sampleCount inputRemaining = len;
|
||||
sampleCount delayRemaining = 0;
|
||||
sampleCount curBlockSize = 0;
|
||||
sampleCount curDelay = 0;
|
||||
auto inputRemaining = len;
|
||||
decltype(GetLatency()) curDelay = 0, delayRemaining = 0;
|
||||
decltype(mBlockSize) curBlockSize = 0;
|
||||
|
||||
size_t inputBufferCnt = 0;
|
||||
sampleCount outputBufferCnt = 0;
|
||||
decltype(mBufferSize) inputBufferCnt = 0;
|
||||
decltype(mBufferSize) outputBufferCnt = 0;
|
||||
bool cleared = false;
|
||||
|
||||
int chans = wxMin(mNumAudioOut, mNumChannels);
|
||||
|
||||
std::unique_ptr<WaveTrack> genLeft, genRight;
|
||||
sampleCount genLength = 0;
|
||||
decltype(len) genLength = 0;
|
||||
bool isGenerator = GetType() == EffectTypeGenerate;
|
||||
bool isProcessor = GetType() == EffectTypeProcess;
|
||||
double genDur = 0;
|
||||
@ -1616,10 +1614,10 @@ bool Effect::ProcessTrack(int count,
|
||||
|
||||
// Clear the remainder of the buffers so that a full block can be passed
|
||||
// to the effect
|
||||
sampleCount cnt = mBlockSize - curBlockSize;
|
||||
auto cnt = mBlockSize - curBlockSize;
|
||||
for (int i = 0; i < mNumChannels; i++)
|
||||
{
|
||||
for (int j = 0 ; j < cnt; j++)
|
||||
for (decltype(cnt) j = 0 ; j < cnt; j++)
|
||||
{
|
||||
mInBufPos[i][j + curBlockSize] = 0.0;
|
||||
}
|
||||
@ -1668,7 +1666,7 @@ bool Effect::ProcessTrack(int count,
|
||||
}
|
||||
|
||||
// Finally call the plugin to process the block
|
||||
sampleCount processed;
|
||||
decltype(curBlockSize) processed;
|
||||
try
|
||||
{
|
||||
processed = ProcessBlock(mInBufPos, mOutBufPos, curBlockSize);
|
||||
@ -1701,7 +1699,7 @@ bool Effect::ProcessTrack(int count,
|
||||
// Get the current number of delayed samples and accumulate
|
||||
if (isProcessor)
|
||||
{
|
||||
sampleCount delay = GetLatency();
|
||||
auto delay = GetLatency();
|
||||
curDelay += delay;
|
||||
delayRemaining += delay;
|
||||
|
||||
@ -2020,8 +2018,8 @@ void Effect::GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len)
|
||||
|
||||
if (t1 > t0) {
|
||||
*start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
*len = (sampleCount)(end - *start);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
*len = end - *start;
|
||||
}
|
||||
else {
|
||||
*start = 0;
|
||||
@ -2374,7 +2372,7 @@ sampleCount Effect::RealtimeProcess(int group,
|
||||
float **clientIn = (float **) alloca(mNumAudioIn * sizeof(float *));
|
||||
float **clientOut = (float **) alloca(mNumAudioOut * sizeof(float *));
|
||||
float *dummybuf = (float *) alloca(numSamples * sizeof(float));
|
||||
sampleCount len = 0;
|
||||
decltype(numSamples) len = 0;
|
||||
int ichans = chans;
|
||||
int ochans = chans;
|
||||
int gchans = chans;
|
||||
@ -2448,9 +2446,9 @@ sampleCount Effect::RealtimeProcess(int group,
|
||||
|
||||
// Finally call the plugin to process the block
|
||||
len = 0;
|
||||
for (sampleCount block = 0; block < numSamples; block += mBlockSize)
|
||||
for (decltype(numSamples) block = 0; block < numSamples; block += mBlockSize)
|
||||
{
|
||||
sampleCount cnt = (block + mBlockSize > numSamples ? numSamples - block : mBlockSize);
|
||||
auto cnt = (block + mBlockSize > numSamples ? numSamples - block : mBlockSize);
|
||||
len += RealtimeProcess(processor, clientIn, clientOut, cnt);
|
||||
|
||||
for (int i = 0 ; i < mNumAudioIn; i++)
|
||||
|
@ -548,9 +548,9 @@ bool EffectEqualization::Process()
|
||||
double t1 = mT1 > trackEnd? trackEnd: mT1;
|
||||
|
||||
if (t1 > t0) {
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
|
||||
if (!ProcessOne(count, track, start, len))
|
||||
{
|
||||
@ -1061,8 +1061,8 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
|
||||
auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
|
||||
|
||||
int L = windowSize - (mM - 1); //Process L samples at a go
|
||||
sampleCount s = start;
|
||||
sampleCount idealBlockLen = t->GetMaxBlockSize() * 4;
|
||||
auto s = start;
|
||||
auto idealBlockLen = t->GetMaxBlockSize() * 4;
|
||||
if (idealBlockLen % L != 0)
|
||||
idealBlockLen += (L - (idealBlockLen % L));
|
||||
|
||||
@ -1073,7 +1073,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
|
||||
float *thisWindow = window1;
|
||||
float *lastWindow = window2;
|
||||
|
||||
sampleCount originalLen = len;
|
||||
auto originalLen = len;
|
||||
|
||||
int i,j;
|
||||
for(i=0; i<windowSize; i++)
|
||||
@ -1086,7 +1086,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
|
||||
|
||||
while (len != 0)
|
||||
{
|
||||
sampleCount block = idealBlockLen;
|
||||
auto block = idealBlockLen;
|
||||
if (block > len)
|
||||
block = len;
|
||||
|
||||
@ -1147,7 +1147,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
|
||||
|
||||
// now move the appropriate bit of the output back to the track
|
||||
// (this could be enhanced in the future to use the tails)
|
||||
double offsetT0 = t->LongSamplesToTime((sampleCount)offset);
|
||||
double offsetT0 = t->LongSamplesToTime(offset);
|
||||
double lenT = t->LongSamplesToTime(originalLen);
|
||||
// 'start' is the sample offset in 't', the passed in track
|
||||
// 'startT' is the equivalent time value
|
||||
|
@ -303,9 +303,9 @@ bool EffectEqualization48x::Process(EffectEqualization* effectEqualization)
|
||||
double t1 = mEffectEqualization->mT1 > trackEnd? trackEnd: mEffectEqualization->mT1;
|
||||
|
||||
if (t1 > t0) {
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
bBreakLoop=RunFunctionSelect(sMathPath, count, track, start, len);
|
||||
if( bBreakLoop )
|
||||
break;
|
||||
@ -367,9 +367,9 @@ bool EffectEqualization48x::TrackCompare()
|
||||
double t1 = mEffectEqualization->mT1 > trackEnd? trackEnd: mEffectEqualization->mT1;
|
||||
|
||||
if (t1 > t0) {
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
bBreakLoop=RunFunctionSelect(sMathPath, count, track, start, len);
|
||||
if( bBreakLoop )
|
||||
break;
|
||||
@ -390,9 +390,9 @@ bool EffectEqualization48x::TrackCompare()
|
||||
double t1 = mEffectEqualization->mT1 > trackEnd? trackEnd: mEffectEqualization->mT1;
|
||||
|
||||
if (t1 > t0) {
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
DeltaTrack(track, track2, start, len);
|
||||
}
|
||||
track = (WaveTrack *) iter.Next();
|
||||
@ -406,21 +406,21 @@ bool EffectEqualization48x::TrackCompare()
|
||||
bool EffectEqualization48x::DeltaTrack(WaveTrack * t, WaveTrack * t2, sampleCount start, sampleCount len)
|
||||
{
|
||||
|
||||
sampleCount trackBlockSize = t->GetMaxBlockSize();
|
||||
auto trackBlockSize = t->GetMaxBlockSize();
|
||||
|
||||
float *buffer1 = new float[trackBlockSize];
|
||||
float *buffer2 = new float[trackBlockSize];
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto output=p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
|
||||
sampleCount originalLen = len;
|
||||
sampleCount currentSample = start;
|
||||
auto originalLen = len;
|
||||
auto currentSample = start;
|
||||
|
||||
while(len) {
|
||||
sampleCount curretLength=(trackBlockSize>len)?len:trackBlockSize;
|
||||
auto curretLength = (trackBlockSize > len) ? len : trackBlockSize;
|
||||
t->Get((samplePtr)buffer1, floatSample, currentSample, curretLength);
|
||||
t2->Get((samplePtr)buffer2, floatSample, currentSample, curretLength);
|
||||
for(int i=0;i<curretLength;i++)
|
||||
for(decltype(curretLength) i=0;i<curretLength;i++)
|
||||
buffer1[i]-=buffer2[i];
|
||||
output->Append((samplePtr)buffer1, floatSample, curretLength);
|
||||
currentSample+=curretLength;
|
||||
@ -479,9 +479,9 @@ bool EffectEqualization48x::Benchmark(EffectEqualization* effectEqualization)
|
||||
double t1 = mEffectEqualization->mT1 > trackEnd? trackEnd: mEffectEqualization->mT1;
|
||||
|
||||
if (t1 > t0) {
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
bBreakLoop=RunFunctionSelect( localMathPath, count, track, start, len);
|
||||
if( bBreakLoop )
|
||||
break;
|
||||
@ -510,7 +510,7 @@ bool EffectEqualization48x::Benchmark(EffectEqualization* effectEqualization)
|
||||
|
||||
bool EffectEqualization48x::ProcessTail(WaveTrack * t, WaveTrack * output, sampleCount start, sampleCount len)
|
||||
{
|
||||
// double offsetT0 = t->LongSamplesToTime((sampleCount)offset);
|
||||
// double offsetT0 = t->LongSamplesToTime(offset);
|
||||
double lenT = t->LongSamplesToTime(len);
|
||||
// 'start' is the sample offset in 't', the passed in track
|
||||
// 'startT' is the equivalent time value
|
||||
@ -632,7 +632,7 @@ bool EffectEqualization48x::ProcessOne1x(int count, WaveTrack * t,
|
||||
{
|
||||
//sampleCount blockCount=len/mBlockSize;
|
||||
|
||||
sampleCount trackBlockSize = t->GetMaxBlockSize();
|
||||
auto trackBlockSize = t->GetMaxBlockSize();
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
|
||||
@ -647,7 +647,7 @@ bool EffectEqualization48x::ProcessOne1x(int count, WaveTrack * t,
|
||||
singleProcessLength=len;
|
||||
else
|
||||
singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(subBufferSize-mBlockSize));
|
||||
sampleCount currentSample=start;
|
||||
auto currentSample=start;
|
||||
bool bBreakLoop = false;
|
||||
for(int bigRun=0;bigRun<bigRuns;bigRun++)
|
||||
{
|
||||
@ -817,7 +817,7 @@ bool EffectEqualization48x::ProcessOne4x(int count, WaveTrack * t,
|
||||
if(len<subBufferSize) // it's not worth 4x processing do a regular process
|
||||
return ProcessOne1x(count, t, start, len);
|
||||
|
||||
sampleCount trackBlockSize = t->GetMaxBlockSize();
|
||||
auto trackBlockSize = t->GetMaxBlockSize();
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
|
||||
@ -827,7 +827,7 @@ bool EffectEqualization48x::ProcessOne4x(int count, WaveTrack * t,
|
||||
int trackBlocksPerBig=subBufferSize/trackBlockSize;
|
||||
int trackLeftovers=subBufferSize-trackBlocksPerBig*trackBlockSize;
|
||||
int singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(subBufferSize-mBlockSize));
|
||||
sampleCount currentSample=start;
|
||||
auto currentSample=start;
|
||||
|
||||
bool bBreakLoop = false;
|
||||
for(int bigRun=0;bigRun<bigRuns;bigRun++)
|
||||
@ -906,13 +906,13 @@ bool EffectEqualization48x::ProcessOne1x4xThreaded(int count, WaveTrack * t,
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
|
||||
|
||||
sampleCount trackBlockSize = t->GetMaxBlockSize();
|
||||
auto trackBlockSize = t->GetMaxBlockSize();
|
||||
mEffectEqualization->TrackProgress(count, 0.0);
|
||||
int bigRuns=len/(subBufferSize-mBlockSize);
|
||||
int trackBlocksPerBig=subBufferSize/trackBlockSize;
|
||||
int trackLeftovers=subBufferSize-trackBlocksPerBig*trackBlockSize;
|
||||
int singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(subBufferSize-mBlockSize));
|
||||
sampleCount currentSample=start;
|
||||
auto currentSample=start;
|
||||
|
||||
int bigBlocksRead=mWorkerDataCount, bigBlocksWritten=0;
|
||||
|
||||
@ -1146,7 +1146,7 @@ bool EffectEqualization48x::ProcessOne8x(int count, WaveTrack * t,
|
||||
if(blockCount<32) // it's not worth 8x processing do a regular process
|
||||
return ProcessOne4x(count, t, start, len);
|
||||
|
||||
sampleCount trackBlockSize = t->GetMaxBlockSize();
|
||||
auto trackBlockSize = t->GetMaxBlockSize();
|
||||
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
|
||||
@ -1156,7 +1156,7 @@ bool EffectEqualization48x::ProcessOne8x(int count, WaveTrack * t,
|
||||
int trackBlocksPerBig=mSubBufferSize/trackBlockSize;
|
||||
int trackLeftovers=mSubBufferSize-trackBlocksPerBig*trackBlockSize;
|
||||
int singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(mSubBufferSize-mBlockSize));
|
||||
sampleCount currentSample=start;
|
||||
auto currentSample=start;
|
||||
|
||||
bool bBreakLoop = false;
|
||||
for(int bigRun=0;bigRun<bigRuns;bigRun++)
|
||||
@ -1203,13 +1203,13 @@ bool EffectEqualization48x::ProcessOne8xThreaded(int count, WaveTrack * t,
|
||||
AudacityProject *p = GetActiveProject();
|
||||
auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
|
||||
|
||||
sampleCount trackBlockSize = t->GetMaxBlockSize();
|
||||
auto trackBlockSize = t->GetMaxBlockSize();
|
||||
mEffectEqualization->TrackProgress(count, 0.0);
|
||||
int bigRuns=len/(mSubBufferSize-mBlockSize);
|
||||
int trackBlocksPerBig=mSubBufferSize/trackBlockSize;
|
||||
int trackLeftovers=mSubBufferSize-trackBlocksPerBig*trackBlockSize;
|
||||
int singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(mSubBufferSize-mBlockSize));
|
||||
sampleCount currentSample=start;
|
||||
auto currentSample=start;
|
||||
|
||||
int bigBlocksRead=mWorkerDataCount, bigBlocksWritten=0;
|
||||
|
||||
|
@ -82,14 +82,14 @@ sampleCount EffectFade::ProcessBlock(float **inBlock, float **outBlock, sampleCo
|
||||
|
||||
if (mFadeIn)
|
||||
{
|
||||
for (sampleCount i = 0; i < blockLen; i++)
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++)
|
||||
{
|
||||
obuf[i] = (ibuf[i] * ((float) mSample++)) / mSampleCnt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (sampleCount i = 0; i < blockLen; i++)
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++)
|
||||
{
|
||||
obuf[i] = (ibuf[i] * ((float) mSampleCnt - 1 - mSample++)) / mSampleCnt;
|
||||
}
|
||||
|
@ -125,9 +125,9 @@ bool EffectFindClipping::Process()
|
||||
double t1 = mT1 > trackEnd ? trackEnd : mT1;
|
||||
|
||||
if (t1 > t0) {
|
||||
sampleCount start = t->TimeToLongSamples(t0);
|
||||
sampleCount end = t->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = t->TimeToLongSamples(t0);
|
||||
auto end = t->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
|
||||
if (!ProcessOne(lt, count, t, start, len)) {
|
||||
return false;
|
||||
@ -153,8 +153,7 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt,
|
||||
sampleCount len)
|
||||
{
|
||||
bool bGoodResult = true;
|
||||
sampleCount s = 0;
|
||||
sampleCount blockSize = (sampleCount) (mStart * 1000);
|
||||
auto blockSize = (sampleCount) (mStart * 1000);
|
||||
|
||||
if (len < mStart) {
|
||||
return true;
|
||||
@ -164,10 +163,8 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt,
|
||||
|
||||
float *ptr = buffer;
|
||||
|
||||
sampleCount startrun = 0;
|
||||
sampleCount stoprun = 0;
|
||||
sampleCount samps = 0;
|
||||
size_t block = 0;
|
||||
decltype(len) s = 0, startrun = 0, stoprun = 0, samps = 0;
|
||||
decltype(blockSize) block = 0;
|
||||
double startTime = -1.0;
|
||||
|
||||
while (s < len) {
|
||||
|
@ -119,7 +119,7 @@ bool BlockGenerator::GenerateTrack(WaveTrack *tmp,
|
||||
{
|
||||
bool bGoodResult = true;
|
||||
numSamples = track.TimeToLongSamples(GetDuration());
|
||||
sampleCount i = 0;
|
||||
decltype(numSamples) i = 0;
|
||||
float *data = new float[tmp->GetMaxBlockSize()];
|
||||
|
||||
while ((i < numSamples) && bGoodResult) {
|
||||
|
@ -69,7 +69,7 @@ sampleCount EffectInvert::ProcessBlock(float **inBlock, float **outBlock, sample
|
||||
float *ibuf = inBlock[0];
|
||||
float *obuf = outBlock[0];
|
||||
|
||||
for (sampleCount i = 0; i < blockLen; i++)
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++)
|
||||
{
|
||||
obuf[i] = -ibuf[i];
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ sampleCount EffectLeveller::ProcessBlock(float **inBlock, float **outBlock, samp
|
||||
float *ibuf = inBlock[0];
|
||||
float *obuf = outBlock[0];
|
||||
|
||||
for (sampleCount i = 0; i < blockLen; i++)
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++)
|
||||
{
|
||||
float frame = ibuf[i];
|
||||
for (int pass = 0; pass < mNumPasses; pass++)
|
||||
|
@ -104,7 +104,7 @@ sampleCount EffectNoise::ProcessBlock(float **WXUNUSED(inbuf), float **outbuf, s
|
||||
{
|
||||
default:
|
||||
case kWhite: // white
|
||||
for (sampleCount i = 0; i < size; i++)
|
||||
for (decltype(size) i = 0; i < size; i++)
|
||||
{
|
||||
buffer[i] = mAmp * ((rand() / div) - 1.0f);
|
||||
}
|
||||
@ -115,7 +115,7 @@ sampleCount EffectNoise::ProcessBlock(float **WXUNUSED(inbuf), float **outbuf, s
|
||||
|
||||
// 0.129f is an experimental normalization factor.
|
||||
amplitude = mAmp * 0.129f;
|
||||
for (sampleCount i = 0; i < size; i++)
|
||||
for (decltype(size) i = 0; i < size; i++)
|
||||
{
|
||||
white = (rand() / div) - 1.0f;
|
||||
buf0 = 0.99886f * buf0 + 0.0555179f * white;
|
||||
@ -142,7 +142,7 @@ sampleCount EffectNoise::ProcessBlock(float **WXUNUSED(inbuf), float **outbuf, s
|
||||
? 9.0 / sqrt(mSampleRate)
|
||||
: 0.01f;
|
||||
|
||||
for (sampleCount i = 0; i < size; i++)
|
||||
for (decltype(size) i = 0; i < size; i++)
|
||||
{
|
||||
white = (rand() / div) - 1.0f;
|
||||
z = leakage * y + white * scaling;
|
||||
|
@ -664,9 +664,9 @@ bool EffectNoiseReduction::Worker::Process
|
||||
double t1 = std::min(trackEnd, mT1);
|
||||
|
||||
if (t1 > t0) {
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
|
||||
if (!ProcessOne(effect, statistics, factory,
|
||||
count, track, start, len))
|
||||
@ -1291,11 +1291,11 @@ bool EffectNoiseReduction::Worker::ProcessOne
|
||||
if(!mDoProfile)
|
||||
outputTrack = factory.NewWaveTrack(track->GetSampleFormat(), track->GetRate());
|
||||
|
||||
sampleCount bufferSize = track->GetMaxBlockSize();
|
||||
auto bufferSize = track->GetMaxBlockSize();
|
||||
FloatVector buffer(bufferSize);
|
||||
|
||||
bool bLoopSuccess = true;
|
||||
sampleCount samplePos = start;
|
||||
auto samplePos = start;
|
||||
while (bLoopSuccess && samplePos < start + len) {
|
||||
//Get a blockSize of samples (smaller than the size of the buffer)
|
||||
const auto blockSize = limitSampleBufferSize(
|
||||
|
@ -222,9 +222,9 @@ bool EffectNoiseRemoval::Process()
|
||||
double t1 = mT1 > trackEnd? trackEnd: mT1;
|
||||
|
||||
if (t1 > t0) {
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
|
||||
if (!ProcessOne(count, track, start, len)) {
|
||||
Cleanup();
|
||||
@ -572,11 +572,11 @@ bool EffectNoiseRemoval::ProcessOne(int count, WaveTrack * track,
|
||||
mOutputTrack = mFactory->NewWaveTrack(track->GetSampleFormat(),
|
||||
track->GetRate());
|
||||
|
||||
sampleCount bufferSize = track->GetMaxBlockSize();
|
||||
auto bufferSize = track->GetMaxBlockSize();
|
||||
float *buffer = new float[bufferSize];
|
||||
|
||||
bool bLoopSuccess = true;
|
||||
sampleCount samplePos = start;
|
||||
auto samplePos = start;
|
||||
while (samplePos < start + len) {
|
||||
//Get a blockSize of samples (smaller than the size of the buffer)
|
||||
//Adjust the block size if it is the final block in the track
|
||||
|
@ -364,7 +364,6 @@ void EffectNormalize::AnalyseTrack(WaveTrack * track, const wxString &msg)
|
||||
bool EffectNormalize::AnalyseDC(WaveTrack * track, const wxString &msg)
|
||||
{
|
||||
bool rc = true;
|
||||
sampleCount s;
|
||||
|
||||
mOffset = 0.0; // we might just return
|
||||
|
||||
@ -372,8 +371,8 @@ bool EffectNormalize::AnalyseDC(WaveTrack * track, const wxString &msg)
|
||||
return(rc);
|
||||
|
||||
//Transform the marker timepoints to samples
|
||||
sampleCount start = track->TimeToLongSamples(mCurT0);
|
||||
sampleCount end = track->TimeToLongSamples(mCurT1);
|
||||
auto start = track->TimeToLongSamples(mCurT0);
|
||||
auto 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
|
||||
@ -389,7 +388,7 @@ bool EffectNormalize::AnalyseDC(WaveTrack * track, const wxString &msg)
|
||||
|
||||
//Go through the track one buffer at a time. s counts which
|
||||
//sample the current buffer starts at.
|
||||
s = start;
|
||||
auto s = start;
|
||||
while (s < end) {
|
||||
//Get a block of samples (smaller than the size of the buffer)
|
||||
//Adjust the block size if it is the final block in the track
|
||||
@ -430,11 +429,10 @@ bool EffectNormalize::AnalyseDC(WaveTrack * track, const wxString &msg)
|
||||
bool EffectNormalize::ProcessOne(WaveTrack * track, const wxString &msg)
|
||||
{
|
||||
bool rc = true;
|
||||
sampleCount s;
|
||||
|
||||
//Transform the marker timepoints to samples
|
||||
sampleCount start = track->TimeToLongSamples(mCurT0);
|
||||
sampleCount end = track->TimeToLongSamples(mCurT1);
|
||||
auto start = track->TimeToLongSamples(mCurT0);
|
||||
auto 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
|
||||
@ -447,7 +445,7 @@ bool EffectNormalize::ProcessOne(WaveTrack * track, const wxString &msg)
|
||||
|
||||
//Go through the track one buffer at a time. s counts which
|
||||
//sample the current buffer starts at.
|
||||
s = start;
|
||||
auto s = start;
|
||||
while (s < end) {
|
||||
//Get a block of samples (smaller than the size of the buffer)
|
||||
//Adjust the block size if it is the final block in the track
|
||||
@ -484,18 +482,14 @@ bool EffectNormalize::ProcessOne(WaveTrack * track, const wxString &msg)
|
||||
|
||||
void EffectNormalize::AnalyzeData(float *buffer, sampleCount len)
|
||||
{
|
||||
sampleCount i;
|
||||
|
||||
for(i=0; i<len; i++)
|
||||
for(decltype(len) i = 0; i < len; i++)
|
||||
mSum += (double)buffer[i];
|
||||
mCount += len;
|
||||
}
|
||||
|
||||
void EffectNormalize::ProcessData(float *buffer, sampleCount len)
|
||||
{
|
||||
sampleCount i;
|
||||
|
||||
for(i=0; i<len; i++) {
|
||||
for(decltype(len) i = 0; i < len; i++) {
|
||||
float adjFrame = (buffer[i] + mOffset) * mMult;
|
||||
buffer[i] = adjFrame;
|
||||
}
|
||||
|
@ -238,9 +238,9 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
|
||||
int stretch_buf_size = GetBufferSize(track->GetRate());
|
||||
double amount = this->mAmount;
|
||||
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(t0);
|
||||
auto end = track->TimeToLongSamples(t1);
|
||||
auto len = end - start;
|
||||
|
||||
int minDuration = stretch_buf_size * 2 + 1;
|
||||
if (len < minDuration){ //error because the selection is too short
|
||||
@ -292,18 +292,17 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
|
||||
|
||||
PaulStretch stretch(amount,stretch_buf_size,track->GetRate());
|
||||
|
||||
sampleCount nget=stretch.get_nsamples_for_fill();
|
||||
auto nget = stretch.get_nsamples_for_fill();
|
||||
|
||||
int bufsize=stretch.poolsize;
|
||||
float *buffer0=new float[bufsize];
|
||||
float *bufferptr0=buffer0;
|
||||
sampleCount outs=0;
|
||||
bool first_time=true;
|
||||
|
||||
int fade_len=100;
|
||||
if (fade_len>(bufsize/2-1)) fade_len=bufsize/2-1;
|
||||
float *fade_track_smps=new float[fade_len];
|
||||
sampleCount s=0;
|
||||
decltype(len) s=0;
|
||||
bool cancelled=false;
|
||||
|
||||
while (s<len){
|
||||
@ -314,7 +313,6 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
|
||||
stretch.process(buffer0,0);
|
||||
};
|
||||
|
||||
outs+=stretch.out_bufsize;
|
||||
s+=nget;
|
||||
|
||||
if (first_time){//blend the the start of the selection
|
||||
|
@ -387,7 +387,7 @@ sampleCount EffectPhaser::InstanceProcess(EffectPhaserState & data, float **inBl
|
||||
data.phase = mPhase * M_PI / 180;
|
||||
data.outgain = DB_TO_LINEAR(mOutGain);
|
||||
|
||||
for (sampleCount i = 0; i < blockLen; i++)
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++)
|
||||
{
|
||||
double in = ibuf[i];
|
||||
|
||||
|
@ -102,14 +102,14 @@ bool EffectRepair::Process()
|
||||
repair_t0 = (repair_t0 < t0? t0: repair_t0);
|
||||
repair_t1 = (repair_t1 > t1? t1: repair_t1);
|
||||
|
||||
sampleCount s0 = track->TimeToLongSamples(t0);
|
||||
sampleCount repair0 = track->TimeToLongSamples(repair_t0);
|
||||
sampleCount repair1 = track->TimeToLongSamples(repair_t1);
|
||||
sampleCount s1 = track->TimeToLongSamples(t1);
|
||||
auto s0 = track->TimeToLongSamples(t0);
|
||||
auto repair0 = track->TimeToLongSamples(repair_t0);
|
||||
auto repair1 = track->TimeToLongSamples(repair_t1);
|
||||
auto s1 = track->TimeToLongSamples(t1);
|
||||
|
||||
sampleCount repairStart = (sampleCount)(repair0 - s0);
|
||||
sampleCount repairLen = (sampleCount)(repair1 - repair0);
|
||||
sampleCount len = (sampleCount)(s1 - s0);
|
||||
auto repairStart = repair0 - s0;
|
||||
auto repairLen = repair1 - repair0;
|
||||
auto len = s1 - s0;
|
||||
|
||||
if (repairLen > 128) {
|
||||
::wxMessageBox(_("The Repair effect is intended to be used on very short sections of damaged audio (up to 128 samples).\n\nZoom in and select a tiny fraction of a second to repair."));
|
||||
|
@ -125,9 +125,9 @@ bool EffectRepeat::Process()
|
||||
{
|
||||
WaveTrack* track = (WaveTrack*)t;
|
||||
|
||||
sampleCount start = track->TimeToLongSamples(mT0);
|
||||
sampleCount end = track->TimeToLongSamples(mT1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(mT0);
|
||||
auto end = track->TimeToLongSamples(mT1);
|
||||
auto len = end - start;
|
||||
double tLen = track->LongSamplesToTime(len);
|
||||
double tc = mT0 + tLen;
|
||||
|
||||
|
@ -217,11 +217,11 @@ sampleCount EffectReverb::ProcessBlock(float **inBlock, float **outBlock, sample
|
||||
|
||||
float const dryMult = mParams.mWetOnly ? 0 : dB_to_linear(mParams.mDryGain);
|
||||
|
||||
sampleCount remaining = blockLen;
|
||||
auto remaining = blockLen;
|
||||
|
||||
while (remaining)
|
||||
{
|
||||
sampleCount len = wxMin(remaining, BLOCK);
|
||||
auto len = std::min(remaining, decltype(remaining)(BLOCK));
|
||||
for (int c = 0; c < mNumChans; c++)
|
||||
{
|
||||
// Write the input samples to the reverb fifo. Returned value is the address of the
|
||||
@ -232,7 +232,7 @@ sampleCount EffectReverb::ProcessBlock(float **inBlock, float **outBlock, sample
|
||||
|
||||
if (mNumChans == 2)
|
||||
{
|
||||
for (sampleCount i = 0; i < len; i++)
|
||||
for (decltype(len) i = 0; i < len; i++)
|
||||
{
|
||||
for (int w = 0; w < 2; w++)
|
||||
{
|
||||
@ -245,7 +245,7 @@ sampleCount EffectReverb::ProcessBlock(float **inBlock, float **outBlock, sample
|
||||
}
|
||||
else
|
||||
{
|
||||
for (sampleCount i = 0; i < len; i++)
|
||||
for (decltype(len) i = 0; i < len; i++)
|
||||
{
|
||||
ochans[0][i] = dryMult *
|
||||
mP[0].dry[i] +
|
||||
|
@ -78,9 +78,9 @@ bool EffectReverse::Process()
|
||||
WaveTrack *track = (WaveTrack*)t;
|
||||
|
||||
if (mT1 > mT0) {
|
||||
sampleCount start = track->TimeToLongSamples(mT0);
|
||||
sampleCount end = track->TimeToLongSamples(mT1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
auto start = track->TimeToLongSamples(mT0);
|
||||
auto end = track->TimeToLongSamples(mT1);
|
||||
auto len = end - start;
|
||||
|
||||
if (!ProcessOneWave(count, track, start, len))
|
||||
{
|
||||
@ -107,7 +107,7 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
||||
{
|
||||
bool rValue = true; // return value
|
||||
|
||||
sampleCount end = (sampleCount) start + len; // start, end, len refer to the selected reverse region
|
||||
auto end = start + len; // start, end, len refer to the selected reverse region
|
||||
|
||||
// STEP 1:
|
||||
// If a reverse selection begins and/or ends at the inside of a clip
|
||||
@ -116,8 +116,8 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
||||
// Beware, the array grows as we loop over it. Use integer subscripts, not iterators.
|
||||
for (int ii = 0; ii < clips.size(); ++ii) {
|
||||
const auto &clip = clips[ii].get();
|
||||
sampleCount clipStart = clip->GetStartSample();
|
||||
sampleCount clipEnd = clip->GetEndSample();
|
||||
auto clipStart = clip->GetStartSample();
|
||||
auto clipEnd = clip->GetEndSample();
|
||||
if (clipStart < start && clipEnd > start && clipEnd <= end) { // the reverse selection begins at the inside of a clip
|
||||
double splitTime = track->LongSamplesToTime(start);
|
||||
track->SplitAt(splitTime);
|
||||
@ -142,7 +142,7 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
||||
|
||||
// used in calculating the offset of clips to rearrange
|
||||
// holds the NEW end position of the current clip
|
||||
sampleCount currentEnd = (sampleCount)end;
|
||||
auto currentEnd = end;
|
||||
|
||||
WaveClipHolders revClips; // holds the reversed clips
|
||||
WaveClipHolders otherClips; // holds the clips that appear after the reverse selection region
|
||||
@ -151,8 +151,8 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
||||
for (i=0; i < clipArray.size(); i++) {
|
||||
|
||||
WaveClip *clip = clipArray[i];
|
||||
sampleCount clipStart = clip->GetStartSample();
|
||||
sampleCount clipEnd = clip->GetEndSample();
|
||||
auto clipStart = clip->GetStartSample();
|
||||
auto clipEnd = clip->GetEndSample();
|
||||
|
||||
if (clipStart >= start && clipEnd <= end) { // if the clip is inside the selected region
|
||||
|
||||
@ -171,9 +171,9 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
||||
}
|
||||
}
|
||||
|
||||
sampleCount revStart = (clipStart >= start)? clipStart: start;
|
||||
sampleCount revEnd = (clipEnd >= end)? end: clipEnd;
|
||||
sampleCount revLen = (sampleCount)revEnd-revStart;
|
||||
auto revStart = (clipStart >= start)? clipStart: start;
|
||||
auto revEnd = (clipEnd >= end)? end: clipEnd;
|
||||
auto revLen = revEnd - revStart;
|
||||
if (revEnd >= revStart) {
|
||||
if(!ProcessOneClip(count, track, revStart, revLen, start, end)) // reverse the clip
|
||||
{
|
||||
@ -181,12 +181,12 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
||||
break;
|
||||
}
|
||||
|
||||
sampleCount clipOffsetStart = (sampleCount)(currentEnd - (clipEnd-clipStart)); // calculate the offset required
|
||||
auto clipOffsetStart = currentEnd - (clipEnd - clipStart); // calculate the offset required
|
||||
double offsetStartTime = track->LongSamplesToTime(clipOffsetStart);
|
||||
if(i+1 < clipArray.size()) // update currentEnd if there is a clip to process next
|
||||
{
|
||||
sampleCount nextClipStart = clipArray[i+1]->GetStartSample();
|
||||
currentEnd = (sampleCount)(currentEnd - (clipEnd - clipStart) - (nextClipStart - clipEnd));
|
||||
auto nextClipStart = clipArray[i+1]->GetStartSample();
|
||||
currentEnd = currentEnd - (clipEnd - clipStart) - (nextClipStart - clipEnd);
|
||||
}
|
||||
|
||||
revClips.push_back(track->RemoveAndReturnClip(clip)); // detach the clip from track
|
||||
@ -218,20 +218,19 @@ bool EffectReverse::ProcessOneClip(int count, WaveTrack *track,
|
||||
{
|
||||
bool rc = true;
|
||||
// keep track of two blocks whose data we will swap
|
||||
sampleCount first = start;
|
||||
sampleCount second;
|
||||
auto first = start;
|
||||
|
||||
sampleCount blockSize = track->GetMaxBlockSize();
|
||||
auto blockSize = track->GetMaxBlockSize();
|
||||
float tmp;
|
||||
float *buffer1 = new float[blockSize];
|
||||
float *buffer2 = new float[blockSize];
|
||||
|
||||
sampleCount originalLen = (sampleCount)originalEnd-originalStart;
|
||||
auto originalLen = originalEnd - originalStart;
|
||||
|
||||
while (len > 1) {
|
||||
auto block =
|
||||
limitSampleBufferSize( track->GetBestBlockSize(first), len / 2 );
|
||||
second = first + (len - block);
|
||||
auto second = first + (len - block);
|
||||
|
||||
track->Get((samplePtr)buffer1, floatSample, first, block);
|
||||
track->Get((samplePtr)buffer2, floatSample, second, block);
|
||||
|
@ -251,10 +251,8 @@ bool EffectSBSMS::Process()
|
||||
|
||||
// Process only if the right marker is to the right of the left marker
|
||||
if (mCurT1 > mCurT0) {
|
||||
sampleCount start;
|
||||
sampleCount end;
|
||||
start = leftTrack->TimeToLongSamples(mCurT0);
|
||||
end = leftTrack->TimeToLongSamples(mCurT1);
|
||||
auto start = leftTrack->TimeToLongSamples(mCurT0);
|
||||
auto end = leftTrack->TimeToLongSamples(mCurT1);
|
||||
|
||||
WaveTrack* rightTrack = NULL;
|
||||
if (leftTrack->GetLinked()) {
|
||||
@ -275,16 +273,18 @@ bool EffectSBSMS::Process()
|
||||
|
||||
mCurTrackNum++; // Increment for rightTrack, too.
|
||||
}
|
||||
sampleCount trackStart = leftTrack->TimeToLongSamples(leftTrack->GetStartTime());
|
||||
sampleCount trackEnd = leftTrack->TimeToLongSamples(leftTrack->GetEndTime());
|
||||
const auto trackStart =
|
||||
leftTrack->TimeToLongSamples(leftTrack->GetStartTime());
|
||||
const auto trackEnd =
|
||||
leftTrack->TimeToLongSamples(leftTrack->GetEndTime());
|
||||
|
||||
// SBSMS has a fixed sample rate - we just convert to its sample rate and then convert back
|
||||
float srTrack = leftTrack->GetRate();
|
||||
float srProcess = bLinkRatePitch?srTrack:44100.0;
|
||||
float srProcess = bLinkRatePitch ? srTrack : 44100.0;
|
||||
|
||||
// the resampler needs a callback to supply its samples
|
||||
ResampleBuf rb;
|
||||
sampleCount maxBlockSize = leftTrack->GetMaxBlockSize();
|
||||
auto maxBlockSize = leftTrack->GetMaxBlockSize();
|
||||
rb.blockSize = maxBlockSize;
|
||||
rb.buf = (audio*)calloc(rb.blockSize,sizeof(audio));
|
||||
rb.leftTrack = leftTrack;
|
||||
@ -293,17 +293,14 @@ bool EffectSBSMS::Process()
|
||||
rb.rightBuffer = (float*)calloc(maxBlockSize,sizeof(float));
|
||||
|
||||
// Samples in selection
|
||||
sampleCount samplesIn = end-start;
|
||||
auto samplesIn = end - start;
|
||||
|
||||
// Samples for SBSMS to process after resampling
|
||||
sampleCount samplesToProcess = (sampleCount) ((float)samplesIn*(srProcess/srTrack));
|
||||
auto samplesToProcess = (sampleCount) ((float)samplesIn*(srProcess/srTrack));
|
||||
|
||||
SlideType outSlideType;
|
||||
SBSMSResampleCB outResampleCB;
|
||||
|
||||
sampleCount processPresamples = 0;
|
||||
sampleCount trackPresamples = 0;
|
||||
|
||||
if(bLinkRatePitch) {
|
||||
rb.bPitch = true;
|
||||
outSlideType = rateSlideType;
|
||||
@ -327,10 +324,18 @@ bool EffectSBSMS::Process()
|
||||
rb.SBSMSBlockSize = rb.sbsms->getInputFrameSize();
|
||||
rb.SBSMSBuf = (audio*)calloc(rb.SBSMSBlockSize,sizeof(audio));
|
||||
|
||||
processPresamples = wxMin(rb.quality->getMaxPresamples(),
|
||||
(long)((float)(start-trackStart)*(srProcess/srTrack)));
|
||||
trackPresamples = wxMin(start-trackStart,
|
||||
(long)((float)(processPresamples)*(srTrack/srProcess)));
|
||||
// Note: width of getMaxPresamples() is only long. Widen it
|
||||
decltype(start) processPresamples = rb.quality->getMaxPresamples();
|
||||
processPresamples =
|
||||
std::min(processPresamples,
|
||||
decltype(processPresamples)
|
||||
((float)(start-trackStart)*(srProcess/srTrack)));
|
||||
|
||||
auto trackPresamples = start - trackStart;
|
||||
trackPresamples =
|
||||
std::min(trackPresamples,
|
||||
decltype(trackPresamples)
|
||||
((float)(processPresamples)*(srTrack/srProcess)));
|
||||
rb.offset = start - trackPresamples;
|
||||
rb.end = trackEnd;
|
||||
rb.iface = std::make_unique<SBSMSEffectInterface>
|
||||
@ -340,7 +345,9 @@ bool EffectSBSMS::Process()
|
||||
// The argument type is only long!
|
||||
static_cast<long> ( static_cast<size_t> (
|
||||
samplesToProcess ) ),
|
||||
processPresamples,
|
||||
// This argument type is also only long!
|
||||
static_cast<long> ( static_cast<size_t> (
|
||||
processPresamples ) ),
|
||||
rb.quality.get());
|
||||
}
|
||||
|
||||
@ -354,7 +361,7 @@ bool EffectSBSMS::Process()
|
||||
sampleCount samplesToOutput = rb.iface->getSamplesToOutput();
|
||||
|
||||
// Samples in output after resampling back
|
||||
sampleCount samplesOut = (sampleCount) ((float)samplesToOutput * (srTrack/srProcess));
|
||||
auto samplesOut = (sampleCount) ((float)samplesToOutput * (srTrack/srProcess));
|
||||
|
||||
// Duration in track time
|
||||
double duration = (mCurT1-mCurT0) * mTotalStretch;
|
||||
|
@ -50,8 +50,8 @@ bool EffectSimpleMono::Process()
|
||||
if (mCurT1 > mCurT0) {
|
||||
|
||||
//Transform the marker timepoints to samples
|
||||
sampleCount start = pOutWaveTrack->TimeToLongSamples(mCurT0);
|
||||
sampleCount end = pOutWaveTrack->TimeToLongSamples(mCurT1);
|
||||
auto start = pOutWaveTrack->TimeToLongSamples(mCurT0);
|
||||
auto end = pOutWaveTrack->TimeToLongSamples(mCurT1);
|
||||
|
||||
//Get the track rate and samples
|
||||
mCurRate = pOutWaveTrack->GetRate();
|
||||
@ -81,7 +81,6 @@ bool EffectSimpleMono::Process()
|
||||
bool EffectSimpleMono::ProcessOne(WaveTrack * track,
|
||||
sampleCount start, sampleCount end)
|
||||
{
|
||||
sampleCount 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
|
||||
@ -93,7 +92,7 @@ bool EffectSimpleMono::ProcessOne(WaveTrack * track,
|
||||
|
||||
//Go through the track one buffer at a time. s counts which
|
||||
//sample the current buffer starts at.
|
||||
s = start;
|
||||
auto s = start;
|
||||
while (s < end) {
|
||||
//Get a block of samples (smaller than the size of the buffer)
|
||||
//Adjust the block size if it is the final block in the track
|
||||
|
@ -105,7 +105,6 @@ bool EffectSoundTouch::Process()
|
||||
|
||||
// Process only if the right marker is to the right of the left marker
|
||||
if (mCurT1 > mCurT0) {
|
||||
sampleCount start, end;
|
||||
|
||||
if (leftTrack->GetLinked()) {
|
||||
double t;
|
||||
@ -120,8 +119,8 @@ bool EffectSoundTouch::Process()
|
||||
mCurT1 = wxMax(mCurT1, t);
|
||||
|
||||
//Transform the marker timepoints to samples
|
||||
start = leftTrack->TimeToLongSamples(mCurT0);
|
||||
end = leftTrack->TimeToLongSamples(mCurT1);
|
||||
auto start = leftTrack->TimeToLongSamples(mCurT0);
|
||||
auto end = leftTrack->TimeToLongSamples(mCurT1);
|
||||
|
||||
//Inform soundtouch there's 2 channels
|
||||
mSoundTouch->setChannels(2);
|
||||
@ -135,8 +134,8 @@ bool EffectSoundTouch::Process()
|
||||
mCurTrackNum++; // Increment for rightTrack, too.
|
||||
} else {
|
||||
//Transform the marker timepoints to samples
|
||||
start = leftTrack->TimeToLongSamples(mCurT0);
|
||||
end = leftTrack->TimeToLongSamples(mCurT1);
|
||||
auto start = leftTrack->TimeToLongSamples(mCurT0);
|
||||
auto end = leftTrack->TimeToLongSamples(mCurT1);
|
||||
|
||||
//Inform soundtouch there's a single channel
|
||||
mSoundTouch->setChannels(1);
|
||||
@ -175,8 +174,6 @@ bool EffectSoundTouch::Process()
|
||||
bool EffectSoundTouch::ProcessOne(WaveTrack *track,
|
||||
sampleCount start, sampleCount end)
|
||||
{
|
||||
sampleCount s;
|
||||
|
||||
mSoundTouch->setSampleRate((unsigned int)(track->GetRate()+0.5));
|
||||
|
||||
auto outputTrack = mFactory->NewWaveTrack(track->GetSampleFormat(), track->GetRate());
|
||||
@ -192,7 +189,7 @@ bool EffectSoundTouch::ProcessOne(WaveTrack *track,
|
||||
|
||||
//Go through the track one buffer at a time. s counts which
|
||||
//sample the current buffer starts at.
|
||||
s = start;
|
||||
auto s = start;
|
||||
while (s < end) {
|
||||
//Get a block of samples (smaller than the size of the buffer)
|
||||
const auto block =
|
||||
@ -269,7 +266,7 @@ bool EffectSoundTouch::ProcessStereo(WaveTrack* leftTrack, WaveTrack* rightTrack
|
||||
// Make soundTouchBuffer twice as big as MaxBlockSize for each channel,
|
||||
// because Soundtouch wants them interleaved, i.e., each
|
||||
// Soundtouch sample is left-right pair.
|
||||
sampleCount maxBlockSize = leftTrack->GetMaxBlockSize();
|
||||
auto maxBlockSize = leftTrack->GetMaxBlockSize();
|
||||
float* leftBuffer = new float[maxBlockSize];
|
||||
float* rightBuffer = new float[maxBlockSize];
|
||||
float* soundTouchBuffer = new float[maxBlockSize * 2];
|
||||
@ -277,7 +274,7 @@ bool EffectSoundTouch::ProcessStereo(WaveTrack* leftTrack, WaveTrack* rightTrack
|
||||
// Go through the track one stereo buffer at a time.
|
||||
// sourceSampleCount counts the sample at which the current buffer starts,
|
||||
// per channel.
|
||||
sampleCount sourceSampleCount = start;
|
||||
auto sourceSampleCount = start;
|
||||
while (sourceSampleCount < end) {
|
||||
//Get a block of samples (smaller than the size of the buffer)
|
||||
//Adjust the block size if it is the final block in the track
|
||||
|
@ -95,12 +95,12 @@ bool EffectStereoToMono::Process()
|
||||
mRightTrack = (WaveTrack *)iter.Next();
|
||||
|
||||
if ((mLeftTrack->GetRate() == mRightTrack->GetRate())) {
|
||||
sampleCount leftTrackStart = mLeftTrack->TimeToLongSamples(mLeftTrack->GetStartTime());
|
||||
sampleCount rightTrackStart = mRightTrack->TimeToLongSamples(mRightTrack->GetStartTime());
|
||||
auto leftTrackStart = mLeftTrack->TimeToLongSamples(mLeftTrack->GetStartTime());
|
||||
auto rightTrackStart = mRightTrack->TimeToLongSamples(mRightTrack->GetStartTime());
|
||||
mStart = wxMin(leftTrackStart, rightTrackStart);
|
||||
|
||||
sampleCount leftTrackEnd = mLeftTrack->TimeToLongSamples(mLeftTrack->GetEndTime());
|
||||
sampleCount rightTrackEnd = mRightTrack->TimeToLongSamples(mRightTrack->GetEndTime());
|
||||
auto leftTrackEnd = mLeftTrack->TimeToLongSamples(mLeftTrack->GetEndTime());
|
||||
auto rightTrackEnd = mRightTrack->TimeToLongSamples(mRightTrack->GetEndTime());
|
||||
mEnd = wxMax(leftTrackEnd, rightTrackEnd);
|
||||
|
||||
bGoodResult = ProcessOne(count);
|
||||
@ -135,8 +135,8 @@ bool EffectStereoToMono::ProcessOne(int count)
|
||||
float curRightFrame;
|
||||
float curMonoFrame;
|
||||
|
||||
sampleCount idealBlockLen = mLeftTrack->GetMaxBlockSize() * 2;
|
||||
sampleCount index = mStart;
|
||||
auto idealBlockLen = mLeftTrack->GetMaxBlockSize() * 2;
|
||||
auto index = mStart;
|
||||
float *leftBuffer = new float[idealBlockLen];
|
||||
float *rightBuffer = new float[idealBlockLen];
|
||||
bool bResult = true;
|
||||
|
@ -159,7 +159,6 @@ sampleCount EffectToneGen::ProcessBlock(float **WXUNUSED(inBlock), float **outBl
|
||||
{
|
||||
float *buffer = outBlock[0];
|
||||
double throwaway = 0; //passed to modf but never used
|
||||
sampleCount i;
|
||||
double f = 0.0;
|
||||
double a, b;
|
||||
int k;
|
||||
@ -196,7 +195,7 @@ sampleCount EffectToneGen::ProcessBlock(float **WXUNUSED(inBlock), float **outBl
|
||||
}
|
||||
|
||||
// synth loop
|
||||
for (i = 0; i < blockLen; i++)
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++)
|
||||
{
|
||||
switch (mWaveform)
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ double EffectTruncSilence::CalcPreviewInputLength(double /* previewLength */)
|
||||
|
||||
RegionList trackSilences;
|
||||
|
||||
sampleCount index = wt->TimeToLongSamples(mT0);
|
||||
auto index = wt->TimeToLongSamples(mT0);
|
||||
sampleCount silentFrame = 0; // length of the current silence
|
||||
|
||||
Analyze(silences, trackSilences, wt, &silentFrame, &index, whichTrack, &inputLength, &minInputLength);
|
||||
@ -378,7 +378,7 @@ bool EffectTruncSilence::FindSilences
|
||||
WaveTrack *const wt = static_cast<WaveTrack *>(t);
|
||||
|
||||
// Smallest silent region to detect in frames
|
||||
sampleCount minSilenceFrames =
|
||||
auto minSilenceFrames =
|
||||
sampleCount(std::max(mInitialAllowedSilence, DEF_MinTruncMs) * wt->GetRate());
|
||||
|
||||
//
|
||||
@ -386,7 +386,7 @@ bool EffectTruncSilence::FindSilences
|
||||
//
|
||||
RegionList trackSilences;
|
||||
|
||||
sampleCount index = wt->TimeToLongSamples(mT0);
|
||||
auto index = wt->TimeToLongSamples(mT0);
|
||||
sampleCount silentFrame = 0;
|
||||
|
||||
// Detect silences
|
||||
@ -487,7 +487,7 @@ bool EffectTruncSilence::DoRemoval
|
||||
{
|
||||
// In WaveTracks, clear with a cross-fade
|
||||
WaveTrack *const wt = static_cast<WaveTrack*>(t);
|
||||
sampleCount blendFrames = mBlendFrameCount;
|
||||
auto blendFrames = mBlendFrameCount;
|
||||
// Round start/end times to frame boundaries
|
||||
cutStart = wt->LongSamplesToTime(wt->TimeToLongSamples(cutStart));
|
||||
cutEnd = wt->LongSamplesToTime(wt->TimeToLongSamples(cutEnd));
|
||||
@ -501,13 +501,13 @@ bool EffectTruncSilence::DoRemoval
|
||||
// Perform cross-fade in memory
|
||||
float *buf1 = new float[blendFrames];
|
||||
float *buf2 = new float[blendFrames];
|
||||
sampleCount t1 = wt->TimeToLongSamples(cutStart) - blendFrames / 2;
|
||||
sampleCount t2 = wt->TimeToLongSamples(cutEnd) - blendFrames / 2;
|
||||
auto t1 = wt->TimeToLongSamples(cutStart) - blendFrames / 2;
|
||||
auto t2 = wt->TimeToLongSamples(cutEnd) - blendFrames / 2;
|
||||
|
||||
wt->Get((samplePtr)buf1, floatSample, t1, blendFrames);
|
||||
wt->Get((samplePtr)buf2, floatSample, t2, blendFrames);
|
||||
|
||||
for (sampleCount i = 0; i < blendFrames; ++i)
|
||||
for (decltype(blendFrames) i = 0; i < blendFrames; ++i)
|
||||
{
|
||||
buf1[i] = ((blendFrames-i) * buf1[i] + i * buf2[i]) /
|
||||
(double)blendFrames;
|
||||
@ -542,12 +542,12 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList,
|
||||
double* minInputLength /*= NULL*/)
|
||||
{
|
||||
// Smallest silent region to detect in frames
|
||||
sampleCount minSilenceFrames = sampleCount(std::max( mInitialAllowedSilence, DEF_MinTruncMs) * wt->GetRate());
|
||||
auto minSilenceFrames = sampleCount(std::max( mInitialAllowedSilence, DEF_MinTruncMs) * wt->GetRate());
|
||||
|
||||
double truncDbSilenceThreshold = Enums::Db2Signal[mTruncDbChoiceIndex];
|
||||
sampleCount blockLen = wt->GetMaxBlockSize();
|
||||
sampleCount start = wt->TimeToLongSamples(mT0);
|
||||
sampleCount end = wt->TimeToLongSamples(mT1);
|
||||
auto blockLen = wt->GetMaxBlockSize();
|
||||
auto start = wt->TimeToLongSamples(mT0);
|
||||
auto end = wt->TimeToLongSamples(mT1);
|
||||
sampleCount outLength = 0;
|
||||
|
||||
double previewLength;
|
||||
@ -596,8 +596,8 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList,
|
||||
// No more regions -- no need to process the rest of the track
|
||||
if (inputLength) {
|
||||
// Add available samples up to previewLength.
|
||||
sampleCount remainingTrackSamples = wt->TimeToLongSamples(wt->GetEndTime()) - *index;
|
||||
sampleCount requiredTrackSamples = previewLen - outLength;
|
||||
auto remainingTrackSamples = wt->TimeToLongSamples(wt->GetEndTime()) - *index;
|
||||
auto requiredTrackSamples = previewLen - outLength;
|
||||
outLength += (remainingTrackSamples > requiredTrackSamples)? requiredTrackSamples : remainingTrackSamples;
|
||||
}
|
||||
|
||||
@ -612,9 +612,9 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList,
|
||||
));
|
||||
}
|
||||
*silentFrame = 0;
|
||||
sampleCount newIndex = wt->TimeToLongSamples(rit->start);
|
||||
auto newIndex = wt->TimeToLongSamples(rit->start);
|
||||
if (inputLength) {
|
||||
sampleCount requiredTrackSamples = previewLen - outLength;
|
||||
auto requiredTrackSamples = previewLen - outLength;
|
||||
// Add non-silent sample to outLength
|
||||
outLength += ((newIndex - *index) > requiredTrackSamples)? requiredTrackSamples : newIndex - *index;
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ bool EffectTwoPassSimpleMono::ProcessPass()
|
||||
if (mCurT1 > mCurT0) {
|
||||
|
||||
//Transform the marker timepoints to samples
|
||||
sampleCount start = track->TimeToLongSamples(mCurT0);
|
||||
sampleCount end = track->TimeToLongSamples(mCurT1);
|
||||
auto start = track->TimeToLongSamples(mCurT0);
|
||||
auto end = track->TimeToLongSamples(mCurT1);
|
||||
|
||||
//Get the track rate and samples
|
||||
mCurRate = track->GetRate();
|
||||
@ -100,14 +100,13 @@ bool EffectTwoPassSimpleMono::ProcessOne(WaveTrack * track,
|
||||
sampleCount start, sampleCount end)
|
||||
{
|
||||
bool ret;
|
||||
sampleCount s;
|
||||
float *tmpfloat;
|
||||
|
||||
//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);
|
||||
sampleCount maxblock = track->GetMaxBlockSize();
|
||||
auto maxblock = track->GetMaxBlockSize();
|
||||
|
||||
//Initiate a processing buffer. This buffer will (most likely)
|
||||
//be shorter than the length of the track being processed.
|
||||
@ -134,7 +133,7 @@ bool EffectTwoPassSimpleMono::ProcessOne(WaveTrack * track,
|
||||
|
||||
//Go through the track one buffer at a time. s counts which
|
||||
//sample the current buffer starts at.
|
||||
s = start + samples1;
|
||||
auto s = start + samples1;
|
||||
while (s < end) {
|
||||
//Get a block of samples (smaller than the size of the buffer)
|
||||
//Adjust the block size if it is the final block in the track
|
||||
|
@ -1342,7 +1342,7 @@ sampleCount VSTEffect::GetLatency()
|
||||
if (mUseLatency)
|
||||
{
|
||||
// ??? Threading issue ???
|
||||
sampleCount delay = mBufferDelay;
|
||||
auto delay = mBufferDelay;
|
||||
mBufferDelay = 0;
|
||||
return delay;
|
||||
}
|
||||
@ -1540,7 +1540,7 @@ sampleCount VSTEffect::RealtimeProcess(int group, float **inbuf, float **outbuf,
|
||||
|
||||
for (int c = 0; c < mAudioIns; c++)
|
||||
{
|
||||
for (sampleCount s = 0; s < numSamples; s++)
|
||||
for (decltype(numSamples) s = 0; s < numSamples; s++)
|
||||
{
|
||||
mMasterIn[c][s] += inbuf[c][s];
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ sampleCount EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBl
|
||||
data.phase = mPhase * M_PI / 180.0;
|
||||
data.outgain = DB_TO_LINEAR(mOutGain);
|
||||
|
||||
for (int i = 0; i < blockLen; i++)
|
||||
for (decltype(blockLen) i = 0; i < blockLen; i++)
|
||||
{
|
||||
in = (double) ibuf[i];
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ sampleCount AudioUnitEffect::GetLatency()
|
||||
&latency,
|
||||
&dataSize);
|
||||
|
||||
return (sampleCount) (latency * mSampleRate);
|
||||
return latency * mSampleRate;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1231,7 +1231,7 @@ sampleCount AudioUnitEffect::GetTailSize()
|
||||
&tailTime,
|
||||
&dataSize);
|
||||
|
||||
return (sampleCount) (tailTime * mSampleRate);
|
||||
return tailTime * mSampleRate;
|
||||
}
|
||||
|
||||
bool AudioUnitEffect::IsReady()
|
||||
@ -1440,7 +1440,7 @@ sampleCount AudioUnitEffect::RealtimeProcess(int group,
|
||||
|
||||
for (int c = 0; c < mAudioIns; c++)
|
||||
{
|
||||
for (sampleCount s = 0; s < numSamples; s++)
|
||||
for (decltype(numSamples) s = 0; s < numSamples; s++)
|
||||
{
|
||||
mMasterIn[c][s] += inbuf[c][s];
|
||||
}
|
||||
|
@ -919,7 +919,7 @@ sampleCount LV2Effect::RealtimeProcess(int group,
|
||||
|
||||
for (size_t p = 0, cnt = mAudioInputs.GetCount(); p < cnt; p++)
|
||||
{
|
||||
for (sampleCount s = 0; s < numSamples; s++)
|
||||
for (decltype(numSamples) s = 0; s < numSamples; s++)
|
||||
{
|
||||
mMasterIn[p][s] += inbuf[p][s];
|
||||
}
|
||||
|
@ -626,8 +626,8 @@ bool NyquistEffect::Process()
|
||||
gtLast = gt;
|
||||
|
||||
mCurStart[0] = mCurTrack[0]->TimeToLongSamples(mT0);
|
||||
sampleCount end = mCurTrack[0]->TimeToLongSamples(mT1);
|
||||
mCurLen = (sampleCount)(end - mCurStart[0]);
|
||||
auto end = mCurTrack[0]->TimeToLongSamples(mT1);
|
||||
mCurLen = end - mCurStart[0];
|
||||
|
||||
if (mCurLen > NYQ_MAX_LEN) {
|
||||
float hours = (float)NYQ_MAX_LEN / (44100 * 60 * 60);
|
||||
|
@ -492,9 +492,9 @@ bool VampEffect::Process()
|
||||
data[c] = new float[block];
|
||||
}
|
||||
|
||||
sampleCount originalLen = len;
|
||||
sampleCount ls = lstart;
|
||||
sampleCount rs = rstart;
|
||||
auto originalLen = len;
|
||||
auto ls = lstart;
|
||||
auto rs = rstart;
|
||||
|
||||
while (len != 0)
|
||||
{
|
||||
|
@ -448,7 +448,7 @@ int ExportCL::Export(AudacityProject *project,
|
||||
|
||||
// Need to mix another block
|
||||
if (numBytes == 0) {
|
||||
sampleCount numSamples = mixer->Process(maxBlockLen);
|
||||
auto numSamples = mixer->Process(maxBlockLen);
|
||||
if (numSamples == 0) {
|
||||
break;
|
||||
}
|
||||
|
@ -872,7 +872,7 @@ int ExportFFmpeg::Export(AudacityProject *project,
|
||||
wxString::Format(_("Exporting entire file as %s"), ExportFFmpegOptions::fmts[mSubFormat].description));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
sampleCount pcmNumSamples = mixer->Process(pcmBufferSize);
|
||||
auto pcmNumSamples = mixer->Process(pcmBufferSize);
|
||||
|
||||
if (pcmNumSamples == 0)
|
||||
break;
|
||||
|
@ -311,7 +311,7 @@ int ExportFLAC::Export(AudacityProject *project,
|
||||
numChannels, SAMPLES_PER_RUN, false,
|
||||
rate, format, true, mixerSpec);
|
||||
|
||||
int i, j;
|
||||
int i;
|
||||
FLAC__int32 **tmpsmplbuf = new FLAC__int32*[numChannels];
|
||||
for (i = 0; i < numChannels; i++) {
|
||||
tmpsmplbuf[i] = (FLAC__int32 *) calloc(SAMPLES_PER_RUN, sizeof(FLAC__int32));
|
||||
@ -324,7 +324,7 @@ int ExportFLAC::Export(AudacityProject *project,
|
||||
_("Exporting the entire project as FLAC"));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
sampleCount samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
|
||||
auto samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
|
||||
if (samplesThisRun == 0) { //stop encoding
|
||||
break;
|
||||
}
|
||||
@ -332,12 +332,12 @@ int ExportFLAC::Export(AudacityProject *project,
|
||||
for (i = 0; i < numChannels; i++) {
|
||||
samplePtr mixed = mixer->GetBuffer(i);
|
||||
if (format == int24Sample) {
|
||||
for (j = 0; j < samplesThisRun; j++) {
|
||||
for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) {
|
||||
tmpsmplbuf[i][j] = ((int *)mixed)[j];
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (j = 0; j < samplesThisRun; j++) {
|
||||
for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) {
|
||||
tmpsmplbuf[i][j] = ((short *)mixed)[j];
|
||||
}
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ int ExportMP2::Export(AudacityProject *project,
|
||||
wxString::Format(_("Exporting entire file at %ld kbps"), bitrate));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
sampleCount pcmNumSamples = mixer->Process(pcmBufferSize);
|
||||
auto pcmNumSamples = mixer->Process(pcmBufferSize);
|
||||
|
||||
if (pcmNumSamples == 0)
|
||||
break;
|
||||
|
@ -1764,7 +1764,7 @@ int ExportMP3::Export(AudacityProject *project,
|
||||
exporter.SetChannel(CHANNEL_STEREO);
|
||||
}
|
||||
|
||||
sampleCount inSamples = exporter.InitializeStream(channels, rate);
|
||||
auto inSamples = exporter.InitializeStream(channels, rate);
|
||||
if (((int)inSamples) < 0) {
|
||||
wxMessageBox(_("Unable to initialize MP3 stream"));
|
||||
return false;
|
||||
@ -1829,7 +1829,7 @@ int ExportMP3::Export(AudacityProject *project,
|
||||
ProgressDialog progress(wxFileName(fName).GetName(), title);
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
sampleCount blockLen = mixer->Process(inSamples);
|
||||
auto blockLen = mixer->Process(inSamples);
|
||||
|
||||
if (blockLen == 0) {
|
||||
break;
|
||||
|
@ -255,7 +255,7 @@ int ExportOGG::Export(AudacityProject *project,
|
||||
|
||||
while (updateResult == eProgressSuccess && !eos) {
|
||||
float **vorbis_buffer = vorbis_analysis_buffer(&dsp, SAMPLES_PER_RUN);
|
||||
sampleCount samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
|
||||
auto samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
|
||||
|
||||
if (samplesThisRun == 0) {
|
||||
// Tell the library that we wrote 0 bytes - signalling the end.
|
||||
|
@ -490,8 +490,8 @@ int ExportPCM::Export(AudacityProject *project,
|
||||
formatStr.c_str()));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
sampleCount samplesWritten;
|
||||
sampleCount numSamples = mixer->Process(maxBlockLen);
|
||||
sf_count_t samplesWritten;
|
||||
auto numSamples = mixer->Process(maxBlockLen);
|
||||
|
||||
if (numSamples == 0)
|
||||
break;
|
||||
|
@ -603,9 +603,10 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
WaveTrack *t = stream[c].get();
|
||||
odTask->AddWaveTrack(t);
|
||||
|
||||
sampleCount maxBlockSize = t->GetMaxBlockSize();
|
||||
auto maxBlockSize = t->GetMaxBlockSize();
|
||||
//use the maximum blockfile size to divide the sections (about 11secs per blockfile at 44.1khz)
|
||||
for (sampleCount i = 0; i < sampleDuration; i += maxBlockSize) {
|
||||
|
||||
for (decltype(sampleDuration) i = 0; i < sampleDuration; i += maxBlockSize) {
|
||||
const auto blockLen =
|
||||
limitSampleBufferSize( maxBlockSize, sampleDuration - i );
|
||||
|
||||
|
@ -487,9 +487,9 @@ int FLACImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
//add the task to the ODManager
|
||||
if(useOD)
|
||||
{
|
||||
sampleCount fileTotalFrames = (sampleCount)mNumSamples;
|
||||
sampleCount maxBlockSize = mChannels.begin()->get()->GetMaxBlockSize();
|
||||
for (sampleCount i = 0; i < fileTotalFrames; i += maxBlockSize) {
|
||||
auto fileTotalFrames = (sampleCount)mNumSamples;
|
||||
auto maxBlockSize = mChannels.begin()->get()->GetMaxBlockSize();
|
||||
for (decltype(fileTotalFrames) i = 0; i < fileTotalFrames; i += maxBlockSize) {
|
||||
const auto blockLen =
|
||||
limitSampleBufferSize( maxBlockSize, fileTotalFrames - i );
|
||||
|
||||
|
@ -456,13 +456,12 @@ enum mad_flow output_cb(void *_data,
|
||||
struct mad_pcm *pcm)
|
||||
{
|
||||
int channels, samplerate;
|
||||
sampleCount samples;
|
||||
struct private_data *data = (struct private_data *)_data;
|
||||
int smpl;
|
||||
|
||||
samplerate= pcm->samplerate;
|
||||
channels = pcm->channels;
|
||||
samples = pcm->length;
|
||||
const auto samples = pcm->length;
|
||||
|
||||
/* If this is the first run, we need to create the WaveTracks that
|
||||
* will hold the data. We do this now because now is the first
|
||||
|
@ -367,8 +367,8 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
channels.begin()->get()->SetLinked(true);
|
||||
}
|
||||
|
||||
sampleCount fileTotalFrames = (sampleCount)mInfo.frames;
|
||||
sampleCount maxBlockSize = channels.begin()->get()->GetMaxBlockSize();
|
||||
auto fileTotalFrames = (sampleCount)mInfo.frames;
|
||||
auto maxBlockSize = channels.begin()->get()->GetMaxBlockSize();
|
||||
int updateResult = false;
|
||||
|
||||
// If the format is not seekable, we must use 'copy' mode,
|
||||
@ -387,7 +387,8 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
bool useOD =fileTotalFrames>kMinimumODFileSampleSize;
|
||||
int updateCounter = 0;
|
||||
|
||||
for (sampleCount i = 0; i < fileTotalFrames; i += maxBlockSize) {
|
||||
for (decltype(fileTotalFrames) i = 0; i < fileTotalFrames; i += maxBlockSize) {
|
||||
|
||||
const auto blockLen =
|
||||
limitSampleBufferSize( maxBlockSize, fileTotalFrames - i );
|
||||
|
||||
@ -429,9 +430,10 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
// samples in the tracks.
|
||||
|
||||
// PRL: guard against excessive memory buffer allocation in case of many channels
|
||||
sampleCount maxBlock = std::min(maxBlockSize,
|
||||
sampleCount(std::numeric_limits<int>::max() /
|
||||
(mInfo.channels * SAMPLE_SIZE(mFormat)))
|
||||
using type = decltype(maxBlockSize);
|
||||
auto maxBlock = std::min(maxBlockSize,
|
||||
std::numeric_limits<type>::max() /
|
||||
(mInfo.channels * SAMPLE_SIZE(mFormat))
|
||||
);
|
||||
if (maxBlock < 1)
|
||||
return eProgressFailed;
|
||||
@ -446,7 +448,7 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
|
||||
SampleBuffer buffer(maxBlock, mFormat);
|
||||
|
||||
unsigned long framescompleted = 0;
|
||||
decltype(fileTotalFrames) framescompleted = 0;
|
||||
|
||||
long block;
|
||||
do {
|
||||
|
@ -233,8 +233,8 @@ int QTImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
OSErr err = noErr;
|
||||
MovieAudioExtractionRef maer = NULL;
|
||||
int updateResult = eProgressSuccess;
|
||||
sampleCount totSamples = (sampleCount) GetMovieDuration(mMovie);
|
||||
sampleCount numSamples = 0;
|
||||
auto totSamples = (sampleCount) GetMovieDuration(mMovie);
|
||||
decltype(totSamples) numSamples = 0;
|
||||
Boolean discrete = true;
|
||||
UInt32 quality = kQTAudioRenderQuality_Max;
|
||||
AudioStreamBasicDescription desc;
|
||||
|
@ -100,7 +100,6 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
|
||||
int encoding = 0; // Guess Format
|
||||
sampleFormat format;
|
||||
sf_count_t offset = 0;
|
||||
sampleCount totalFrames;
|
||||
double rate = 44100.0;
|
||||
double percent = 100.0;
|
||||
TrackHolders channels;
|
||||
@ -176,7 +175,7 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
|
||||
|
||||
SFCall<sf_count_t>(sf_seek, sndFile.get(), 0, SEEK_SET);
|
||||
|
||||
totalFrames = (sampleCount)(sndInfo.frames * percent / 100.0);
|
||||
auto totalFrames = (sampleCount)(sndInfo.frames * percent / 100.0);
|
||||
|
||||
//
|
||||
// Sample format:
|
||||
@ -218,12 +217,12 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
|
||||
firstChannel->SetLinked(true);
|
||||
}
|
||||
|
||||
sampleCount maxBlockSize = firstChannel->GetMaxBlockSize();
|
||||
auto maxBlockSize = firstChannel->GetMaxBlockSize();
|
||||
|
||||
SampleBuffer srcbuffer(maxBlockSize * numChannels, format);
|
||||
SampleBuffer buffer(maxBlockSize, format);
|
||||
|
||||
sampleCount framescompleted = 0;
|
||||
decltype(totalFrames) framescompleted = 0;
|
||||
if (totalFrames < 0) {
|
||||
wxASSERT(false);
|
||||
totalFrames = 0;
|
||||
|
@ -203,12 +203,12 @@ void ODComputeSummaryTask::Update()
|
||||
const auto odpcmaFile =
|
||||
std::static_pointer_cast<ODPCMAliasBlockFile>(file);
|
||||
odpcmaFile->SetStart(block.start);
|
||||
odpcmaFile->SetClipOffset((sampleCount)(clip->GetStartTime()*clip->GetRate()));
|
||||
odpcmaFile->SetClipOffset(clip->GetStartTime()*clip->GetRate());
|
||||
|
||||
//these will always be linear within a sequence-lets take advantage of this by keeping a cursor.
|
||||
while(insertCursor<(int)tempBlocks.size()&&
|
||||
(sampleCount)(tempBlocks[insertCursor]->GetStart()+tempBlocks[insertCursor]->GetClipOffset()) <
|
||||
(sampleCount)(odpcmaFile->GetStart()+odpcmaFile->GetClipOffset()))
|
||||
tempBlocks[insertCursor]->GetStart() + tempBlocks[insertCursor]->GetClipOffset() <
|
||||
odpcmaFile->GetStart() + odpcmaFile->GetClipOffset())
|
||||
insertCursor++;
|
||||
|
||||
tempBlocks.insert(tempBlocks.begin() + insertCursor++, odpcmaFile);
|
||||
@ -240,7 +240,7 @@ void ODComputeSummaryTask::OrderBlockFiles
|
||||
//Note that this code assumes that the array is sorted in time.
|
||||
|
||||
//find the startpoint
|
||||
sampleCount processStartSample = GetDemandSample();
|
||||
auto processStartSample = GetDemandSample();
|
||||
for(int i= ((int)unorderedBlocks.size())-1;i>= 0;i--)
|
||||
{
|
||||
//check to see if the refcount is at least two before we add it to the list.
|
||||
|
@ -365,7 +365,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo
|
||||
if (sc != (streamContext*)1)
|
||||
{
|
||||
//find out the dts we've seekd to. can't use the stream->cur_dts because it is faulty. also note that until we do the first seek, pkt.dts can be false and will change for the same samples after the initial seek.
|
||||
sampleCount actualDecodeStart = mCurrentPos;
|
||||
auto actualDecodeStart = mCurrentPos;
|
||||
|
||||
// we need adjacent samples, so don't use dts most of the time which will leave gaps between frames
|
||||
// for some formats
|
||||
|
@ -159,12 +159,12 @@ void ODDecodeTask::Update()
|
||||
std::static_pointer_cast<ODDecodeBlockFile>(file))->GetDecodeType() == this->GetODType())
|
||||
{
|
||||
oddbFile->SetStart(block.start);
|
||||
oddbFile->SetClipOffset((sampleCount)(clip->GetStartTime()*clip->GetRate()));
|
||||
oddbFile->SetClipOffset(clip->GetStartTime()*clip->GetRate());
|
||||
|
||||
//these will always be linear within a sequence-lets take advantage of this by keeping a cursor.
|
||||
while(insertCursor<(int)tempBlocks.size()&&
|
||||
(sampleCount)(tempBlocks[insertCursor]->GetStart()+tempBlocks[insertCursor]->GetClipOffset()) <
|
||||
(sampleCount)((oddbFile->GetStart()+oddbFile->GetClipOffset())))
|
||||
tempBlocks[insertCursor]->GetStart() + tempBlocks[insertCursor]->GetClipOffset() <
|
||||
oddbFile->GetStart() + oddbFile->GetClipOffset())
|
||||
insertCursor++;
|
||||
|
||||
tempBlocks.insert(tempBlocks.begin()+insertCursor++, oddbFile);
|
||||
@ -193,7 +193,7 @@ void ODDecodeTask::OrderBlockFiles
|
||||
//(which the user sets by clicking.) note that this code is pretty hacky - it assumes that the array is sorted in time.
|
||||
|
||||
//find the startpoint
|
||||
sampleCount processStartSample = GetDemandSample();
|
||||
auto processStartSample = GetDemandSample();
|
||||
for(int i= ((int)unorderedBlocks.size())-1;i>= 0;i--)
|
||||
{
|
||||
//check to see if the refcount is at least two before we add it to the list.
|
||||
|
@ -329,7 +329,7 @@ void ODTask::DemandTrackUpdate(WaveTrack* track, double seconds)
|
||||
{
|
||||
if(track == mWaveTracks[i])
|
||||
{
|
||||
sampleCount newDemandSample = (sampleCount)(seconds * track->GetRate());
|
||||
auto newDemandSample = (sampleCount)(seconds * track->GetRate());
|
||||
demandSampleChanged = newDemandSample != GetDemandSample();
|
||||
SetDemandSample(newDemandSample);
|
||||
break;
|
||||
|
@ -409,8 +409,8 @@ void TranscriptionToolBar::GetSamples(WaveTrack *t, sampleCount *s0, sampleCount
|
||||
double start = p->GetSel0();
|
||||
double end = p->GetSel1();
|
||||
|
||||
sampleCount ss0 = sampleCount( (start - t->GetOffset()) * t->GetRate() );
|
||||
sampleCount ss1 = sampleCount( (end - t->GetOffset()) * t->GetRate() );
|
||||
auto ss0 = sampleCount( (start - t->GetOffset()) * t->GetRate() );
|
||||
auto ss1 = sampleCount( (end - t->GetOffset()) * t->GetRate() );
|
||||
|
||||
if (start < t->GetOffset()) {
|
||||
ss0 = 0;
|
||||
@ -535,7 +535,7 @@ void TranscriptionToolBar::OnStartOn(wxCommandEvent & WXUNUSED(event))
|
||||
//if(len == 0)
|
||||
//len = (WaveTrack*)t->GetSequence()->GetNumSamples()-start;
|
||||
|
||||
sampleCount newstart = mVk->OnForward(*(WaveTrack*)t,start,len);
|
||||
auto newstart = mVk->OnForward(*(WaveTrack*)t,start,len);
|
||||
double newpos = newstart / ((WaveTrack*)t)->GetRate();
|
||||
|
||||
p->SetSel0(newpos);
|
||||
@ -568,7 +568,7 @@ void TranscriptionToolBar::OnStartOff(wxCommandEvent & WXUNUSED(event))
|
||||
//if(len == 0)
|
||||
//len = (WaveTrack*)t->GetSequence()->GetNumSamples()-start;
|
||||
|
||||
sampleCount newstart = mVk->OffForward(*(WaveTrack*)t,start,len);
|
||||
auto newstart = mVk->OffForward(*(WaveTrack*)t,start,len);
|
||||
double newpos = newstart / ((WaveTrack*)t)->GetRate();
|
||||
|
||||
p->SetSel0(newpos);
|
||||
@ -603,7 +603,7 @@ void TranscriptionToolBar::OnEndOn(wxCommandEvent & WXUNUSED(event))
|
||||
len = start;
|
||||
start = 0;
|
||||
}
|
||||
sampleCount newEnd = mVk->OnBackward(*(WaveTrack*)t,start+ len,len);
|
||||
auto newEnd = mVk->OnBackward(*(WaveTrack*)t,start+ len,len);
|
||||
double newpos = newEnd / ((WaveTrack*)t)->GetRate();
|
||||
|
||||
p->SetSel1(newpos);
|
||||
@ -638,7 +638,7 @@ void TranscriptionToolBar::OnEndOff(wxCommandEvent & WXUNUSED(event))
|
||||
len = start;
|
||||
start = 0;
|
||||
}
|
||||
sampleCount newEnd = mVk->OffBackward(*(WaveTrack*)t,start+ len,len);
|
||||
auto newEnd = mVk->OffBackward(*(WaveTrack*)t,start+ len,len);
|
||||
double newpos = newEnd / ((WaveTrack*)t)->GetRate();
|
||||
|
||||
p->SetSel1(newpos);
|
||||
@ -678,8 +678,8 @@ void TranscriptionToolBar::OnSelectSound(wxCommandEvent & WXUNUSED(event))
|
||||
//len = (WaveTrack*)t->GetSequence()->GetNumSamples()-start;
|
||||
|
||||
double rate = ((WaveTrack*)t)->GetRate();
|
||||
sampleCount newstart = mVk->OffBackward(*(WaveTrack*)t,start,start);
|
||||
sampleCount newend = mVk->OffForward(*(WaveTrack*)t,start+len,(int)(tl->GetEndTime()*rate));
|
||||
auto newstart = mVk->OffBackward(*(WaveTrack*)t,start,start);
|
||||
auto newend = mVk->OffForward(*(WaveTrack*)t,start+len,(int)(tl->GetEndTime()*rate));
|
||||
|
||||
//reset the selection bounds.
|
||||
p->SetSel0(newstart / rate);
|
||||
@ -717,8 +717,8 @@ void TranscriptionToolBar::OnSelectSilence(wxCommandEvent & WXUNUSED(event))
|
||||
//if(len == 0)
|
||||
//len = (WaveTrack*)t->GetSequence()->GetNumSamples()-start;
|
||||
double rate = ((WaveTrack*)t)->GetRate();
|
||||
sampleCount newstart = mVk->OnBackward(*(WaveTrack*)t,start,start);
|
||||
sampleCount newend = mVk->OnForward(*(WaveTrack*)t,start+len,(int)(tl->GetEndTime()*rate));
|
||||
auto newstart = mVk->OnBackward(*(WaveTrack*)t,start,start);
|
||||
auto newend = mVk->OnForward(*(WaveTrack*)t,start+len,(int)(tl->GetEndTime()*rate));
|
||||
|
||||
//reset the selection bounds.
|
||||
p->SetSel0(newstart / rate);
|
||||
@ -813,7 +813,6 @@ void TranscriptionToolBar::OnAutomateSelection(wxCommandEvent & WXUNUSED(event))
|
||||
start = 0;
|
||||
}
|
||||
int lastlen = 0;
|
||||
sampleCount newStart, newEnd;
|
||||
double newStartPos, newEndPos;
|
||||
|
||||
|
||||
@ -827,7 +826,7 @@ void TranscriptionToolBar::OnAutomateSelection(wxCommandEvent & WXUNUSED(event))
|
||||
|
||||
lastlen = len;
|
||||
|
||||
newStart = mVk->OnForward(*(WaveTrack*)t,start,len);
|
||||
auto newStart = mVk->OnForward(*(WaveTrack*)t,start,len);
|
||||
|
||||
//JKC: If no start found then don't add any labels.
|
||||
if( newStart==start)
|
||||
@ -844,7 +843,7 @@ void TranscriptionToolBar::OnAutomateSelection(wxCommandEvent & WXUNUSED(event))
|
||||
//OK, now we have found a NEW starting point. A 'word' should be at least
|
||||
//50 ms long, so jump ahead minWordSize
|
||||
|
||||
newEnd = mVk->OffForward(*(WaveTrack*)t,newStart+minWordSize, len);
|
||||
auto newEnd = mVk->OffForward(*(WaveTrack*)t,newStart+minWordSize, len);
|
||||
|
||||
//If newEnd didn't move, we should give up, because
|
||||
// there isn't another end before the end of the selection.
|
||||
|
Loading…
x
Reference in New Issue
Block a user