From 2949a080d25c043c9a33889f8fc871544038b256 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 24 Aug 2016 13:27:54 -0400 Subject: [PATCH 1/7] More cautions in SBSMSEffect.cpp... ... The narrowings from sampleCount to long might be fixed, but it would require changes in lib-src --- src/effects/SBSMSEffect.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp index 7708180be..580d46425 100644 --- a/src/effects/SBSMSEffect.cpp +++ b/src/effects/SBSMSEffect.cpp @@ -280,7 +280,7 @@ bool EffectSBSMS::Process() // 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; @@ -301,9 +301,6 @@ bool EffectSBSMS::Process() 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 @@ -340,7 +345,9 @@ bool EffectSBSMS::Process() // The argument type is only long! static_cast ( static_cast ( samplesToProcess ) ), - processPresamples, + // This argument type is also only long! + static_cast ( static_cast ( + processPresamples ) ), rb.quality.get()); } From bf66e4410aac459fd416e66b8ece7dbc832ee070 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 24 Aug 2016 13:49:32 -0400 Subject: [PATCH 2/7] Use long long for argument passed to wxString::ToLongLong --- src/Sequence.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 0536b058d..97538bdf3 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -792,8 +792,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 +802,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 +857,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"))) From ee5a0db9ff13c2d88e1fb9dc5fc59e08e3ce9d91 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 24 Aug 2016 10:43:43 -0400 Subject: [PATCH 3/7] some uses of size_t --- src/WaveTrack.cpp | 2 +- src/blockfile/LegacyBlockFile.cpp | 3 ++- src/effects/AutoDuck.cpp | 4 ++-- src/effects/Compressor.cpp | 2 +- src/effects/DtmfGen.cpp | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index eba186d1f..1c9d409f4 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -1429,7 +1429,7 @@ bool WaveTrack::InsertSilence(double t, double len) bool WaveTrack::Disjoin(double t0, double t1) { sampleCount minSamples = TimeToLongSamples( WAVETRACK_MERGE_POINT_TOLERANCE ); - sampleCount maxAtOnce = 1048576; + size_t maxAtOnce = 1048576; float *buffer = new float[ maxAtOnce ]; Regions regions; diff --git a/src/blockfile/LegacyBlockFile.cpp b/src/blockfile/LegacyBlockFile.cpp index 873694d61..0924db58f 100644 --- a/src/blockfile/LegacyBlockFile.cpp +++ b/src/blockfile/LegacyBlockFile.cpp @@ -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; } } diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index fb1396a33..fc02860d5 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -288,7 +288,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]; @@ -393,7 +393,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)) diff --git a/src/effects/Compressor.cpp b/src/effects/Compressor.cpp index 350d1a64d..87827bdde 100644 --- a/src/effects/Compressor.cpp +++ b/src/effects/Compressor.cpp @@ -366,7 +366,7 @@ 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) { diff --git a/src/effects/DtmfGen.cpp b/src/effects/DtmfGen.cpp index 53fca7129..93933fc15 100644 --- a/src/effects/DtmfGen.cpp +++ b/src/effects/DtmfGen.cpp @@ -534,7 +534,7 @@ bool EffectDtmf::MakeDtmfTone(float *buffer, sampleCount len, float fs, wxChar t // 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; } } @@ -548,7 +548,7 @@ bool EffectDtmf::MakeDtmfTone(float *buffer, sampleCount len, float fs, wxChar t // 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)); } } From b8c1d02058745c07f35f33535f8371a8dccc5cff Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 24 Aug 2016 13:08:53 -0400 Subject: [PATCH 4/7] Use sf_count_t not sampleCount --- src/export/ExportPCM.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index d4a1f8284..4c1a1008c 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -490,7 +490,7 @@ int ExportPCM::Export(AudacityProject *project, formatStr.c_str())); while (updateResult == eProgressSuccess) { - sampleCount samplesWritten; + sf_count_t samplesWritten; sampleCount numSamples = mixer->Process(maxBlockLen); if (numSamples == 0) From 79c79f9cd35873ac5103a9f07dd32610d36b4fd0 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 24 Aug 2016 11:24:26 -0400 Subject: [PATCH 5/7] Remove many mentions of sampleCount with auto and decltype... ... This makes much code agnostic about how other things (functions and arguments) are typed. Many of these neeed to become size_t instead of sampleCount. --- src/AudioIO.cpp | 10 +-- src/BlockFile.cpp | 19 ++--- src/FreqWindow.cpp | 14 ++-- src/Menus.cpp | 2 +- src/Mix.cpp | 10 +-- src/MixerBoard.cpp | 4 +- src/Sequence.cpp | 95 ++++++++++------------ src/TrackArtist.cpp | 25 +++--- src/TrackPanel.cpp | 14 ++-- src/VoiceKey.cpp | 36 ++++---- src/WaveClip.cpp | 44 +++++----- src/WaveTrack.cpp | 81 +++++++++--------- src/effects/Amplify.cpp | 2 +- src/effects/AutoDuck.cpp | 20 ++--- src/effects/ChangePitch.cpp | 2 +- src/effects/ChangeSpeed.cpp | 13 ++- src/effects/ClickRemoval.cpp | 12 +-- src/effects/Compressor.cpp | 2 +- src/effects/Contrast.cpp | 4 +- src/effects/DtmfGen.cpp | 10 +-- src/effects/Echo.cpp | 2 +- src/effects/Effect.cpp | 40 +++++---- src/effects/Equalization.cpp | 14 ++-- src/effects/Equalization48x.cpp | 52 ++++++------ src/effects/Fade.cpp | 4 +- src/effects/FindClipping.cpp | 13 ++- src/effects/Generator.cpp | 2 +- src/effects/Invert.cpp | 2 +- src/effects/Leveller.cpp | 2 +- src/effects/Noise.cpp | 6 +- src/effects/NoiseReduction.cpp | 10 +-- src/effects/NoiseRemoval.cpp | 10 +-- src/effects/Normalize.cpp | 22 ++--- src/effects/Paulstretch.cpp | 12 ++- src/effects/Phaser.cpp | 2 +- src/effects/Repair.cpp | 14 ++-- src/effects/Repeat.cpp | 6 +- src/effects/Reverb.cpp | 8 +- src/effects/Reverse.cpp | 39 +++++---- src/effects/SBSMSEffect.cpp | 20 ++--- src/effects/SimpleMono.cpp | 7 +- src/effects/SoundTouchEffect.cpp | 17 ++-- src/effects/StereoToMono.cpp | 12 +-- src/effects/ToneGen.cpp | 3 +- src/effects/TruncSilence.cpp | 30 +++---- src/effects/TwoPassSimpleMono.cpp | 9 +- src/effects/VST/VSTEffect.cpp | 4 +- src/effects/audiounits/AudioUnitEffect.cpp | 2 +- src/effects/lv2/LV2Effect.cpp | 2 +- src/effects/nyquist/Nyquist.cpp | 4 +- src/effects/vamp/VampEffect.cpp | 6 +- src/export/ExportCL.cpp | 2 +- src/export/ExportFFmpeg.cpp | 2 +- src/export/ExportFLAC.cpp | 2 +- src/export/ExportMP2.cpp | 2 +- src/export/ExportMP3.cpp | 4 +- src/export/ExportOGG.cpp | 2 +- src/export/ExportPCM.cpp | 2 +- src/import/ImportFFmpeg.cpp | 5 +- src/import/ImportFLAC.cpp | 6 +- src/import/ImportMP3.cpp | 3 +- src/import/ImportPCM.cpp | 14 ++-- src/import/ImportQT.cpp | 4 +- src/import/ImportRaw.cpp | 7 +- src/ondemand/ODComputeSummaryTask.cpp | 2 +- src/ondemand/ODDecodeFFmpegTask.cpp | 2 +- src/ondemand/ODDecodeTask.cpp | 2 +- src/ondemand/ODTask.cpp | 2 +- src/toolbars/TranscriptionToolBar.cpp | 25 +++--- 69 files changed, 424 insertions(+), 459 deletions(-) diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index c46061a04..4ae6df1e6 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -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) { diff --git a/src/BlockFile.cpp b/src/BlockFile.cpp index e9f08556d..414a3de2c 100644 --- a/src/BlockFile.cpp +++ b/src/BlockFile.cpp @@ -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) diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index 026663fe8..0a1be3ee0 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -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++) diff --git a/src/Menus.cpp b/src/Menus.cpp index cfdfb9e8a..c4b5f8f62 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -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, diff --git a/src/Mix.cpp b/src/Mix.cpp index 94d6123fb..827e9f091 100644 --- a/src/Mix.cpp +++ b/src/Mix.cpp @@ -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; @@ -418,7 +418,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 +438,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 +488,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache, } } - sampleCount thisProcessLen = mProcessLen; + auto thisProcessLen = mProcessLen; bool last = (*queueLen < mProcessLen); if (last) { thisProcessLen = *queueLen; @@ -625,7 +625,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; diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 216ba7a1f..4e481144b 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -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); diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 97538bdf3..031ba1171 100644 --- a/src/Sequence.cpp +++ b/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+1GetLength()) + result) <= mMaxSamples) { b++; @@ -1117,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); @@ -1153,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); @@ -1188,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) { @@ -1271,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; @@ -1279,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(); @@ -1304,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 @@ -1351,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); @@ -1391,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. @@ -1424,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) @@ -1467,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 @@ -1488,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 = @@ -1525,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, @@ -1570,7 +1563,7 @@ void Sequence::Blockify(BlockArray &list, sampleCount start, samplePtr buffer, s for (int 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)); @@ -1604,12 +1597,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; @@ -1662,8 +1655,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); @@ -1702,8 +1695,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 diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index 5b100b0ea..c96aac0dd 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -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) ); diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index bd089fba6..9a9b375f8 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -2342,9 +2342,9 @@ void TrackPanel::StartSnappingFreqSelection (const WaveTrack *pTrack) // Grab samples, just for this track, at these times std::vector 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 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). diff --git a/src/VoiceKey.cpp b/src/VoiceKey.cpp index 5b6e79a8f..952758337 100644 --- a/src/VoiceKey.cpp +++ b/src/VoiceKey.cpp @@ -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; diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 2512e6592..2c539460e 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -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; @@ -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; } @@ -473,7 +473,7 @@ fillWhere(std::vector &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++) + for (decltype(len) x = 1; x < len + 1; x++) where[x] = sampleCount( floor(w0 + double(x) * samplesPerPixel) ); @@ -626,10 +626,8 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0, sampleFormat seqFormat = mSequence->GetSampleFormat(); bool didUpdate = false; for(i=a; i left) { float *b; sampleCount len = right-left; - sampleCount j; if (seqFormat == floatSample) b = &((float *)mAppendBuffer.ptr())[left]; @@ -658,7 +655,7 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0, theMax = theMin = val; sumsq = val * val; } - for(j=1; j> 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 +819,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 +981,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 +992,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 +1022,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) { @@ -1225,8 +1223,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 +1459,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 +1703,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(mSequence->GetDirManager(), mSequence->GetSampleFormat()); diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 1c9d409f4..265fef6f8 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -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,7 +1428,7 @@ 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 ); + 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); @@ -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 @@ -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); diff --git a/src/effects/Amplify.cpp b/src/effects/Amplify.cpp index dc2e73d73..d6d9d15cb 100644 --- a/src/effects/Amplify.cpp +++ b/src/effects/Amplify.cpp @@ -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; } diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index fc02860d5..ba31f0ed6 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -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); @@ -302,7 +300,7 @@ 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) { @@ -310,7 +308,7 @@ bool EffectAutoDuck::Process() mControlTrack->Get((samplePtr)buf, floatSample, pos, (sampleCount)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]; @@ -513,11 +511,11 @@ 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( mOuterFadeDownLen + mInnerFadeDownLen); @@ -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);; diff --git a/src/effects/ChangePitch.cpp b/src/effects/ChangePitch.cpp index 39519578d..6958828d5 100644 --- a/src/effects/ChangePitch.cpp +++ b/src/effects/ChangePitch.cpp @@ -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; diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index 422766dab..619d5e22b 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -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) diff --git a/src/effects/ClickRemoval.cpp b/src/effects/ClickRemoval.cpp index c300c6336..d820bd871 100644 --- a/src/effects/ClickRemoval.cpp +++ b/src/effects/ClickRemoval.cpp @@ -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; diff --git a/src/effects/Compressor.cpp b/src/effects/Compressor.cpp index 87827bdde..eb518adb5 100644 --- a/src/effects/Compressor.cpp +++ b/src/effects/Compressor.cpp @@ -370,7 +370,7 @@ bool EffectCompressor::InitPass1() 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 diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index cb89e0bf3..e0079fd60 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -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) { diff --git a/src/effects/DtmfGen.cpp b/src/effects/DtmfGen.cpp index 93933fc15..fbe9b67de 100644 --- a/src/effects/DtmfGen.cpp +++ b/src/effects/DtmfGen.cpp @@ -117,8 +117,8 @@ 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 @@ -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,7 +527,7 @@ 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= 0) { diff --git a/src/effects/Echo.cpp b/src/effects/Echo.cpp index 8a5fd7248..e89c0b042 100644 --- a/src/effects/Echo.cpp +++ b/src/effects/Echo.cpp @@ -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) { diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index ffe178a9f..778a0108e 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -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 genLeft, genRight; - sampleCount genLength = 0; + decltype(len) genLength = 0; bool isGenerator = GetType() == EffectTypeGenerate; bool isProcessor = GetType() == EffectTypeProcess; double genDur = 0; @@ -1616,7 +1614,7 @@ 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++) @@ -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,7 +2018,7 @@ void Effect::GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len) if (t1 > t0) { *start = track->TimeToLongSamples(t0); - sampleCount end = track->TimeToLongSamples(t1); + auto end = track->TimeToLongSamples(t1); *len = (sampleCount)(end - *start); } else { @@ -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++) diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 014a10573..fd3a0d716 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -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 len) block = len; diff --git a/src/effects/Equalization48x.cpp b/src/effects/Equalization48x.cpp index 8be27a314..62a168c34 100644 --- a/src/effects/Equalization48x.cpp +++ b/src/effects/Equalization48x.cpp @@ -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,18 +406,18 @@ 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;imT1 > 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; @@ -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;bigRunGetMaxBlockSize(); + 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;bigRunGetTrackFactory()->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;bigRunGetTrackFactory()->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; diff --git a/src/effects/Fade.cpp b/src/effects/Fade.cpp index 7a9733b2b..bcfb7ea72 100644 --- a/src/effects/Fade.cpp +++ b/src/effects/Fade.cpp @@ -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; } diff --git a/src/effects/FindClipping.cpp b/src/effects/FindClipping.cpp index bc067e7ab..063c3d6bd 100644 --- a/src/effects/FindClipping.cpp +++ b/src/effects/FindClipping.cpp @@ -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,9 +163,7 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt, float *ptr = buffer; - sampleCount startrun = 0; - sampleCount stoprun = 0; - sampleCount samps = 0; + decltype(len) s = 0, startrun = 0, stoprun = 0, samps = 0; size_t block = 0; double startTime = -1.0; diff --git a/src/effects/Generator.cpp b/src/effects/Generator.cpp index 61a3dcd44..67c432eb7 100644 --- a/src/effects/Generator.cpp +++ b/src/effects/Generator.cpp @@ -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) { diff --git a/src/effects/Invert.cpp b/src/effects/Invert.cpp index a2c2a955b..899540231 100644 --- a/src/effects/Invert.cpp +++ b/src/effects/Invert.cpp @@ -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]; } diff --git a/src/effects/Leveller.cpp b/src/effects/Leveller.cpp index fc02bcc22..02b4747d4 100644 --- a/src/effects/Leveller.cpp +++ b/src/effects/Leveller.cpp @@ -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++) diff --git a/src/effects/Noise.cpp b/src/effects/Noise.cpp index 6c7fab735..40d8dbd42 100644 --- a/src/effects/Noise.cpp +++ b/src/effects/Noise.cpp @@ -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; diff --git a/src/effects/NoiseReduction.cpp b/src/effects/NoiseReduction.cpp index 2081acc21..370afabbc 100644 --- a/src/effects/NoiseReduction.cpp +++ b/src/effects/NoiseReduction.cpp @@ -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( diff --git a/src/effects/NoiseRemoval.cpp b/src/effects/NoiseRemoval.cpp index 9a7fce27e..288c64e65 100644 --- a/src/effects/NoiseRemoval.cpp +++ b/src/effects/NoiseRemoval.cpp @@ -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 diff --git a/src/effects/Normalize.cpp b/src/effects/Normalize.cpp index c4422fbd0..3a1332d3d 100644 --- a/src/effects/Normalize.cpp +++ b/src/effects/Normalize.cpp @@ -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; iGetRate()); 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 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.")); diff --git a/src/effects/Repeat.cpp b/src/effects/Repeat.cpp index dbfa6ba70..cbeeddbd5 100644 --- a/src/effects/Repeat.cpp +++ b/src/effects/Repeat.cpp @@ -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; diff --git a/src/effects/Reverb.cpp b/src/effects/Reverb.cpp index e026aeca4..73392584e 100644 --- a/src/effects/Reverb.cpp +++ b/src/effects/Reverb.cpp @@ -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] + diff --git a/src/effects/Reverse.cpp b/src/effects/Reverse.cpp index b026fa28c..40ae4d2f5 100644 --- a/src/effects/Reverse.cpp +++ b/src/effects/Reverse.cpp @@ -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); diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp index 580d46425..345c7bc36 100644 --- a/src/effects/SBSMSEffect.cpp +++ b/src/effects/SBSMSEffect.cpp @@ -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,8 +273,10 @@ 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(); @@ -284,7 +284,7 @@ bool EffectSBSMS::Process() // 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,10 +293,10 @@ 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; @@ -361,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; diff --git a/src/effects/SimpleMono.cpp b/src/effects/SimpleMono.cpp index a6a81774d..40f47ce9b 100644 --- a/src/effects/SimpleMono.cpp +++ b/src/effects/SimpleMono.cpp @@ -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 diff --git a/src/effects/SoundTouchEffect.cpp b/src/effects/SoundTouchEffect.cpp index c353784d5..6a1e5aefe 100644 --- a/src/effects/SoundTouchEffect.cpp +++ b/src/effects/SoundTouchEffect.cpp @@ -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 diff --git a/src/effects/StereoToMono.cpp b/src/effects/StereoToMono.cpp index e68eeab23..a8c6e1fd6 100644 --- a/src/effects/StereoToMono.cpp +++ b/src/effects/StereoToMono.cpp @@ -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; diff --git a/src/effects/ToneGen.cpp b/src/effects/ToneGen.cpp index f93fcaccd..033e64ecd 100644 --- a/src/effects/ToneGen.cpp +++ b/src/effects/ToneGen.cpp @@ -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) { diff --git a/src/effects/TruncSilence.cpp b/src/effects/TruncSilence.cpp index a62f5d815..cf4ff5f4c 100644 --- a/src/effects/TruncSilence.cpp +++ b/src/effects/TruncSilence.cpp @@ -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(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(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; } diff --git a/src/effects/TwoPassSimpleMono.cpp b/src/effects/TwoPassSimpleMono.cpp index 8037853f9..46a90c861 100644 --- a/src/effects/TwoPassSimpleMono.cpp +++ b/src/effects/TwoPassSimpleMono.cpp @@ -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 diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index fc678f519..bdfbcbfe7 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -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]; } diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index 99b6c4d5b..30f8e5b52 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -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]; } diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index 336d5265d..60cd79982 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -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]; } diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index a2c90968e..5ff9b5675 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -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); diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index 249f08812..ae5afbceb 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -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) { diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index 68ee6f051..76ad0039a 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -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; } diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index c615ef7f2..51137a336 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -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; diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index 196555910..ef5075ff9 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -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; } diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp index c8a1f8e26..d5b281870 100644 --- a/src/export/ExportMP2.cpp +++ b/src/export/ExportMP2.cpp @@ -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; diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index 4e26f904b..f7107fba6 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -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; diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp index 012264528..472ed098d 100644 --- a/src/export/ExportOGG.cpp +++ b/src/export/ExportOGG.cpp @@ -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. diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index 4c1a1008c..7a9618527 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -491,7 +491,7 @@ int ExportPCM::Export(AudacityProject *project, while (updateResult == eProgressSuccess) { sf_count_t samplesWritten; - sampleCount numSamples = mixer->Process(maxBlockLen); + auto numSamples = mixer->Process(maxBlockLen); if (numSamples == 0) break; diff --git a/src/import/ImportFFmpeg.cpp b/src/import/ImportFFmpeg.cpp index 76e6d9998..12df5b2db 100644 --- a/src/import/ImportFFmpeg.cpp +++ b/src/import/ImportFFmpeg.cpp @@ -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 ); diff --git a/src/import/ImportFLAC.cpp b/src/import/ImportFLAC.cpp index f61745409..b18835a0f 100644 --- a/src/import/ImportFLAC.cpp +++ b/src/import/ImportFLAC.cpp @@ -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 ); diff --git a/src/import/ImportMP3.cpp b/src/import/ImportMP3.cpp index 56bd6b555..85b65a8c3 100644 --- a/src/import/ImportMP3.cpp +++ b/src/import/ImportMP3.cpp @@ -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 diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index 8feadedf0..7279b40db 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -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::max() / - (mInfo.channels * SAMPLE_SIZE(mFormat))) + using type = decltype(maxBlockSize); + auto maxBlock = std::min(maxBlockSize, + std::numeric_limits::max() / + (mInfo.channels * SAMPLE_SIZE(mFormat)) ); if (maxBlock < 1) return eProgressFailed; diff --git a/src/import/ImportQT.cpp b/src/import/ImportQT.cpp index 60732065b..9cf025775 100644 --- a/src/import/ImportQT.cpp +++ b/src/import/ImportQT.cpp @@ -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; diff --git a/src/import/ImportRaw.cpp b/src/import/ImportRaw.cpp index fb81bb2d6..63d235ac1 100644 --- a/src/import/ImportRaw.cpp +++ b/src/import/ImportRaw.cpp @@ -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_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; diff --git a/src/ondemand/ODComputeSummaryTask.cpp b/src/ondemand/ODComputeSummaryTask.cpp index f82e18b2e..4d8663a2e 100644 --- a/src/ondemand/ODComputeSummaryTask.cpp +++ b/src/ondemand/ODComputeSummaryTask.cpp @@ -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. diff --git a/src/ondemand/ODDecodeFFmpegTask.cpp b/src/ondemand/ODDecodeFFmpegTask.cpp index c1c63807e..0e5174992 100644 --- a/src/ondemand/ODDecodeFFmpegTask.cpp +++ b/src/ondemand/ODDecodeFFmpegTask.cpp @@ -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 diff --git a/src/ondemand/ODDecodeTask.cpp b/src/ondemand/ODDecodeTask.cpp index cffd84a36..4faf81e0e 100644 --- a/src/ondemand/ODDecodeTask.cpp +++ b/src/ondemand/ODDecodeTask.cpp @@ -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. diff --git a/src/ondemand/ODTask.cpp b/src/ondemand/ODTask.cpp index 39de3aaae..4adcd0e67 100644 --- a/src/ondemand/ODTask.cpp +++ b/src/ondemand/ODTask.cpp @@ -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; diff --git a/src/toolbars/TranscriptionToolBar.cpp b/src/toolbars/TranscriptionToolBar.cpp index fda47040e..cf821dfb7 100644 --- a/src/toolbars/TranscriptionToolBar.cpp +++ b/src/toolbars/TranscriptionToolBar.cpp @@ -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. From fd2b050d6f25b5e296a036e9c524f9bc0954c78b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 24 Aug 2016 07:56:33 -0400 Subject: [PATCH 6/7] Type agnosticism for some other variables that were not sampleCount... ... in some cases, this fixes narrowings. --- src/Benchmark.cpp | 2 +- src/Dependencies.cpp | 2 +- src/Mix.cpp | 8 +++----- src/Sequence.cpp | 5 ++--- src/WaveClip.cpp | 2 +- src/WaveTrack.cpp | 2 +- src/commands/CompareAudioCommand.cpp | 10 +++++----- src/effects/AutoDuck.cpp | 4 ++-- src/effects/BassTreble.cpp | 2 +- src/effects/Distortion.cpp | 2 +- src/effects/Effect.cpp | 2 +- src/effects/Equalization48x.cpp | 2 +- src/effects/FindClipping.cpp | 2 +- src/effects/Wahwah.cpp | 2 +- src/export/ExportFLAC.cpp | 6 +++--- src/import/ImportPCM.cpp | 2 +- 16 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/Benchmark.cpp b/src/Benchmark.cpp index 8a8417664..d6139d18a 100644 --- a/src/Benchmark.cpp +++ b/src/Benchmark.cpp @@ -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; diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index 5331d9b2c..ec7cf7f14 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -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); diff --git a/src/Mix.cpp b/src/Mix.cpp index 827e9f091..d0f697d1e 100644 --- a/src/Mix.cpp +++ b/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. @@ -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]; } @@ -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(); diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 031ba1171..801e835bb 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -1556,11 +1556,10 @@ 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 auto offset = i * len / num; diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 2c539460e..2f684e8b1 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -608,7 +608,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. diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 265fef6f8..61a972d0d 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -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; } diff --git a/src/commands/CompareAudioCommand.cpp b/src/commands/CompareAudioCommand.cpp index e0344b307..874e48faa 100644 --- a/src/commands/CompareAudioCommand.cpp +++ b/src/commands/CompareAudioCommand.cpp @@ -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 diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index ba31f0ed6..c3450303e 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -517,12 +517,12 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNumber, WaveTrack* t, float *buf = new float[kBufSize]; 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; diff --git a/src/effects/BassTreble.cpp b/src/effects/BassTreble.cpp index 24bdf9ff2..73796b75c 100644 --- a/src/effects/BassTreble.cpp +++ b/src/effects/BassTreble.cpp @@ -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; } diff --git a/src/effects/Distortion.cpp b/src/effects/Distortion.cpp index 34b977ca6..dfdd6c42e 100644 --- a/src/effects/Distortion.cpp +++ b/src/effects/Distortion.cpp @@ -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(); } diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 778a0108e..88656ea9a 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1617,7 +1617,7 @@ bool Effect::ProcessTrack(int count, 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; } diff --git a/src/effects/Equalization48x.cpp b/src/effects/Equalization48x.cpp index 62a168c34..16c9d865c 100644 --- a/src/effects/Equalization48x.cpp +++ b/src/effects/Equalization48x.cpp @@ -420,7 +420,7 @@ bool EffectEqualization48x::DeltaTrack(WaveTrack * t, WaveTrack * t2, sampleCoun auto curretLength = (trackBlockSize > len) ? len : trackBlockSize; t->Get((samplePtr)buffer1, floatSample, currentSample, curretLength); t2->Get((samplePtr)buffer2, floatSample, currentSample, curretLength); - for(int i=0;iAppend((samplePtr)buffer1, floatSample, curretLength); currentSample+=curretLength; diff --git a/src/effects/FindClipping.cpp b/src/effects/FindClipping.cpp index 063c3d6bd..546724c70 100644 --- a/src/effects/FindClipping.cpp +++ b/src/effects/FindClipping.cpp @@ -164,7 +164,7 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt, float *ptr = buffer; decltype(len) s = 0, startrun = 0, stoprun = 0, samps = 0; - size_t block = 0; + decltype(blockSize) block = 0; double startTime = -1.0; while (s < len) { diff --git a/src/effects/Wahwah.cpp b/src/effects/Wahwah.cpp index c498c9d56..c8b5e7e86 100644 --- a/src/effects/Wahwah.cpp +++ b/src/effects/Wahwah.cpp @@ -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]; diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index ef5075ff9..a935ebbc0 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -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)); @@ -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]; } } diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index 7279b40db..05c628a4c 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -448,7 +448,7 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory, SampleBuffer buffer(maxBlock, mFormat); - unsigned long framescompleted = 0; + decltype(fileTotalFrames) framescompleted = 0; long block; do { From 52417c444dc960fe0a8eb24fb8c5f77f68ea7950 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 24 Aug 2016 08:02:09 -0400 Subject: [PATCH 7/7] Remove unnecessary casts to sampleCount --- src/WaveClip.cpp | 10 ++++------ src/WaveTrack.cpp | 2 +- src/effects/AutoDuck.cpp | 2 +- src/effects/DtmfGen.cpp | 4 ++-- src/effects/Effect.cpp | 2 +- src/effects/Equalization.cpp | 2 +- src/effects/Equalization48x.cpp | 2 +- src/effects/audiounits/AudioUnitEffect.cpp | 4 ++-- src/ondemand/ODComputeSummaryTask.cpp | 6 +++--- src/ondemand/ODDecodeTask.cpp | 6 +++--- 10 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 2f684e8b1..0bdc51778 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -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 @@ -472,11 +472,9 @@ fillWhere(std::vector &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))); + where[0] = std::max(0.0, floor(w0)); for (decltype(len) x = 1; x < len + 1; x++) - where[x] = sampleCount( - floor(w0 + double(x) * samplesPerPixel) - ); + where[x] = floor(w0 + double(x) * samplesPerPixel); } } @@ -1198,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 diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 61a972d0d..43831c8fb 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -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 diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index c3450303e..40f90e95a 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -306,7 +306,7 @@ bool EffectAutoDuck::Process() { const auto len = limitSampleBufferSize( kBufSize, end - pos ); - mControlTrack->Get((samplePtr)buf, floatSample, pos, (sampleCount)len); + mControlTrack->Get((samplePtr)buf, floatSample, pos, len); for (auto i = pos; i < pos + len; i++) { diff --git a/src/effects/DtmfGen.cpp b/src/effects/DtmfGen.cpp index fbe9b67de..b01f1bda7 100644 --- a/src/effects/DtmfGen.cpp +++ b/src/effects/DtmfGen.cpp @@ -122,8 +122,8 @@ bool EffectDtmf::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames 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) diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 88656ea9a..0a4fa97dc 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -2019,7 +2019,7 @@ void Effect::GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len) if (t1 > t0) { *start = track->TimeToLongSamples(t0); auto end = track->TimeToLongSamples(t1); - *len = (sampleCount)(end - *start); + *len = end - *start; } else { *start = 0; diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index fd3a0d716..8342213ff 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -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 diff --git a/src/effects/Equalization48x.cpp b/src/effects/Equalization48x.cpp index 16c9d865c..bca3f395a 100644 --- a/src/effects/Equalization48x.cpp +++ b/src/effects/Equalization48x.cpp @@ -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 diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index 30f8e5b52..1173e1e9e 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -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() diff --git a/src/ondemand/ODComputeSummaryTask.cpp b/src/ondemand/ODComputeSummaryTask.cpp index 4d8663a2e..1def19b0b 100644 --- a/src/ondemand/ODComputeSummaryTask.cpp +++ b/src/ondemand/ODComputeSummaryTask.cpp @@ -203,12 +203,12 @@ void ODComputeSummaryTask::Update() const auto odpcmaFile = std::static_pointer_cast(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); diff --git a/src/ondemand/ODDecodeTask.cpp b/src/ondemand/ODDecodeTask.cpp index 4faf81e0e..31f81d478 100644 --- a/src/ondemand/ODDecodeTask.cpp +++ b/src/ondemand/ODDecodeTask.cpp @@ -159,12 +159,12 @@ void ODDecodeTask::Update() std::static_pointer_cast(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);