diff --git a/mac/Audacity.xcodeproj/project.pbxproj b/mac/Audacity.xcodeproj/project.pbxproj
index 04b00e020d2721d78ef3f81c2085bbe88d4b5b43..a31f7ddc6965c4253878693f3ca1162f64d79d99 100644
--- a/mac/Audacity.xcodeproj/project.pbxproj
+++ b/mac/Audacity.xcodeproj/project.pbxproj
@@ -3102,8 +3102,8 @@
 		EDD94ED9103CB520000873F1 /* ImportExportCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.cpp.cpp; path = ImportExportCommands.cpp; sourceTree = "<group>"; tabWidth = 3; };
 		EDD94EDA103CB520000873F1 /* ImportExportCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.h; path = ImportExportCommands.h; sourceTree = "<group>"; tabWidth = 3; };
 		EDE325FF168243EF00C19E60 /* vr32.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vr32.c; sourceTree = "<group>"; };
-		EDF3B7AE1588C0D50032D35F /* Paulstretch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Paulstretch.h; path = effects/Paulstretch.h; sourceTree = "<group>"; };
-		EDF3B7AF1588C0D50032D35F /* Paulstretch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Paulstretch.cpp; path = effects/Paulstretch.cpp; sourceTree = "<group>"; };
+		EDF3B7AE1588C0D50032D35F /* Paulstretch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Paulstretch.h; sourceTree = "<group>"; };
+		EDF3B7AF1588C0D50032D35F /* Paulstretch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Paulstretch.cpp; sourceTree = "<group>"; };
 		EDFCEB9A18894AE600C98E51 /* OpenSaveCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OpenSaveCommands.cpp; sourceTree = "<group>"; };
 		EDFCEB9B18894AE600C98E51 /* OpenSaveCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenSaveCommands.h; sourceTree = "<group>"; };
 		EDFCEBA218894B2A00C98E51 /* RealFFTf48x.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RealFFTf48x.cpp; sourceTree = "<group>"; };
@@ -3874,7 +3874,6 @@
 				289E75081006D0BD00CEF79B /* MixerBoard.cpp */,
 				280A8B4519F4403B0091DE70 /* ModuleManager.cpp */,
 				1790B0AF09883BFD008A330A /* NoteTrack.cpp */,
-				EDF3B7AF1588C0D50032D35F /* Paulstretch.cpp */,
 				1790B0B109883BFD008A330A /* PitchName.cpp */,
 				1790B0B309883BFD008A330A /* PlatformCompatibility.cpp */,
 				287E207E102561F300BF47A2 /* PluginManager.cpp */,
@@ -3966,7 +3965,6 @@
 				280A8B4619F4403B0091DE70 /* ModuleManager.h */,
 				1790B0B009883BFD008A330A /* NoteTrack.h */,
 				280F5C8B1B676699003022C5 /* NumberScale.h */,
-				EDF3B7AE1588C0D50032D35F /* Paulstretch.h */,
 				1790B0B209883BFD008A330A /* PitchName.h */,
 				1790B0B409883BFD008A330A /* PlatformCompatibility.h */,
 				2803C8B519F35AA000278526 /* PluginManager.h */,
@@ -4115,6 +4113,8 @@
 				1790B03409883BFD008A330A /* nyquist */,
 				1790B03A09883BFD008A330A /* Phaser.cpp */,
 				1790B03B09883BFD008A330A /* Phaser.h */,
+				EDF3B7AF1588C0D50032D35F /* Paulstretch.cpp */,
+				EDF3B7AE1588C0D50032D35F /* Paulstretch.h */,
 				28EBA7FA0A78FADE00C8BB1F /* Repair.cpp */,
 				28EBA7FB0A78FADE00C8BB1F /* Repair.h */,
 				1790B03E09883BFD008A330A /* Repeat.cpp */,
diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp
index c46061a04bd4b1a5578c75dade05442e461df873..4ae6df1e651a3bc9ae2082e4e018bd11a6f8cc6f 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/Benchmark.cpp b/src/Benchmark.cpp
index 8a84176645364f86473c399372331e3f5d9b001e..d6139d18a3850fb32a0533e25750901195639efa 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/BlockFile.cpp b/src/BlockFile.cpp
index e9f08556d2e133b36a7148134ea90ac72e11e5b4..414a3de2c83b203b09282421d8588d725ab65302 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/Dependencies.cpp b/src/Dependencies.cpp
index 5331d9b2cbd0f0078892422d6a2f0224ef41d7e2..ec7cf7f14103cf05a8b50cfccea66699cf9c2e8f 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/FreqWindow.cpp b/src/FreqWindow.cpp
index 026663fe8f54d36a9555c0936087f2184e1e2574..0a1be3ee008a8b4eac6bce31b864658c98fe1db2 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 e46ca1e7912225b30ef51e21a96712589e01c055..c3fe8f1e504cbb9ae3145e12078ef82bd5606458 100644
--- a/src/Menus.cpp
+++ b/src/Menus.cpp
@@ -3412,7 +3412,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 5c130e3fabfb54aa600d379ba833513fdabb919a..d0f697d1eda0f19686ac1d72824828434f57a723 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.
@@ -172,7 +172,7 @@ void MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
          _("Mixing and rendering tracks"));
 
       while (updateResult == eProgressSuccess) {
-         sampleCount blockLen = mixer.Process(maxBlockLen);
+         auto blockLen = mixer.Process(maxBlockLen);
 
          if (blockLen == 0)
             break;
@@ -338,9 +338,7 @@ Mixer::Mixer(const WaveTrackConstArray &inputTracks,
       mQueueLen[i] = 0;
    }
 
-   int envLen = mInterleavedBufferSize;
-   if (mQueueMaxLen > envLen)
-      envLen = mQueueMaxLen;
+   const auto envLen = std::max(mQueueMaxLen, mInterleavedBufferSize);
    mEnvValues = new double[envLen];
 }
 
@@ -418,7 +416,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
    const double tstep = 1.0 / trackRate;
    int sampleSize = SAMPLE_SIZE(floatSample);
 
-   sampleCount out = 0;
+   decltype(mMaxOut) out = 0;
 
    /* time is floating point. Sample rate is integer. The number of samples
     * has to be integer, but the multiplication gives a float result, which we
@@ -438,7 +436,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
    const double tEnd = backwards
       ? std::max(startTime, mT1)
       : std::min(endTime, mT1);
-   const sampleCount endPos = track->TimeToLongSamples(tEnd);
+   const auto endPos = track->TimeToLongSamples(tEnd);
    // Find the time corresponding to the start of the queue, for use with time track
    double t = (*pos + (backwards ? *queueLen : - *queueLen)) / trackRate;
 
@@ -448,7 +446,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
          memmove(queue, &queue[*queueStart], (*queueLen) * sampleSize);
          *queueStart = 0;
 
-         const auto getLen = limitSampleBufferSize(
+         auto getLen = limitSampleBufferSize(
             mQueueMaxLen - *queueLen,
             backwards ? *pos - endPos : endPos - *pos
          );
@@ -476,7 +474,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
                *pos += getLen;
             }
 
-            for (auto i = 0; i < getLen; i++) {
+            for (decltype(getLen) i = 0; i < getLen; i++) {
                queue[(*queueLen) + i] *= mEnvValues[i];
             }
 
@@ -488,7 +486,7 @@ sampleCount Mixer::MixVariableRates(int *channelFlags, WaveTrackCache &cache,
          }
       }
 
-      sampleCount thisProcessLen = mProcessLen;
+      auto thisProcessLen = mProcessLen;
       bool last = (*queueLen < mProcessLen);
       if (last) {
          thisProcessLen = *queueLen;
@@ -557,7 +555,7 @@ sampleCount Mixer::MixSameRate(int *channelFlags, WaveTrackCache &cache,
                                sampleCount *pos)
 {
    const WaveTrack *const track = cache.GetTrack();
-   int slen = mMaxOut;
+   auto slen = mMaxOut;
    int c;
    const double t = *pos / track->GetRate();
    const double trackEndTime = track->GetEndTime();
@@ -625,7 +623,7 @@ sampleCount Mixer::Process(sampleCount maxToProcess)
    //   return 0;
 
    int i, j;
-   sampleCount maxOut = 0;
+   decltype(Process(0)) maxOut = 0;
    int *channelFlags = new int[mNumChannels];
 
    mMaxOut = maxToProcess;
diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp
index 393e66cc21ca0a0c80458f0ba50ee557d8566130..ac065cbdbe8fb7151bf28c5429eea38f347aa627 100644
--- a/src/MixerBoard.cpp
+++ b/src/MixerBoard.cpp
@@ -634,8 +634,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 0536b058d4839e3952fee8f233ca681298c5dbc8..801e835bb980b961ed55ee3251803adfb4f98e0e 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+1<numBlocks &&
          ((length = mBlock[b+1].f->GetLength()) + result) <= mMaxSamples) {
       b++;
@@ -792,8 +786,6 @@ sampleCount Sequence::GetBestBlockSize(sampleCount start) const
 
 bool Sequence::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
 {
-   sampleCount nValue;
-
    /* handle waveblock tag and its attributes */
    if (!wxStrcmp(tag, wxT("waveblock"))) {
       SeqBlock wb;
@@ -804,6 +796,8 @@ bool Sequence::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
          const wxChar *attr = *attrs++;
          const wxChar *value = *attrs++;
 
+         long long nValue = 0;
+
          if (!value)
             break;
 
@@ -857,6 +851,8 @@ bool Sequence::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
          if (!value)
             break;
 
+         long long nValue = 0;
+
          const wxString strValue = value;	// promote string, we need this for all
 
          if (!wxStrcmp(attr, wxT("maxsamples")))
@@ -1115,7 +1111,7 @@ bool Sequence::CopyWrite(SampleBuffer &scratch,
    // we copy the old block entirely into memory, dereference it,
    // make the change, and then write the NEW block to disk.
 
-   const sampleCount length = b.f->GetLength();
+   const auto length = b.f->GetLength();
    wxASSERT(length <= mMaxSamples);
    wxASSERT(start + len <= length);
    wxASSERT(start >= 0);
@@ -1151,8 +1147,7 @@ bool Sequence::Get(int b, samplePtr buffer, sampleFormat format,
    while (len) {
       const SeqBlock &block = mBlock[b];
       const sampleCount bstart = (start - (block.start));
-      const sampleCount blen =
-          std::min(len, block.f->GetLength() - bstart);
+      const auto blen = std::min(len, block.f->GetLength() - bstart);
 
       Read(buffer, format, block, bstart, blen);
 
@@ -1186,7 +1181,7 @@ bool Sequence::Set(samplePtr buffer, sampleFormat format,
    while (len != 0) {
       SeqBlock &block = mBlock[b];
       const sampleCount bstart = start - block.start;
-      const sampleCount fileLength = block.f->GetLength();
+      const auto fileLength = block.f->GetLength();
       const auto blen = limitSampleBufferSize( fileLength - bstart, len );
 
       if (buffer) {
@@ -1269,7 +1264,7 @@ struct MinMaxSumsq
 bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
                               int len, const sampleCount *where)
 {
-   const sampleCount s0 = std::max(sampleCount(0), where[0]);
+   const auto s0 = std::max(sampleCount(0), where[0]);
    if (s0 >= mNumSamples)
       // None of the samples asked for are in range. Abandon.
       return false;
@@ -1277,18 +1272,18 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
    // In case where[len - 1] == where[len], raise the limit by one,
    // so we load at least one pixel for column len - 1
    // ... unless the mNumSamples ceiling applies, and then there are other defenses
-   const sampleCount s1 =
+   const auto s1 =
       std::min(mNumSamples, std::max(1 + where[len - 1], where[len]));
    float *temp = new float[mMaxSamples];
 
    int pixel = 0;
 
-   sampleCount srcX = s0;
-   sampleCount nextSrcX = 0;
+   auto srcX = s0;
+   decltype(srcX) nextSrcX = 0;
    int lastRmsDenom = 0;
    int lastDivisor = 0;
-   sampleCount whereNow = std::min(s1 - 1, where[0]);
-   sampleCount whereNext = 0;
+   auto whereNow = std::min(s1 - 1, where[0]);
+   decltype(whereNow) whereNext = 0;
    // Loop over block files, opening and reading and closing each
    // not more than once
    unsigned nBlocks = mBlock.size();
@@ -1302,7 +1297,7 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
       // Find the range of sample values for this block that
       // are in the display.
       SeqBlock &seqBlock = mBlock[b];
-      const sampleCount start = seqBlock.start;
+      const auto start = seqBlock.start;
       nextSrcX = std::min(s1, start + seqBlock.f->GetLength());
 
       // The column for pixel p covers samples from
@@ -1349,7 +1344,7 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
          std::max(sampleCount(0), (srcX - start) / divisor);
       const sampleCount inclusiveEndPosition =
          std::min((mMaxSamples / divisor) - 1, (nextSrcX - 1 - start) / divisor);
-      const sampleCount num = 1 + inclusiveEndPosition - startPosition;
+      const auto num = 1 + inclusiveEndPosition - startPosition;
       if (num <= 0) {
          // What?  There was a zero length block file?
          wxASSERT(false);
@@ -1389,7 +1384,7 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
          break;
       }
       
-      sampleCount filePosition = startPosition;
+      auto filePosition = startPosition;
 
       // The previous pixel column might straddle blocks.
       // If so, impute some of the data to it.
@@ -1422,7 +1417,7 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
          // and the range of positions for those columns
          // (normally one or more, for that one column)
          int pixelX = pixel + 1;
-         sampleCount positionX = 0;
+         decltype(filePosition) positionX = 0;
          while (pixelX < nextPixel &&
             filePosition ==
                 (positionX = (std::min(s1 - 1, where[pixelX]) - start) / divisor)
@@ -1465,12 +1460,12 @@ bool Sequence::GetWaveDisplay(float *min, float *max, float *rms, int* bl,
 sampleCount Sequence::GetIdealAppendLen()
 {
    int numBlocks = mBlock.size();
-   const sampleCount max = GetMaxBlockSize();
+   const auto max = GetMaxBlockSize();
 
    if (numBlocks == 0)
       return max;
 
-   const sampleCount lastBlockLen = mBlock.back().f->GetLength();
+   const auto lastBlockLen = mBlock.back().f->GetLength();
    if (lastBlockLen == max)
       return max;
    else
@@ -1486,8 +1481,8 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format,
 
    // If the last block is not full, we need to add samples to it
    int numBlocks = mBlock.size();
-   sampleCount length;
    SeqBlock *pLastBlock;
+   decltype(pLastBlock->f->GetLength()) length;
    SampleBuffer buffer2(mMaxSamples, mSampleFormat);
    if (numBlocks > 0 &&
        (length =
@@ -1523,8 +1518,8 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format,
    }
    // Append the rest as NEW blocks
    while (len) {
-      const sampleCount idealSamples = GetIdealBlockSize();
-      const sampleCount l = std::min(idealSamples, len);
+      const auto idealSamples = GetIdealBlockSize();
+      const auto l = std::min(idealSamples, len);
       BlockFilePtr pFile;
       if (format == mSampleFormat) {
          pFile = mDirManager->NewSimpleBlockFile(buffer, l, mSampleFormat,
@@ -1561,14 +1556,13 @@ void Sequence::Blockify(BlockArray &list, sampleCount start, samplePtr buffer, s
 {
    if (len <= 0)
       return;
-
-   const int num = (len + (mMaxSamples - 1)) / mMaxSamples;
+   auto num = (len + (mMaxSamples - 1)) / mMaxSamples;
    list.reserve(list.size() + num);
 
-   for (int i = 0; i < num; i++) {
+   for (decltype(num) i = 0; i < num; i++) {
       SeqBlock b;
 
-      const sampleCount offset = i * len / num;
+      const auto offset = i * len / num;
       b.start = start + offset;
       int newLen = ((i + 1) * len / num) - offset;
       samplePtr bufStart = buffer + (offset * SAMPLE_SIZE(mSampleFormat));
@@ -1602,12 +1596,12 @@ bool Sequence::Delete(sampleCount start, sampleCount len)
    // block and the resulting length is not too small, perform the
    // deletion within this block:
    SeqBlock *pBlock;
-   sampleCount length;
+   decltype(pBlock->f->GetLength()) length;
 
    // One buffer for reuse in various branches here
    SampleBuffer scratch;
    // The maximum size that will ever be needed
-   const sampleCount scratchSize = mMaxSamples + mMinSamples;
+   const auto scratchSize = mMaxSamples + mMinSamples;
 
    if (b0 == b1 && (length = (pBlock = &mBlock[b0])->f->GetLength()) - len >= mMinSamples) {
       SeqBlock &b = *pBlock;
@@ -1660,8 +1654,8 @@ bool Sequence::Delete(sampleCount start, sampleCount len)
          newBlock.push_back(SeqBlock(pFile, preBlock.start));
       } else {
          const SeqBlock &prepreBlock = mBlock[b0 - 1];
-         const sampleCount prepreLen = prepreBlock.f->GetLength();
-         const sampleCount sum = prepreLen + preBufferLen;
+         const auto prepreLen = prepreBlock.f->GetLength();
+         const auto sum = prepreLen + preBufferLen;
 
          if (!scratch.ptr())
             scratch.Allocate(scratchSize, mSampleFormat);
@@ -1700,8 +1694,8 @@ bool Sequence::Delete(sampleCount start, sampleCount len)
          newBlock.push_back(SeqBlock(file, start));
       } else {
          SeqBlock &postpostBlock = mBlock[b1 + 1];
-         sampleCount postpostLen = postpostBlock.f->GetLength();
-         sampleCount sum = postpostLen + postBufferLen;
+         const auto postpostLen = postpostBlock.f->GetLength();
+         const auto sum = postpostLen + postBufferLen;
 
          if (!scratch.ptr())
             // Last use of scratch, can ask for smaller
diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp
index 5b100b0ead43b81f214ed52fae6cb2b4d7c79b41..c96aac0ddc50058c6d6b532b99d15c12737c9455 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 4d497419ba701ee769a032edea858fe7466658ff..69e52b23d5957f6a4d82ad3ed2d081757db89522 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<float> frequencySnappingData;
-   const sampleCount start =
+   const auto start =
       pTrack->TimeToLongSamples(mViewInfo->selectedRegion.t0());
-   const sampleCount end =
+   const auto end =
       pTrack->TimeToLongSamples(mViewInfo->selectedRegion.t1());
    const auto length =
       std::min(frequencySnappingData.max_size(),
@@ -3248,7 +3248,7 @@ namespace {
          // WaveClip::GetClipAtX doesn't work unless the clip is on the screen and can return bad info otherwise
          // instead calculate the time manually
          double rate = pTrack->GetRate();
-         sampleCount s0 = (sampleCount)(time * rate + 0.5);
+         auto s0 = (sampleCount)(time * rate + 0.5);
 
          if (s0 >= 0)
             return pTrack->GetClipAtSample(s0);
@@ -4507,15 +4507,15 @@ void TrackPanel::HandleSampleEditingDrag( wxMouseEvent & event )
 
    //Now, redraw all samples between current and last redrawn sample, inclusive
    //Go from the smaller to larger sample.
-   const int start = std::min( s0, mDrawingLastDragSample);
-   const int end   = std::max( s0, mDrawingLastDragSample);
+   const auto start = std::min( s0, mDrawingLastDragSample);
+   const auto end   = std::max( s0, mDrawingLastDragSample);
    const int size = end - start + 1;
    if (size == 1) {
       mDrawingTrack->Set((samplePtr)&newLevel, floatSample, start, size);
    }
    else {
       std::vector<float> values(size);
-      for (sampleCount i = start; i <= end; ++i) {
+      for (auto i = start; i <= end; ++i) {
          //This interpolates each sample linearly:
          values[i - start] =
             mDrawingLastDragSampleValue + (newLevel - mDrawingLastDragSampleValue)  *
@@ -6657,7 +6657,7 @@ bool TrackPanel::HitTestSamples(Track *track, wxRect &rect, const wxMouseEvent &
 
    // Just get one sample.
    float oneSample;
-   sampleCount s0 = (sampleCount)(tt * rate + 0.5);
+   auto s0 = (sampleCount)(tt * rate + 0.5);
    wavetrack->Get((samplePtr)&oneSample, floatSample, s0, 1);
 
    // Get y distance of envelope point from center line (in pixels).
diff --git a/src/VoiceKey.cpp b/src/VoiceKey.cpp
index 7a9b85e9cfb04343d261212125c01ed551c791fb..952758337e4e92054b8f81e7c5a0d12ac33eb2bb 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
@@ -848,12 +848,12 @@ double VoiceKey::TestEnergy (WaveTrack & t, sampleCount start, sampleCount len)
    while(len > 0)
       {
          //Figure out how much to grab
-         const auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len );
+         auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len );
 
          t.Get((samplePtr)buffer,floatSample, s,block);                      //grab the block;
 
          //Now, go through the block and calculate energy
-         for(auto i = 0; i< block; i++)
+         for(decltype(block) i = 0; i< block; i++)
             {
                sum += buffer[i]*buffer[i];
             }
@@ -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;
@@ -891,7 +891,7 @@ double VoiceKey::TestSignChanges(WaveTrack & t, sampleCount start, sampleCount l
 
    while(len > 0) {
       //Figure out how much to grab
-      const auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len );
+      auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len );
 
       t.Get((samplePtr)buffer,floatSample, s,block);                      //grab the block;
 
@@ -903,7 +903,7 @@ double VoiceKey::TestSignChanges(WaveTrack & t, sampleCount start, sampleCount l
 
       //Now, go through the block and calculate zero crossings
 
-      for(auto i = 0; i< block; i++)
+      for(decltype(block) i = 0; i< block; i++)
          {
             if( sgn(buffer[i]) != currentsign)
                {
@@ -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;
@@ -948,7 +948,7 @@ double VoiceKey::TestDirectionChanges(WaveTrack & t, sampleCount start, sampleCo
 
    while(len > 0) {
       //Figure out how much to grab
-      const auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len );
+      auto block = limitSampleBufferSize ( t.GetBestBlockSize(s), len );
 
       t.Get((samplePtr)buffer,floatSample, s,block);                      //grab the block;
 
@@ -960,7 +960,7 @@ double VoiceKey::TestDirectionChanges(WaveTrack & t, sampleCount start, sampleCo
       //Now, go through the block and calculate zero crossings
 
 
-      for(auto i = 0; i< block; i++){
+      for(decltype(block) i = 0; i< block; i++){
 
          if( sgn(buffer[i]-lastval) != lastdirection) {
             directionchanges++;
diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp
index 2512e659271266f8ccee812518d3328cb43e978e..0bdc51778ce64b90e3ad880e949c8f9a2a3a4dcc 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;
@@ -375,7 +375,7 @@ double WaveClip::GetEndTime() const
 
 sampleCount WaveClip::GetStartSample() const
 {
-   return (sampleCount)floor(mOffset * mRate + 0.5);
+   return floor(mOffset * mRate + 0.5);
 }
 
 sampleCount WaveClip::GetEndSample() const
@@ -390,19 +390,19 @@ sampleCount WaveClip::GetNumSamples() const
 
 bool WaveClip::WithinClip(double t) const
 {
-   sampleCount ts = (sampleCount)floor(t * mRate + 0.5);
+   auto ts = (sampleCount)floor(t * mRate + 0.5);
    return ts > GetStartSample() && ts < GetEndSample() + mAppendBufferLen;
 }
 
 bool WaveClip::BeforeClip(double t) const
 {
-   sampleCount ts = (sampleCount)floor(t * mRate + 0.5);
+   auto ts = (sampleCount)floor(t * mRate + 0.5);
    return ts <= GetStartSample();
 }
 
 bool WaveClip::AfterClip(double t) const
 {
-   sampleCount ts = (sampleCount)floor(t * mRate + 0.5);
+   auto ts = (sampleCount)floor(t * mRate + 0.5);
    return ts >= GetEndSample() + mAppendBufferLen;
 }
 
@@ -472,11 +472,9 @@ fillWhere(std::vector<sampleCount> &where, int len, double bias, double correcti
 {
    // Be careful to make the first value non-negative
    const double w0 = 0.5 + correction + bias + t0 * rate;
-   where[0] = sampleCount(std::max(0.0, floor(w0)));
-   for (sampleCount x = 1; x < len + 1; x++)
-      where[x] = sampleCount(
-         floor(w0 + double(x) * samplesPerPixel)
-      );
+   where[0] = std::max(0.0, floor(w0));
+   for (decltype(len) x = 1; x < len + 1; x++)
+      where[x] = floor(w0 + double(x) * samplesPerPixel);
 }
 
 }
@@ -608,7 +606,7 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
 
       /* handle values in the append buffer */
 
-      int numSamples = mSequence->GetNumSamples();
+      auto numSamples = mSequence->GetNumSamples();
       int a;
 
       // Not all of the required columns might be in the sequence.
@@ -626,10 +624,8 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
          sampleFormat seqFormat = mSequence->GetSampleFormat();
          bool didUpdate = false;
          for(i=a; i<p1; i++) {
-            sampleCount left;
-            left = where[i] - numSamples;
-            sampleCount right;
-            right = where[i + 1] - numSamples;
+            auto left = where[i] - numSamples;
+            auto right = where[i + 1] - numSamples;
 
             //wxCriticalSectionLocker locker(mAppendCriticalSection);
 
@@ -641,7 +637,6 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
             if (right > left) {
                float *b;
                sampleCount len = right-left;
-               sampleCount j;
 
                if (seqFormat == floatSample)
                   b = &((float *)mAppendBuffer.ptr())[left];
@@ -658,7 +653,7 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
                   theMax = theMin = val;
                   sumsq = val * val;
                }
-               for(j=1; j<len; j++) {
+               for(decltype(len) j = 1; j < len; j++) {
                   const float val = b[j];
                   theMax = std::max(theMax, val);
                   theMin = std::min(theMin, val);
@@ -730,11 +725,11 @@ void ComputeSpectrogramGainFactors
       // This is the reciprocal of the bin number of 1000 Hz:
       const double factor = ((double)rate / (double)fftLen) / 1000.0;
 
-      const int half = fftLen / 2;
+      int half = fftLen / 2;
       gainFactors.reserve(half);
       // Don't take logarithm of zero!  Let bin 0 replicate the gain factor for bin 1.
       gainFactors.push_back(frequencyGain*log10(factor));
-      for (sampleCount x = 1; x < half; x++) {
+      for (decltype(half) x = 1; x < half; x++) {
          gainFactors.push_back(frequencyGain*log10(factor * x));
       }
    }
@@ -806,12 +801,13 @@ bool SpecCache::CalculateOneSpectrum
       float *adj = scratch + padding;
 
       {
-         sampleCount myLen = windowSize;
+         auto myLen = windowSize;
          // Take a window of the track centered at this sample.
          start -= windowSize >> 1;
          if (start < 0) {
             // Near the start of the clip, pad left with zeroes as needed.
-            for (sampleCount ii = start; ii < 0; ++ii)
+            // Start is at least -windowSize / 2
+            for (auto ii = start; ii < 0; ++ii)
                *adj++ = 0;
             myLen += start;
             start = 0;
@@ -821,7 +817,7 @@ bool SpecCache::CalculateOneSpectrum
          if (start + myLen > numSamples) {
             // Near the end of the clip, pad right with zeroes as needed.
             int newlen = numSamples - start;
-            for (sampleCount ii = newlen; ii < (sampleCount)myLen; ++ii)
+            for (decltype(myLen) ii = newlen; ii < myLen; ++ii)
                adj[ii] = 0;
             myLen = newlen;
             copy = true;
@@ -983,7 +979,7 @@ void SpecCache::Populate
    for (int jj = 0; jj < 2; ++jj) {
       const int lowerBoundX = jj == 0 ? 0 : copyEnd;
       const int upperBoundX = jj == 0 ? copyBegin : numPixels;
-      for (sampleCount xx = lowerBoundX; xx < upperBoundX; ++xx)
+      for (auto xx = lowerBoundX; xx < upperBoundX; ++xx)
          CalculateOneSpectrum(
             settings, waveTrackCache, xx, numSamples,
             offset, rate, pixelsPerSecond,
@@ -994,7 +990,7 @@ void SpecCache::Populate
          // Need to look beyond the edges of the range to accumulate more
          // time reassignments.
          // I'm not sure what's a good stopping criterion?
-         sampleCount xx = lowerBoundX;
+         auto xx = lowerBoundX;
          const double pixelsPerSample = pixelsPerSecond / rate;
          const int limit = std::min(int(0.5 + fftLen * pixelsPerSample), 100);
          for (int ii = 0; ii < limit; ++ii)
@@ -1024,7 +1020,7 @@ void SpecCache::Populate
 
          // Now Convert to dB terms.  Do this only after accumulating
          // power values, which may cross columns with the time correction.
-         for (sampleCount xx = lowerBoundX; xx < upperBoundX; ++xx) {
+         for (auto xx = lowerBoundX; xx < upperBoundX; ++xx) {
             float *const results = &freq[half * xx];
             const HFFT hFFT = settings.hFFT;
             for (int ii = 0; ii < hFFT->Points; ++ii) {
@@ -1200,7 +1196,7 @@ void WaveClip::TimeToSamplesClip(double t0, sampleCount *s0) const
    else if (t0 > mOffset + double(mSequence->GetNumSamples())/mRate)
       *s0 = mSequence->GetNumSamples();
    else
-      *s0 = (sampleCount)floor(((t0 - mOffset) * mRate) + 0.5);
+      *s0 = floor(((t0 - mOffset) * mRate) + 0.5);
 }
 
 void WaveClip::ClearDisplayRect() const
@@ -1225,8 +1221,8 @@ bool WaveClip::Append(samplePtr buffer, sampleFormat format,
 {
    //wxLogDebug(wxT("Append: len=%lli"), (long long) len);
 
-   sampleCount maxBlockSize = mSequence->GetMaxBlockSize();
-   sampleCount blockSize = mSequence->GetIdealAppendLen();
+   auto maxBlockSize = mSequence->GetMaxBlockSize();
+   auto blockSize = mSequence->GetIdealAppendLen();
    sampleFormat seqFormat = mSequence->GetSampleFormat();
 
    if (!mAppendBuffer.ptr())
@@ -1461,7 +1457,7 @@ bool WaveClip::InsertSilence(double t, double len)
 {
    sampleCount s0;
    TimeToSamplesClip(t, &s0);
-   sampleCount slen = (sampleCount)floor(len * mRate + 0.5);
+   auto slen = (sampleCount)floor(len * mRate + 0.5);
 
    if (!GetSequence()->InsertSilence(s0, slen))
    {
@@ -1705,7 +1701,7 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
    sampleCount pos = 0;
    bool error = false;
    int outGenerated = 0;
-   sampleCount numSamples = mSequence->GetNumSamples();
+   auto numSamples = mSequence->GetNumSamples();
 
    auto newSequence =
       std::make_unique<Sequence>(mSequence->GetDirManager(), mSequence->GetSampleFormat());
diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp
index 11ba531b9dce2853430183b09db275f23ad31adf..43831c8fb62c8413bc1e989a33ebfdf271ac19b2 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,8 +1428,8 @@ bool WaveTrack::InsertSilence(double t, double len)
 //Analyses selected region for possible Joined clips and disjoins them
 bool WaveTrack::Disjoin(double t0, double t1)
 {
-   sampleCount minSamples = TimeToLongSamples( WAVETRACK_MERGE_POINT_TOLERANCE );
-   sampleCount maxAtOnce = 1048576;
+   auto minSamples = TimeToLongSamples( WAVETRACK_MERGE_POINT_TOLERANCE );
+   size_t maxAtOnce = 1048576;
    float *buffer = new float[ maxAtOnce ];
    Regions regions;
 
@@ -1456,16 +1456,16 @@ 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 )
       {
-         const auto numSamples = limitSampleBufferSize( maxAtOnce, len - done );
+         auto numSamples = limitSampleBufferSize( maxAtOnce, len - done );
 
          clip->GetSamples( ( samplePtr )buffer, floatSample, start + done,
                numSamples );
-         for( auto i = 0; i < numSamples; i++ )
+         for( decltype(numSamples) i = 0; i < numSamples; i++ )
          {
-            sampleCount curSamplePos = start + done + i;
+            auto curSamplePos = start + done + i;
 
             //start a NEW sequence
             if( buffer[ i ] == 0.0 && seqStart == -1 )
@@ -1474,7 +1474,7 @@ bool WaveTrack::Disjoin(double t0, double t1)
             {
                if( seqStart != -1 )
                {
-                  sampleCount seqEnd;
+                  decltype(end) seqEnd;
 
                   //consider the end case, where selection ends in zeroes
                   if( curSamplePos == end - 1 && buffer[ i ] == 0.0 )
@@ -1597,8 +1597,8 @@ sampleCount WaveTrack::GetBlockStart(sampleCount s) const
 {
    for (const auto &clip : mClips)
    {
-      const sampleCount startSample = (sampleCount)floor(0.5 + clip->GetStartTime()*mRate);
-      const sampleCount endSample = startSample + clip->GetNumSamples();
+      const auto startSample = (sampleCount)floor(0.5 + clip->GetStartTime()*mRate);
+      const auto endSample = startSample + clip->GetNumSamples();
       if (s >= startSample && s < endSample)
          return startSample + clip->GetSequence()->GetBlockStart(s - startSample);
    }
@@ -1608,12 +1608,12 @@ sampleCount WaveTrack::GetBlockStart(sampleCount s) const
 
 sampleCount WaveTrack::GetBestBlockSize(sampleCount s) const
 {
-   sampleCount bestBlockSize = GetMaxBlockSize();
+   auto bestBlockSize = GetMaxBlockSize();
 
    for (const auto &clip : mClips)
    {
-      sampleCount startSample = (sampleCount)floor(clip->GetStartTime()*mRate + 0.5);
-      sampleCount endSample = startSample + clip->GetNumSamples();
+      auto startSample = (sampleCount)floor(clip->GetStartTime()*mRate + 0.5);
+      auto endSample = startSample + clip->GetNumSamples();
       if (s >= startSample && s < endSample)
       {
          bestBlockSize = clip->GetSequence()->GetBestBlockSize(s - startSample);
@@ -1851,7 +1851,7 @@ bool WaveTrack::Unlock() const
 
 AUDACITY_DLL_API sampleCount WaveTrack::TimeToLongSamples(double t0) const
 {
-   return (sampleCount)floor(t0 * mRate + 0.5);
+   return floor(t0 * mRate + 0.5);
 }
 
 double WaveTrack::LongSamplesToTime(sampleCount pos) const
@@ -2025,17 +2025,17 @@ bool WaveTrack::Get(samplePtr buffer, sampleFormat format,
 
    for (const auto &clip: mClips)
    {
-      sampleCount clipStart = clip->GetStartSample();
-      sampleCount clipEnd = clip->GetEndSample();
+      auto clipStart = clip->GetStartSample();
+      auto clipEnd = clip->GetEndSample();
 
       if (clipEnd > start && clipStart < start+len)
       {
          // Clip sample region and Get/Put sample region overlap
-         sampleCount samplesToCopy = start+len - clipStart;
+         auto samplesToCopy = start+len - clipStart;
          if (samplesToCopy > clip->GetNumSamples())
             samplesToCopy = clip->GetNumSamples();
-         sampleCount inclipDelta = 0;
-         sampleCount startDelta = clipStart - start;
+         auto startDelta = clipStart - start;
+         decltype(startDelta) inclipDelta = 0;
          if (startDelta < 0)
          {
             inclipDelta = -startDelta; // make positive value
@@ -2062,17 +2062,17 @@ bool WaveTrack::Set(samplePtr buffer, sampleFormat format,
 
    for (const auto &clip: mClips)
    {
-      sampleCount clipStart = clip->GetStartSample();
-      sampleCount clipEnd = clip->GetEndSample();
+      auto clipStart = clip->GetStartSample();
+      auto clipEnd = clip->GetEndSample();
 
       if (clipEnd > start && clipStart < start+len)
       {
          // Clip sample region and Get/Put sample region overlap
-         sampleCount samplesToCopy = start+len - clipStart;
+         auto samplesToCopy = start+len - clipStart;
          if (samplesToCopy > clip->GetNumSamples())
             samplesToCopy = clip->GetNumSamples();
-         sampleCount inclipDelta = 0;
-         sampleCount startDelta = clipStart - start;
+         auto startDelta = clipStart - start;
+         decltype(startDelta) inclipDelta = 0;
          if (startDelta < 0)
          {
             inclipDelta = -startDelta; // make positive value
@@ -2106,7 +2106,7 @@ void WaveTrack::GetEnvelopeValues(double *buffer, size_t bufferLen,
    // be set twice.  Unfortunately, there is no easy way around this since the clips are not
    // stored in increasing time order.  If they were, we could just track the time as the
    // buffer is filled.
-   for (int i = 0; i < bufferLen; i++)
+   for (decltype(bufferLen) i = 0; i < bufferLen; i++)
    {
       buffer[i] = 1.0;
    }
@@ -2127,7 +2127,7 @@ void WaveTrack::GetEnvelopeValues(double *buffer, size_t bufferLen,
 
          if (rt0 < dClipStartTime)
          {
-            sampleCount nDiff = (sampleCount)floor((dClipStartTime - rt0) * mRate + 0.5);
+            auto nDiff = (sampleCount)floor((dClipStartTime - rt0) * mRate + 0.5);
             rbuf += nDiff;
             wxASSERT(nDiff <= rlen);
             rlen -= nDiff;
@@ -2171,10 +2171,8 @@ WaveClip* WaveTrack::GetClipAtSample(sampleCount sample)
 {
    for (const auto &clip: mClips)
    {
-      sampleCount start, len;
-
-      start = clip->GetStartSample();
-      len   = clip->GetNumSamples();
+      auto start = clip->GetStartSample();
+      auto len   = clip->GetNumSamples();
 
       if (sample >= start && sample < start + len)
          return clip.get();
@@ -2623,7 +2621,7 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
    sampleCount start, sampleCount len)
 {
    if (format == floatSample && len > 0) {
-      const sampleCount end = start + len;
+      const auto end = start + len;
 
       bool fillFirst = (mNValidBuffers < 1);
       bool fillSecond = (mNValidBuffers < 2);
@@ -2669,9 +2667,9 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
 
       // Refill buffers as needed
       if (fillFirst) {
-         const sampleCount start0 = mPTrack->GetBlockStart(start);
+         const auto start0 = mPTrack->GetBlockStart(start);
          if (start0 >= 0) {
-            const sampleCount len0 = mPTrack->GetBestBlockSize(start0);
+            const auto len0 = mPTrack->GetBestBlockSize(start0);
             wxASSERT(len0 <= mBufferSize);
             if (!mPTrack->Get(samplePtr(mBuffers[0].data), floatSample, start0, len0))
                return 0;
@@ -2693,11 +2691,11 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
       wxASSERT(!fillSecond || mNValidBuffers > 0);
       if (fillSecond) {
          mNValidBuffers = 1;
-         const sampleCount end0 = mBuffers[0].end();
+         const auto end0 = mBuffers[0].end();
          if (end > end0) {
-            const sampleCount start1 = mPTrack->GetBlockStart(end0);
+            const auto start1 = mPTrack->GetBlockStart(end0);
             if (start1 == end0) {
-               const sampleCount len1 = mPTrack->GetBestBlockSize(start1);
+               const auto len1 = mPTrack->GetBestBlockSize(start1);
                wxASSERT(len1 <= mBufferSize);
                if (!mPTrack->Get(samplePtr(mBuffers[1].data), floatSample, start1, len1))
                   return 0;
@@ -2710,7 +2708,7 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
       wxASSERT(mNValidBuffers < 2 || mBuffers[0].end() == mBuffers[1].start);
 
       samplePtr buffer = 0;
-      sampleCount remaining = len;
+      auto remaining = len;
 
       // Possibly get an initial portion that is uncached
 
@@ -2731,8 +2729,9 @@ constSamplePtr WaveTrackCache::Get(sampleFormat format,
 
       // Now satisfy the request from the buffers
       for (int ii = 0; ii < mNValidBuffers && remaining > 0; ++ii) {
-         const sampleCount starti = start - mBuffers[ii].start;
-         const sampleCount leni = std::min(remaining, mBuffers[ii].len - starti);
+         const auto starti = start - mBuffers[ii].start;
+         const auto leni =
+            std::min( sampleCount( remaining ), mBuffers[ii].len - starti );
          if (initLen == 0 && leni == len) {
             // All is contiguous already.  We can completely avoid copying
             return samplePtr(mBuffers[ii].data + starti);
diff --git a/src/blockfile/LegacyBlockFile.cpp b/src/blockfile/LegacyBlockFile.cpp
index 873694d61b45823bc0c230877dcb5fcffa3bfa7e..0924db58fcb9cb6eacc76a57389e8f735b9ca74d 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/commands/CompareAudioCommand.cpp b/src/commands/CompareAudioCommand.cpp
index b982360c7060289904790d749d0ae13ffd446883..874e48faa9b4bff8b19a408304d2210dd2afb994 100644
--- a/src/commands/CompareAudioCommand.cpp
+++ b/src/commands/CompareAudioCommand.cpp
@@ -98,25 +98,25 @@ 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
-      const auto block = limitSampleBufferSize(
+      auto block = limitSampleBufferSize(
          mTrack0->GetBestBlockSize(position), s1 - position
       );
       mTrack0->Get((samplePtr)buff0, floatSample, position, block);
       mTrack1->Get((samplePtr)buff1, floatSample, position, block);
 
-      for (auto buffPos = 0; buffPos < block; ++buffPos)
+      for (decltype(block) buffPos = 0; buffPos < block; ++buffPos)
       {
          if (CompareSample(buff0[buffPos], buff1[buffPos]) > errorThreshold)
          {
diff --git a/src/effects/Amplify.cpp b/src/effects/Amplify.cpp
index dc2e73d73f3ec2ae83d0d2276ea58d8a9a40f9a2..d6d9d15cbd9cfca5a0e19110b97fd11603d8617e 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 fb1396a33dc17b5a7331742fa1720175035dc687..40f90e95adedf9b7936e1a0a98931b42e069227a 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);
@@ -288,7 +286,7 @@ bool EffectAutoDuck::Process()
    int rmsPos = 0;
    float rmsSum = 0;
    float *rmsWindow = new float[kRMSWindowSize];
-   for (i = 0; i < kRMSWindowSize; i++)
+   for (size_t i = 0; i < kRMSWindowSize; i++)
       rmsWindow[i] = 0;
 
    float *buf = new float[kBufSize];
@@ -302,15 +300,15 @@ bool EffectAutoDuck::Process()
    // to make the progress bar appear more natural, we first look for all
    // duck regions and apply them all at once afterwards
    AutoDuckRegionArray regions;
-   sampleCount pos = start;
+   auto pos = start;
 
    while (pos < end)
    {
       const auto len = limitSampleBufferSize( kBufSize, end - pos );
 
-      mControlTrack->Get((samplePtr)buf, floatSample, pos, (sampleCount)len);
+      mControlTrack->Get((samplePtr)buf, floatSample, pos, len);
 
-      for (i = pos; i < pos + len; i++)
+      for (auto i = pos; i < pos + len; i++)
       {
          rmsSum -= rmsWindow[rmsPos];
          rmsWindow[rmsPos] = buf[i - pos] * buf[i - pos];
@@ -393,7 +391,7 @@ bool EffectAutoDuck::Process()
 
          WaveTrack* t = (WaveTrack*)iterTrack;
 
-         for (i = 0; i < (int)regions.GetCount(); i++)
+         for (size_t i = 0; i < regions.GetCount(); i++)
          {
             const AutoDuckRegion& region = regions[i];
             if (ApplyDuckFade(trackNumber, t, region.t0, region.t1))
@@ -513,18 +511,18 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNumber, WaveTrack* t,
 {
    bool cancel = false;
 
-   sampleCount start = t->TimeToLongSamples(t0);
-   sampleCount end = t->TimeToLongSamples(t1);
+   auto start = t->TimeToLongSamples(t0);
+   auto end = t->TimeToLongSamples(t1);
 
    float *buf = new float[kBufSize];
-   sampleCount pos = start;
+   auto pos = start;
 
-   int fadeDownSamples = t->TimeToLongSamples(
+   auto fadeDownSamples = t->TimeToLongSamples(
       mOuterFadeDownLen + mInnerFadeDownLen);
    if (fadeDownSamples < 1)
       fadeDownSamples = 1;
 
-   int fadeUpSamples = t->TimeToLongSamples(
+   auto fadeUpSamples = t->TimeToLongSamples(
       mOuterFadeUpLen + mInnerFadeUpLen);
    if (fadeUpSamples < 1)
       fadeUpSamples = 1;
@@ -538,7 +536,7 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNumber, WaveTrack* t,
 
       t->Get((samplePtr)buf, floatSample, pos, len);
 
-      for (sampleCount i = pos; i < pos + len; i++)
+      for (auto i = pos; i < pos + len; i++)
       {
          float gainDown = fadeDownStep * (i - start);
          float gainUp = fadeUpStep * (end - i);;
diff --git a/src/effects/BassTreble.cpp b/src/effects/BassTreble.cpp
index 24bdf9ff275d2242261313f275fbe8f3c74c0d04..73796b75ce1efbaaf871e1991ec8bfabe774de22 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/ChangePitch.cpp b/src/effects/ChangePitch.cpp
index 39519578d6ab29d9193908a20f53a67076883b5c..6958828d59ad635bcdadc4f15c5d70730ebdde5e 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 422766dabe72d4b7f93af032533262fa428029f7..619d5e22b7fa544cda87607c202274ee1b48f9c8 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 c300c6336fa5ffc0397106edad099cd36a952921..d820bd871a9457b7f56d11e32c2653a18ba57deb 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 350d1a64d484b66a56e30cef5e7178f364c20f4e..eb518adb59d07632450886a1f8bce9af6e2028ad 100644
--- a/src/effects/Compressor.cpp
+++ b/src/effects/Compressor.cpp
@@ -366,11 +366,11 @@ bool EffectCompressor::InitPass1()
       DisableSecondPass();
 
    // Find the maximum block length required for any track
-   sampleCount maxlen=0;
+   size_t maxlen = 0;
    SelectedTrackListOfKindIterator iter(Track::Wave, mTracks);
    WaveTrack *track = (WaveTrack *) iter.First();
    while (track) {
-      sampleCount len=track->GetMaxBlockSize();
+      auto len = track->GetMaxBlockSize();
       if(len > maxlen)
          maxlen = len;
       //Iterate to the next track
diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp
index cb89e0bf392b3b6090ffd050134c89dd8277e4fc..e0079fd60b28f712ee65243e82cdad785ff0a24d 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/Distortion.cpp b/src/effects/Distortion.cpp
index 34b977ca6523a63bf73618767f8359776abda65d..dfdd6c42e6916794b5b0340c9efa07fbeb2d8b22 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/DtmfGen.cpp b/src/effects/DtmfGen.cpp
index 398e89ae29956a432082ba208b85b1b68d5adb69..b1ee606eb0a369c93daa00d8ffa66a1f70308dfc 100644
--- a/src/effects/DtmfGen.cpp
+++ b/src/effects/DtmfGen.cpp
@@ -117,13 +117,13 @@ bool EffectDtmf::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames
    // extra samples may get created as mDuration may now be > mT1 - mT0;
    // However we are making our best efforts at creating what was asked for.
 
-   sampleCount nT0 = (sampleCount)floor(mT0 * mSampleRate + 0.5);
-   sampleCount nT1 = (sampleCount)floor((mT0 + duration) * mSampleRate + 0.5);
+   auto nT0 = (sampleCount)floor(mT0 * mSampleRate + 0.5);
+   auto nT1 = (sampleCount)floor((mT0 + duration) * mSampleRate + 0.5);
    numSamplesSequence = nT1 - nT0;  // needs to be exact number of samples selected
 
    //make under-estimates if anything, and then redistribute the few remaining samples
-   numSamplesTone = (sampleCount)floor(dtmfTone * mSampleRate);
-   numSamplesSilence = (sampleCount)floor(dtmfSilence * mSampleRate);
+   numSamplesTone = floor(dtmfTone * mSampleRate);
+   numSamplesSilence = floor(dtmfSilence * mSampleRate);
 
    // recalculate the sum, and spread the difference - due to approximations.
    // Since diff should be in the order of "some" samples, a division (resulting in zero)
@@ -153,7 +153,7 @@ bool EffectDtmf::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames
 sampleCount EffectDtmf::ProcessBlock(float **WXUNUSED(inbuf), float **outbuf, sampleCount size)
 {
    float *buffer = outbuf[0];
-   sampleCount processed = 0;
+   decltype(size) processed = 0;
 
    // for the whole dtmf sequence, we will be generating either tone or silence
    // according to a bool value, and this might be done in small chunks of size
@@ -527,14 +527,14 @@ bool EffectDtmf::MakeDtmfTone(float *buffer, sampleCount len, float fs, wxChar t
 
    // now generate the wave: 'last' is used to avoid phase errors
    // when inside the inner for loop of the Process() function.
-   for(sampleCount i=0; i<len; i++) {
+   for(decltype(len) i = 0; i < len; i++) {
       buffer[i]=amplitude*0.5*(sin(A*(i+last))+sin(B*(i+last)));
    }
 
    // generate a fade-in of duration 1/250th of second
    if (last == 0) {
       A = (fs / kFadeInOut);
-      for(sampleCount i = 0; i < A; i++) {
+      for(size_t i = 0; i < A; i++) {
          buffer[i] *= i/A;
       }
    }
@@ -544,11 +544,11 @@ bool EffectDtmf::MakeDtmfTone(float *buffer, sampleCount len, float fs, wxChar t
       // we are at the last buffer of 'len' size, so, offset is to
       // backup 'A' samples, from 'len'
       A = (fs / kFadeInOut);
-      sampleCount offset = len - (sampleCount)(fs / kFadeInOut);
+      auto offset = len - decltype(len)(fs / kFadeInOut);
       // protect against negative offset, which can occur if too a
       // small selection is made
       if (offset >= 0) {
-         for(sampleCount i = 0; i < A; i++) {
+         for(size_t i = 0; i < A; i++) {
             buffer[i + offset] *= (1 - (i / A));
          }
       }
diff --git a/src/effects/Echo.cpp b/src/effects/Echo.cpp
index 8a5fd7248c422c96253b027bf1ff948af266e153..e89c0b042a078591295ddcbff42e6d808c5a7848 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 ffe178a9f4c73f061d7db51912cb0fd6af19aa89..0a4fa97dc958f1331a16e76ea882d71e94be9788 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;
-
-   sampleCount inputRemaining = len;
-   sampleCount delayRemaining = 0;
-   sampleCount curBlockSize = 0;
-   sampleCount curDelay = 0;
-
-   size_t inputBufferCnt = 0;
-   sampleCount outputBufferCnt = 0;
+   auto inLeftPos = leftStart;
+   auto inRightPos = rightStart;
+   auto outLeftPos = leftStart;
+   auto outRightPos = rightStart;
+
+   auto inputRemaining = len;
+   decltype(GetLatency()) curDelay = 0, delayRemaining = 0;
+   decltype(mBlockSize) curBlockSize = 0;
+
+   decltype(mBufferSize) inputBufferCnt = 0;
+   decltype(mBufferSize) outputBufferCnt = 0;
    bool cleared = false;
 
    int chans = wxMin(mNumAudioOut, mNumChannels);
 
    std::unique_ptr<WaveTrack> genLeft, genRight;
-   sampleCount genLength = 0;
+   decltype(len) genLength = 0;
    bool isGenerator = GetType() == EffectTypeGenerate;
    bool isProcessor = GetType() == EffectTypeProcess;
    double genDur = 0;
@@ -1616,10 +1614,10 @@ bool Effect::ProcessTrack(int count,
 
             // Clear the remainder of the buffers so that a full block can be passed
             // to the effect
-            sampleCount cnt = mBlockSize - curBlockSize;
+            auto cnt = mBlockSize - curBlockSize;
             for (int i = 0; i < mNumChannels; i++)
             {
-               for (int j = 0 ; j < cnt; j++)
+               for (decltype(cnt) j = 0 ; j < cnt; j++)
                {
                   mInBufPos[i][j + curBlockSize] = 0.0;
                }
@@ -1668,7 +1666,7 @@ bool Effect::ProcessTrack(int count,
       }
 
       // Finally call the plugin to process the block
-      sampleCount processed;
+      decltype(curBlockSize) processed;
       try
       {
          processed = ProcessBlock(mInBufPos, mOutBufPos, curBlockSize);
@@ -1701,7 +1699,7 @@ bool Effect::ProcessTrack(int count,
       // Get the current number of delayed samples and accumulate
       if (isProcessor)
       {
-         sampleCount delay = GetLatency();
+         auto delay = GetLatency();
          curDelay += delay;
          delayRemaining += delay;
 
@@ -2020,8 +2018,8 @@ void Effect::GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len)
 
    if (t1 > t0) {
       *start = track->TimeToLongSamples(t0);
-      sampleCount end = track->TimeToLongSamples(t1);
-      *len = (sampleCount)(end - *start);
+      auto end = track->TimeToLongSamples(t1);
+      *len = end - *start;
    }
    else {
       *start = 0;
@@ -2374,7 +2372,7 @@ sampleCount Effect::RealtimeProcess(int group,
    float **clientIn = (float **) alloca(mNumAudioIn * sizeof(float *));
    float **clientOut = (float **) alloca(mNumAudioOut * sizeof(float *));
    float *dummybuf = (float *) alloca(numSamples * sizeof(float));
-   sampleCount len = 0;
+   decltype(numSamples) len = 0;
    int ichans = chans;
    int ochans = chans;
    int gchans = chans;
@@ -2448,9 +2446,9 @@ sampleCount Effect::RealtimeProcess(int group,
 
       // Finally call the plugin to process the block
       len = 0;
-      for (sampleCount block = 0; block < numSamples; block += mBlockSize)
+      for (decltype(numSamples) block = 0; block < numSamples; block += mBlockSize)
       {
-         sampleCount cnt = (block + mBlockSize > numSamples ? numSamples - block : mBlockSize);
+         auto cnt = (block + mBlockSize > numSamples ? numSamples - block : mBlockSize);
          len += RealtimeProcess(processor, clientIn, clientOut, cnt);
 
          for (int i = 0 ; i < mNumAudioIn; i++)
diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp
index 3276eeb110eef28b23533250fbbd4a4aa7253bff..737ba1aa8ca2a895d75a1d518a4e12b2b850fcfa 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))
          {
@@ -1064,8 +1064,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));
 
@@ -1076,7 +1076,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
    float *thisWindow = window1;
    float *lastWindow = window2;
 
-   sampleCount originalLen = len;
+   auto originalLen = len;
 
    int i,j;
    for(i=0; i<windowSize; i++)
@@ -1089,7 +1089,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
 
    while (len != 0)
    {
-      sampleCount block = idealBlockLen;
+      auto block = idealBlockLen;
       if (block > len)
          block = len;
 
@@ -1150,7 +1150,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 8be27a31416a3dc06ac6e9aa8edbd370c962036a..bca3f395a8f6a28cd23d2c8b5e09894b4e256b3a 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,21 +406,21 @@ bool EffectEqualization48x::TrackCompare()
 bool EffectEqualization48x::DeltaTrack(WaveTrack * t, WaveTrack * t2, sampleCount start, sampleCount len)
 {
 
-   sampleCount trackBlockSize = t->GetMaxBlockSize();
+   auto trackBlockSize = t->GetMaxBlockSize();
 
    float *buffer1 = new float[trackBlockSize];
    float *buffer2 = new float[trackBlockSize];
 
    AudacityProject *p = GetActiveProject();
    auto output=p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
-   sampleCount originalLen = len;
-   sampleCount currentSample = start;
+   auto originalLen = len;
+   auto currentSample = start;
 
    while(len) {
-      sampleCount curretLength=(trackBlockSize>len)?len:trackBlockSize;
+      auto curretLength = (trackBlockSize > len) ? len : trackBlockSize;
       t->Get((samplePtr)buffer1, floatSample, currentSample, curretLength);
       t2->Get((samplePtr)buffer2, floatSample, currentSample, curretLength);
-      for(int i=0;i<curretLength;i++)
+      for(decltype(curretLength) i=0;i<curretLength;i++)
          buffer1[i]-=buffer2[i];
       output->Append((samplePtr)buffer1, floatSample, curretLength);
       currentSample+=curretLength;
@@ -479,9 +479,9 @@ bool EffectEqualization48x::Benchmark(EffectEqualization* effectEqualization)
             double t1 = mEffectEqualization->mT1 > trackEnd? trackEnd: mEffectEqualization->mT1;
 
             if (t1 > t0) {
-               sampleCount start = track->TimeToLongSamples(t0);
-               sampleCount end = track->TimeToLongSamples(t1);
-               sampleCount len = (sampleCount)(end - start);
+               auto start = track->TimeToLongSamples(t0);
+               auto end = track->TimeToLongSamples(t1);
+               auto len = end - start;
                bBreakLoop=RunFunctionSelect( localMathPath, count, track, start, len);
                if( bBreakLoop )
                   break;
@@ -510,7 +510,7 @@ bool EffectEqualization48x::Benchmark(EffectEqualization* effectEqualization)
 
 bool EffectEqualization48x::ProcessTail(WaveTrack * t, WaveTrack * output, sampleCount start, sampleCount len)
 {
-   //	  double offsetT0 = t->LongSamplesToTime((sampleCount)offset);
+   //	  double offsetT0 = t->LongSamplesToTime(offset);
    double lenT = t->LongSamplesToTime(len);
    // 'start' is the sample offset in 't', the passed in track
    // 'startT' is the equivalent time value
@@ -632,7 +632,7 @@ bool EffectEqualization48x::ProcessOne1x(int count, WaveTrack * t,
 {
    //sampleCount blockCount=len/mBlockSize;
 
-   sampleCount trackBlockSize = t->GetMaxBlockSize();
+   auto trackBlockSize = t->GetMaxBlockSize();
 
    AudacityProject *p = GetActiveProject();
    auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
@@ -647,7 +647,7 @@ bool EffectEqualization48x::ProcessOne1x(int count, WaveTrack * t,
       singleProcessLength=len;
    else 
       singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(subBufferSize-mBlockSize));
-   sampleCount currentSample=start;
+   auto currentSample=start;
    bool bBreakLoop = false;
    for(int bigRun=0;bigRun<bigRuns;bigRun++)
    {
@@ -817,7 +817,7 @@ bool EffectEqualization48x::ProcessOne4x(int count, WaveTrack * t,
    if(len<subBufferSize) // it's not worth 4x processing do a regular process
       return ProcessOne1x(count, t, start, len);
 
-   sampleCount trackBlockSize = t->GetMaxBlockSize();
+   auto trackBlockSize = t->GetMaxBlockSize();
 
    AudacityProject *p = GetActiveProject();
    auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
@@ -827,7 +827,7 @@ bool EffectEqualization48x::ProcessOne4x(int count, WaveTrack * t,
    int trackBlocksPerBig=subBufferSize/trackBlockSize;
    int trackLeftovers=subBufferSize-trackBlocksPerBig*trackBlockSize;
    int singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(subBufferSize-mBlockSize));
-   sampleCount currentSample=start;
+   auto currentSample=start;
 
    bool bBreakLoop = false;
    for(int bigRun=0;bigRun<bigRuns;bigRun++)
@@ -906,13 +906,13 @@ bool EffectEqualization48x::ProcessOne1x4xThreaded(int count, WaveTrack * t,
    AudacityProject *p = GetActiveProject();
    auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
 
-   sampleCount trackBlockSize = t->GetMaxBlockSize();
+   auto trackBlockSize = t->GetMaxBlockSize();
    mEffectEqualization->TrackProgress(count, 0.0);
    int bigRuns=len/(subBufferSize-mBlockSize);
    int trackBlocksPerBig=subBufferSize/trackBlockSize;
    int trackLeftovers=subBufferSize-trackBlocksPerBig*trackBlockSize;
    int singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(subBufferSize-mBlockSize));
-   sampleCount currentSample=start;
+   auto currentSample=start;
 
    int bigBlocksRead=mWorkerDataCount, bigBlocksWritten=0;
 
@@ -1146,7 +1146,7 @@ bool EffectEqualization48x::ProcessOne8x(int count, WaveTrack * t,
    if(blockCount<32) // it's not worth 8x processing do a regular process
       return ProcessOne4x(count, t, start, len);
 
-   sampleCount trackBlockSize = t->GetMaxBlockSize();
+   auto trackBlockSize = t->GetMaxBlockSize();
 
    AudacityProject *p = GetActiveProject();
    auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
@@ -1156,7 +1156,7 @@ bool EffectEqualization48x::ProcessOne8x(int count, WaveTrack * t,
    int trackBlocksPerBig=mSubBufferSize/trackBlockSize;
    int trackLeftovers=mSubBufferSize-trackBlocksPerBig*trackBlockSize;
    int singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(mSubBufferSize-mBlockSize));
-   sampleCount currentSample=start;
+   auto currentSample=start;
 
    bool bBreakLoop = false;
    for(int bigRun=0;bigRun<bigRuns;bigRun++)
@@ -1203,13 +1203,13 @@ bool EffectEqualization48x::ProcessOne8xThreaded(int count, WaveTrack * t,
    AudacityProject *p = GetActiveProject();
    auto output = p->GetTrackFactory()->NewWaveTrack(floatSample, t->GetRate());
 
-   sampleCount trackBlockSize = t->GetMaxBlockSize();
+   auto trackBlockSize = t->GetMaxBlockSize();
    mEffectEqualization->TrackProgress(count, 0.0);
    int bigRuns=len/(mSubBufferSize-mBlockSize);
    int trackBlocksPerBig=mSubBufferSize/trackBlockSize;
    int trackLeftovers=mSubBufferSize-trackBlocksPerBig*trackBlockSize;
    int singleProcessLength=(mFilterSize>>1)*bigRuns + len%(bigRuns*(mSubBufferSize-mBlockSize));
-   sampleCount currentSample=start;
+   auto currentSample=start;
 
    int bigBlocksRead=mWorkerDataCount, bigBlocksWritten=0;
 
diff --git a/src/effects/Fade.cpp b/src/effects/Fade.cpp
index 7a9733b2b4e7435ec06345dd5a7eaa08484488d3..bcfb7ea72b73e2782c51ece7cb5c00c0b2ccea5e 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 bc067e7ab5f921210c9c67d485b095bac3fd0089..546724c704f01137b108eee4c5ab4400c4e6b475 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,10 +163,8 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt,
 
    float *ptr = buffer;
 
-   sampleCount startrun = 0;
-   sampleCount stoprun = 0;
-   sampleCount samps = 0;
-   size_t block = 0;
+   decltype(len) s = 0, startrun = 0, stoprun = 0, samps = 0;
+   decltype(blockSize) block = 0;
    double startTime = -1.0;
 
    while (s < len) {
diff --git a/src/effects/Generator.cpp b/src/effects/Generator.cpp
index 61a3dcd44d38dac1d9730df36df8a9229cac852a..67c432eb7fb39bf4c135e77d496436fc6c9dc079 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 a2c2a955b0534706ff8d11da66cb1a1d0c90a95c..899540231d2bcd69e882101bdc34fad116b6ea7f 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 fc02bcc22e825522e072caa9861d3d2b10fd234f..02b4747d47751eb92bc5e01fb08a47ca498a3324 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 6c7fab735703082381c0f042149dc903a453bb69..40d8dbd42420f028d4cf05192163105c5088d55c 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 2081acc217ed39fc723d61009d2f1d5df28fcbb7..370afabbcf30c6e7459d2eff5ac06ee8c2ceefbd 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 9a7fce27ebbdb3e3a8ee9ccd70553c8ae6f9b24d..288c64e65b28b2a397f2ef9fb3a704e613905044 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 c4422fbd09cb8d99e57dc4e0e9014e27200aea78..3a1332d3dc32e390c548b05ecd48ad1a9c4f4411 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; i<len; i++)
+   for(decltype(len) i = 0; i < len; i++)
       mSum += (double)buffer[i];
    mCount += len;
 }
 
 void EffectNormalize::ProcessData(float *buffer, sampleCount len)
 {
-   sampleCount i;
-
-   for(i=0; i<len; i++) {
+   for(decltype(len) i = 0; i < len; i++) {
       float adjFrame = (buffer[i] + mOffset) * mMult;
       buffer[i] = adjFrame;
    }
diff --git a/src/effects/Paulstretch.cpp b/src/effects/Paulstretch.cpp
index 9b33ff252a9d8207914678799fc2ee96755c3cdb..f8cab3453dd8bd94e8b82f82b1749960f2470ccd 100644
--- a/src/effects/Paulstretch.cpp
+++ b/src/effects/Paulstretch.cpp
@@ -238,9 +238,9 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
    int stretch_buf_size = GetBufferSize(track->GetRate());
    double amount = this->mAmount;
 
-   sampleCount start = track->TimeToLongSamples(t0);
-   sampleCount end = track->TimeToLongSamples(t1);
-   sampleCount len = (sampleCount)(end - start);
+   auto start = track->TimeToLongSamples(t0);
+   auto end = track->TimeToLongSamples(t1);
+   auto len = end - start;
 
    int minDuration = stretch_buf_size * 2 + 1;
    if (len < minDuration){   //error because the selection is too short
@@ -292,18 +292,17 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
 
    PaulStretch stretch(amount,stretch_buf_size,track->GetRate());
 
-   sampleCount nget=stretch.get_nsamples_for_fill();
+   auto nget = stretch.get_nsamples_for_fill();
 
    int bufsize=stretch.poolsize;
    float *buffer0=new float[bufsize];
    float *bufferptr0=buffer0;
-   sampleCount outs=0;
    bool first_time=true;
 
    int fade_len=100;
    if (fade_len>(bufsize/2-1)) fade_len=bufsize/2-1;
    float *fade_track_smps=new float[fade_len];
-   sampleCount s=0;
+   decltype(len) s=0;
    bool cancelled=false;
 
    while (s<len){
@@ -314,7 +313,6 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
          stretch.process(buffer0,0);
       };
 
-      outs+=stretch.out_bufsize;
       s+=nget;
 
       if (first_time){//blend the the start of the selection
diff --git a/src/effects/Phaser.cpp b/src/effects/Phaser.cpp
index 48a83bf13148e5294db913ef409dfe45870e87bf..a284d9d88210bc8940c562f52294a3572d658c80 100644
--- a/src/effects/Phaser.cpp
+++ b/src/effects/Phaser.cpp
@@ -387,7 +387,7 @@ sampleCount EffectPhaser::InstanceProcess(EffectPhaserState & data, float **inBl
    data.phase = mPhase * M_PI / 180;
    data.outgain = DB_TO_LINEAR(mOutGain);
 
-   for (sampleCount i = 0; i < blockLen; i++)
+   for (decltype(blockLen) i = 0; i < blockLen; i++)
    {
       double in = ibuf[i];
 
diff --git a/src/effects/Repair.cpp b/src/effects/Repair.cpp
index 6b1167305c973abc4e9d573683469e217f818866..5917bd0b9808a77c9cb61d2e507bb04840eb8fb0 100644
--- a/src/effects/Repair.cpp
+++ b/src/effects/Repair.cpp
@@ -102,14 +102,14 @@ bool EffectRepair::Process()
          repair_t0 = (repair_t0 < t0? t0: repair_t0);
          repair_t1 = (repair_t1 > t1? t1: repair_t1);
 
-         sampleCount s0 = track->TimeToLongSamples(t0);
-         sampleCount repair0 = track->TimeToLongSamples(repair_t0);
-         sampleCount repair1 = track->TimeToLongSamples(repair_t1);
-         sampleCount s1 = track->TimeToLongSamples(t1);
-
-         sampleCount repairStart = (sampleCount)(repair0 - s0);
-         sampleCount repairLen = (sampleCount)(repair1 - repair0);
-         sampleCount len = (sampleCount)(s1 - s0);
+         auto s0 = track->TimeToLongSamples(t0);
+         auto repair0 = track->TimeToLongSamples(repair_t0);
+         auto repair1 = track->TimeToLongSamples(repair_t1);
+         auto s1 = track->TimeToLongSamples(t1);
+
+         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 dbfa6ba7035d159c23fba6051b527b0b5ad339b5..cbeeddbd59909506b5b3badbd8f4bbb924823593 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 e026aeca4cfd0e82e3b90177fba82847ebeed89a..73392584e4d5730fea6b921b6056470603776272 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 69cbeb5ff38407094c83b2179d9ece8e918a82db..40ae4d2f50068efc6e8196ad7e63553f12f4fd24 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,24 +218,23 @@ 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) {
-      const auto block =
+      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);
-      for (auto i = 0; i < block; i++) {
+      for (decltype(block) i = 0; i < block; i++) {
          tmp = buffer1[i];
          buffer1[i] = buffer2[block-i-1];
          buffer2[block-i-1] = tmp;
diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp
index 44d85109550afaa4bee51d447c465d49c699118f..345c7bc36c6e0e77dc3c6a0988c5c23c60666935 100644
--- a/src/effects/SBSMSEffect.cpp
+++ b/src/effects/SBSMSEffect.cpp
@@ -98,7 +98,7 @@ long resampleCB(void *cb_data, SBSMSFrame *data)
 {
    ResampleBuf *r = (ResampleBuf*) cb_data;
 
-   const auto blockSize = limitSampleBufferSize(
+   auto blockSize = limitSampleBufferSize(
       r->leftTrack->GetBestBlockSize(r->offset),
       r->end - r->offset
    );
@@ -108,7 +108,7 @@ long resampleCB(void *cb_data, SBSMSFrame *data)
    r->rightTrack->Get((samplePtr)(r->rightBuffer), floatSample, r->offset, blockSize);
 
    // convert to sbsms audio format
-   for(auto i=0; i<blockSize; i++) {
+   for(decltype(blockSize) i=0; i<blockSize; i++) {
       r->buf[i][0] = r->leftBuffer[i];
       r->buf[i][1] = r->rightBuffer[i];
    }
@@ -251,10 +251,8 @@ bool EffectSBSMS::Process()
 
          // Process only if the right marker is to the right of the left marker
          if (mCurT1 > mCurT0) {
-            sampleCount start;
-            sampleCount end;
-            start = leftTrack->TimeToLongSamples(mCurT0);
-            end = leftTrack->TimeToLongSamples(mCurT1);
+            auto start = leftTrack->TimeToLongSamples(mCurT0);
+            auto end = leftTrack->TimeToLongSamples(mCurT1);
 
             WaveTrack* rightTrack = NULL;
             if (leftTrack->GetLinked()) {
@@ -275,16 +273,18 @@ bool EffectSBSMS::Process()
 
                mCurTrackNum++; // Increment for rightTrack, too.
             }
-            sampleCount trackStart = leftTrack->TimeToLongSamples(leftTrack->GetStartTime());
-            sampleCount trackEnd = leftTrack->TimeToLongSamples(leftTrack->GetEndTime());
+            const auto trackStart =
+               leftTrack->TimeToLongSamples(leftTrack->GetStartTime());
+            const auto trackEnd =
+               leftTrack->TimeToLongSamples(leftTrack->GetEndTime());
 
             // SBSMS has a fixed sample rate - we just convert to its sample rate and then convert back
             float srTrack = leftTrack->GetRate();
-            float srProcess = bLinkRatePitch?srTrack:44100.0;
+            float srProcess = bLinkRatePitch ? srTrack : 44100.0;
 
             // the resampler needs a callback to supply its samples
             ResampleBuf rb;
-            sampleCount maxBlockSize = leftTrack->GetMaxBlockSize();
+            auto maxBlockSize = leftTrack->GetMaxBlockSize();
             rb.blockSize = maxBlockSize;
             rb.buf = (audio*)calloc(rb.blockSize,sizeof(audio));
             rb.leftTrack = leftTrack;
@@ -293,17 +293,14 @@ bool EffectSBSMS::Process()
             rb.rightBuffer = (float*)calloc(maxBlockSize,sizeof(float));
 
             // Samples in selection
-            sampleCount samplesIn = end-start;
+            auto samplesIn = end - start;
 
             // Samples for SBSMS to process after resampling
-            sampleCount samplesToProcess = (sampleCount) ((float)samplesIn*(srProcess/srTrack));
+            auto samplesToProcess = (sampleCount) ((float)samplesIn*(srProcess/srTrack));
 
             SlideType outSlideType;
             SBSMSResampleCB outResampleCB;
 
-            sampleCount processPresamples = 0;
-            sampleCount trackPresamples = 0;
-
             if(bLinkRatePitch) {
               rb.bPitch = true;
               outSlideType = rateSlideType;
@@ -327,10 +324,18 @@ bool EffectSBSMS::Process()
               rb.SBSMSBlockSize = rb.sbsms->getInputFrameSize();
               rb.SBSMSBuf = (audio*)calloc(rb.SBSMSBlockSize,sizeof(audio));
 
-              processPresamples = wxMin(rb.quality->getMaxPresamples(),
-                                        (long)((float)(start-trackStart)*(srProcess/srTrack)));
-              trackPresamples = wxMin(start-trackStart,
-                                      (long)((float)(processPresamples)*(srTrack/srProcess)));
+              // Note: width of getMaxPresamples() is only long.  Widen it
+              decltype(start) processPresamples = rb.quality->getMaxPresamples();
+              processPresamples =
+                 std::min(processPresamples,
+                          decltype(processPresamples)
+                             ((float)(start-trackStart)*(srProcess/srTrack)));
+
+              auto trackPresamples = start - trackStart;
+              trackPresamples =
+                  std::min(trackPresamples,
+                           decltype(trackPresamples)
+                              ((float)(processPresamples)*(srTrack/srProcess)));
               rb.offset = start - trackPresamples;
               rb.end = trackEnd;
               rb.iface = std::make_unique<SBSMSEffectInterface>
@@ -340,7 +345,9 @@ bool EffectSBSMS::Process()
                    // The argument type is only long!
                    static_cast<long> ( static_cast<size_t> (
                         samplesToProcess ) ),
-                   processPresamples,
+                   // This argument type is also only long!
+                   static_cast<long> ( static_cast<size_t> (
+                        processPresamples ) ),
                    rb.quality.get());
             }
             
@@ -354,7 +361,7 @@ bool EffectSBSMS::Process()
             sampleCount samplesToOutput = rb.iface->getSamplesToOutput();
 
             // Samples in output after resampling back
-            sampleCount samplesOut = (sampleCount) ((float)samplesToOutput * (srTrack/srProcess));
+            auto samplesOut = (sampleCount) ((float)samplesToOutput * (srTrack/srProcess));
 
             // Duration in track time
             double duration =  (mCurT1-mCurT0) * mTotalStretch;
diff --git a/src/effects/SimpleMono.cpp b/src/effects/SimpleMono.cpp
index a6a81774d3ed674fd5ed4bc60517759cc83f198d..40f47ce9b4a4e7d9d18ff2b6f43c62bf4d98e440 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 e1e36b7d24b6b2b747c33d471324ebb7bf1d4267..6a1e5aefef7d3213e4a1c6347d3b5cbfe1ba6cd9 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,11 +274,11 @@ 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
-      const auto blockSize = limitSampleBufferSize(
+      auto blockSize = limitSampleBufferSize(
          leftTrack->GetBestBlockSize(sourceSampleCount),
          end - sourceSampleCount
       );
@@ -291,7 +288,7 @@ bool EffectSoundTouch::ProcessStereo(WaveTrack* leftTrack, WaveTrack* rightTrack
       rightTrack->Get((samplePtr)(rightBuffer), floatSample, sourceSampleCount, blockSize);
 
       // Interleave into soundTouchBuffer.
-      for (auto index = 0; index < blockSize; index++) {
+      for (decltype(blockSize) index = 0; index < blockSize; index++) {
          soundTouchBuffer[index*2]       = leftBuffer[index];
          soundTouchBuffer[(index*2)+1]   = rightBuffer[index];
       }
diff --git a/src/effects/StereoToMono.cpp b/src/effects/StereoToMono.cpp
index 25f9c925aaceb32e5b5bc8e7f5255f90260bd88a..a8c6e1fd6ef087328fd9ad87ad2bf894b04adc09 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;
@@ -144,8 +144,8 @@ bool EffectStereoToMono::ProcessOne(int count)
    while (index < mEnd) {
       bResult &= mLeftTrack->Get((samplePtr)leftBuffer, floatSample, index, idealBlockLen);
       bResult &= mRightTrack->Get((samplePtr)rightBuffer, floatSample, index, idealBlockLen);
-      const auto limit = limitSampleBufferSize( idealBlockLen, mEnd - index );
-      for (auto i = 0; i < limit; ++i) {
+      auto limit = limitSampleBufferSize( idealBlockLen, mEnd - index );
+      for (decltype(limit) i = 0; i < limit; ++i) {
          index++;
          curLeftFrame = leftBuffer[i];
          curRightFrame = rightBuffer[i];
diff --git a/src/effects/ToneGen.cpp b/src/effects/ToneGen.cpp
index f93fcaccdaa349ba566634ac617110c7b1951b10..033e64ecd7cbd48d4ae3f4f7cad02270c7db5609 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 eba4b08eedc635a38a918e9e6a4d4640fc25ff70..619fc2ef7aa858ddfba4446713211c5ebde7763f 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<WaveTrack *>(t);
 
       // Smallest silent region to detect in frames
-      sampleCount minSilenceFrames =
+      auto minSilenceFrames =
          sampleCount(std::max(mInitialAllowedSilence, DEF_MinTruncMs) * wt->GetRate());
 
       //
@@ -386,7 +386,7 @@ bool EffectTruncSilence::FindSilences
       //
       RegionList trackSilences;
 
-      sampleCount index = wt->TimeToLongSamples(mT0);
+      auto index = wt->TimeToLongSamples(mT0);
       sampleCount silentFrame = 0;
 
       // Detect silences
@@ -487,7 +487,7 @@ bool EffectTruncSilence::DoRemoval
          {
             // In WaveTracks, clear with a cross-fade
             WaveTrack *const wt = static_cast<WaveTrack*>(t);
-            sampleCount blendFrames = mBlendFrameCount;
+            auto blendFrames = mBlendFrameCount;
             // Round start/end times to frame boundaries
             cutStart = wt->LongSamplesToTime(wt->TimeToLongSamples(cutStart));
             cutEnd = wt->LongSamplesToTime(wt->TimeToLongSamples(cutEnd));
@@ -501,13 +501,13 @@ bool EffectTruncSilence::DoRemoval
             // Perform cross-fade in memory
             float *buf1 = new float[blendFrames];
             float *buf2 = new float[blendFrames];
-            sampleCount t1 = wt->TimeToLongSamples(cutStart) - blendFrames / 2;
-            sampleCount t2 = wt->TimeToLongSamples(cutEnd) - blendFrames / 2;
+            auto t1 = wt->TimeToLongSamples(cutStart) - blendFrames / 2;
+            auto t2 = wt->TimeToLongSamples(cutEnd) - blendFrames / 2;
 
             wt->Get((samplePtr)buf1, floatSample, t1, blendFrames);
             wt->Get((samplePtr)buf2, floatSample, t2, blendFrames);
 
-            for (sampleCount i = 0; i < blendFrames; ++i)
+            for (decltype(blendFrames) i = 0; i < blendFrames; ++i)
             {
                buf1[i] = ((blendFrames-i) * buf1[i] + i * buf2[i]) /
                          (double)blendFrames;
@@ -542,12 +542,12 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList,
                                  double* minInputLength /*= NULL*/)
 {
    // Smallest silent region to detect in frames
-   sampleCount minSilenceFrames = sampleCount(std::max( mInitialAllowedSilence, DEF_MinTruncMs) * wt->GetRate());
+   auto minSilenceFrames = sampleCount(std::max( mInitialAllowedSilence, DEF_MinTruncMs) * wt->GetRate());
 
    double truncDbSilenceThreshold = Enums::Db2Signal[mTruncDbChoiceIndex];
-   sampleCount blockLen = wt->GetMaxBlockSize();
-   sampleCount start = wt->TimeToLongSamples(mT0);
-   sampleCount end = wt->TimeToLongSamples(mT1);
+   auto blockLen = wt->GetMaxBlockSize();
+   auto start = wt->TimeToLongSamples(mT0);
+   auto end = wt->TimeToLongSamples(mT1);
    sampleCount outLength = 0;
 
    double previewLength;
@@ -596,8 +596,8 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList,
          // No more regions -- no need to process the rest of the track
          if (inputLength) {
             // Add available samples up to previewLength.
-            sampleCount remainingTrackSamples = wt->TimeToLongSamples(wt->GetEndTime()) - *index;
-            sampleCount requiredTrackSamples = previewLen - outLength;
+            auto remainingTrackSamples = wt->TimeToLongSamples(wt->GetEndTime()) - *index;
+            auto requiredTrackSamples = previewLen - outLength;
             outLength += (remainingTrackSamples > requiredTrackSamples)? requiredTrackSamples : remainingTrackSamples;
          }
 
@@ -612,9 +612,9 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList,
             ));
          }
          *silentFrame = 0;
-         sampleCount newIndex = wt->TimeToLongSamples(rit->start);
+         auto newIndex = wt->TimeToLongSamples(rit->start);
          if (inputLength) {
-            sampleCount requiredTrackSamples = previewLen - outLength;
+            auto requiredTrackSamples = previewLen - outLength;
             // Add non-silent sample to outLength
             outLength += ((newIndex - *index) > requiredTrackSamples)? requiredTrackSamples : newIndex - *index;
          }
@@ -624,13 +624,13 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList,
       // End of optimization
 
       // Limit size of current block if we've reached the end
-      const auto count = limitSampleBufferSize( blockLen, end - *index );
+      auto count = limitSampleBufferSize( blockLen, end - *index );
 
       // Fill buffer
       wt->Get((samplePtr)(buffer), floatSample, *index, count);
 
       // Look for silenceList in current block
-      for (auto i = 0; i < count; ++i) {
+      for (decltype(count) i = 0; i < count; ++i) {
          if (inputLength && ((outLength >= previewLen) || (outLength > wt->TimeToLongSamples(*minInputLength)))) {
             *inputLength = wt->LongSamplesToTime(*index + i) - wt->LongSamplesToTime(start);
             break;
diff --git a/src/effects/TwoPassSimpleMono.cpp b/src/effects/TwoPassSimpleMono.cpp
index 8037853f99546c0c2255a305882d28bdd556871b..46a90c8612a9022f5345eabf14b2cc3ad1c17735 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 6c6e389aa64ac117ce4ef6b73724f3934e6dc160..101c5181e3d03074d7ce9d8175842b25d1172ccb 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/Wahwah.cpp b/src/effects/Wahwah.cpp
index c498c9d5608d05bba7f3435a3cbe66984c31e180..c8b5e7e860f4e3160d1dce23ff4e94f8f2403375 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/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp
index 99b6c4d5bf8d7bcefe4838e02c87b6049c867f1e..1173e1e9eeb6c77f526bb81e15ce188c0375a65f 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()
@@ -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 336d5265df34ddaee2a8130bcdd8ffbf2156a3a6..60cd799821bc38f54013b6a66a4dae833f67f666 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 a2c90968e7dd5de99bcca48226927e23cc9de3d1..5ff9b567567cec51d24282183d3b1c71c3c42008 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 249f08812998f58b2b64786f3ce904fac41e32e6..ae5afbceb3a2e67acc5405f4fdc57adc7a69636c 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 68ee6f051cf294594ba7229a69c795786d9d0bfd..76ad0039ad536d00741ba655c43261fda7d00d96 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 c615ef7f2c37a7c2f67ede98322f8f3bf6675f13..51137a3363a96b3ff8122baf107f855a0f156542 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 196555910e8f0c936db5d1017495791b57eceb71..a935ebbc07737103db60926706a22676615236a9 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));
@@ -324,7 +324,7 @@ int ExportFLAC::Export(AudacityProject *project,
          _("Exporting the entire project as FLAC"));
 
       while (updateResult == eProgressSuccess) {
-         sampleCount samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
+         auto samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
          if (samplesThisRun == 0) { //stop encoding
             break;
          }
@@ -332,12 +332,12 @@ int ExportFLAC::Export(AudacityProject *project,
             for (i = 0; i < numChannels; i++) {
                samplePtr mixed = mixer->GetBuffer(i);
                if (format == int24Sample) {
-                  for (j = 0; j < samplesThisRun; j++) {
+                  for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) {
                      tmpsmplbuf[i][j] = ((int *)mixed)[j];
                   }
                }
                else {
-                  for (j = 0; j < samplesThisRun; j++) {
+                  for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) {
                      tmpsmplbuf[i][j] = ((short *)mixed)[j];
                   }
                }
diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp
index c8a1f8e26e498c81c5edbb998e4606424b8086ee..d5b2818704184f1a3e7fe089fd5cd4e3b768fff2 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 891bdb12d1503734f80d26a36e6d5b26de01e2ec..b32c8c321b0d2cdffb7bc6c5a0021550f571513c 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 01226452889c3d992b1d13f23c5747168b8ea666..472ed098d68a673637d7a0ba0e5abae0ac6adcf0 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 d4a1f8284ff1316fb72d92a3d91c2275e1f50f06..7a9618527e83bbe364a928b54b8d1e2cbb250a00 100644
--- a/src/export/ExportPCM.cpp
+++ b/src/export/ExportPCM.cpp
@@ -490,8 +490,8 @@ int ExportPCM::Export(AudacityProject *project,
                                                   formatStr.c_str()));
 
          while (updateResult == eProgressSuccess) {
-            sampleCount samplesWritten;
-            sampleCount numSamples = mixer->Process(maxBlockLen);
+            sf_count_t samplesWritten;
+            auto numSamples = mixer->Process(maxBlockLen);
 
             if (numSamples == 0)
                break;
diff --git a/src/import/ImportFFmpeg.cpp b/src/import/ImportFFmpeg.cpp
index 76e6d99986c850a61709256c973cec219a3ca388..12df5b2dbd53381b37e059fd54b855206f3cfd18 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 f617454095bf2746b6d914cf90dd1a0dc1db36bf..b18835a0f3933d1e7471b4a969f14fdc629a55bf 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 56bd6b5554129feeef0281514e2b0a90d967a267..85b65a8c3553f2919ced660da262b294ed6b9fc7 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 8feadedf0f90be2a4ed97db1cb96009b7a722305..05c628a4cb7a1135c3eb3285fcef013b9ddc2b1b 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<int>::max() /
-                 (mInfo.channels * SAMPLE_SIZE(mFormat)))
+      using type = decltype(maxBlockSize);
+      auto maxBlock = std::min(maxBlockSize,
+         std::numeric_limits<type>::max() /
+            (mInfo.channels * SAMPLE_SIZE(mFormat))
       );
       if (maxBlock < 1)
          return eProgressFailed;
@@ -446,7 +448,7 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
 
       SampleBuffer buffer(maxBlock, mFormat);
 
-      unsigned long framescompleted = 0;
+      decltype(fileTotalFrames) framescompleted = 0;
 
       long block;
       do {
diff --git a/src/import/ImportQT.cpp b/src/import/ImportQT.cpp
index 60732065b205effd32f88a9fa471e1e19abfa3cf..9cf0257758906fa91c50ab3c5b84da0327ef9327 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 fb81bb2d6bbfbc1357593c53f0b0f616d4574176..63d235ac1c55039bc8251b9c4f9c53fc797fda84 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_count_t>(sf_seek, sndFile.get(), 0, SEEK_SET);
 
-      totalFrames = (sampleCount)(sndInfo.frames * percent / 100.0);
+      auto totalFrames = (sampleCount)(sndInfo.frames * percent / 100.0);
 
       //
       // Sample format:
@@ -218,12 +217,12 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
          firstChannel->SetLinked(true);
       }
 
-      sampleCount maxBlockSize = firstChannel->GetMaxBlockSize();
+      auto maxBlockSize = firstChannel->GetMaxBlockSize();
 
       SampleBuffer srcbuffer(maxBlockSize * numChannels, format);
       SampleBuffer buffer(maxBlockSize, format);
 
-      sampleCount framescompleted = 0;
+      decltype(totalFrames) framescompleted = 0;
       if (totalFrames < 0) {
          wxASSERT(false);
          totalFrames = 0;
diff --git a/src/ondemand/ODComputeSummaryTask.cpp b/src/ondemand/ODComputeSummaryTask.cpp
index f82e18b2edbcca3dc8c850300a1d897b6ecd46aa..1def19b0b0c4a94a0a37ec14c17c9188f0f07247 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<ODPCMAliasBlockFile>(file);
                   odpcmaFile->SetStart(block.start);
-                  odpcmaFile->SetClipOffset((sampleCount)(clip->GetStartTime()*clip->GetRate()));
+                  odpcmaFile->SetClipOffset(clip->GetStartTime()*clip->GetRate());
 
                   //these will always be linear within a sequence-lets take advantage of this by keeping a cursor.
                   while(insertCursor<(int)tempBlocks.size()&&
-                     (sampleCount)(tempBlocks[insertCursor]->GetStart()+tempBlocks[insertCursor]->GetClipOffset()) <
-                        (sampleCount)(odpcmaFile->GetStart()+odpcmaFile->GetClipOffset()))
+                     tempBlocks[insertCursor]->GetStart() + tempBlocks[insertCursor]->GetClipOffset() <
+                        odpcmaFile->GetStart() + odpcmaFile->GetClipOffset())
                      insertCursor++;
 
                   tempBlocks.insert(tempBlocks.begin() + insertCursor++, odpcmaFile);
@@ -240,7 +240,7 @@ void ODComputeSummaryTask::OrderBlockFiles
    //Note that this code assumes that the array is sorted in time.
 
    //find the startpoint
-   sampleCount processStartSample = GetDemandSample();
+   auto processStartSample = GetDemandSample();
    for(int i= ((int)unorderedBlocks.size())-1;i>= 0;i--)
    {
       //check to see if the refcount is at least two before we add it to the list.
diff --git a/src/ondemand/ODDecodeFFmpegTask.cpp b/src/ondemand/ODDecodeFFmpegTask.cpp
index c1c63807ea4d4d2a774f5bf3fe61a97e8dd39602..0e5174992a4f51ae28f37f7ee3704934189301a0 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 cffd84a36b5583f9076af42be2dd17c8dcb7b474..31f81d47894e6ad5f24e3b8089adcca241a29196 100644
--- a/src/ondemand/ODDecodeTask.cpp
+++ b/src/ondemand/ODDecodeTask.cpp
@@ -159,12 +159,12 @@ void ODDecodeTask::Update()
                        std::static_pointer_cast<ODDecodeBlockFile>(file))->GetDecodeType() == this->GetODType())
                {
                   oddbFile->SetStart(block.start);
-                  oddbFile->SetClipOffset((sampleCount)(clip->GetStartTime()*clip->GetRate()));
+                  oddbFile->SetClipOffset(clip->GetStartTime()*clip->GetRate());
 
                   //these will always be linear within a sequence-lets take advantage of this by keeping a cursor.
                   while(insertCursor<(int)tempBlocks.size()&&
-                     (sampleCount)(tempBlocks[insertCursor]->GetStart()+tempBlocks[insertCursor]->GetClipOffset()) <
-                        (sampleCount)((oddbFile->GetStart()+oddbFile->GetClipOffset())))
+                     tempBlocks[insertCursor]->GetStart() + tempBlocks[insertCursor]->GetClipOffset() <
+                        oddbFile->GetStart() + oddbFile->GetClipOffset())
                      insertCursor++;
 
                   tempBlocks.insert(tempBlocks.begin()+insertCursor++, oddbFile);
@@ -193,7 +193,7 @@ void ODDecodeTask::OrderBlockFiles
    //(which the user sets by clicking.)   note that this code is pretty hacky - it assumes that the array is sorted in time.
 
    //find the startpoint
-   sampleCount processStartSample = GetDemandSample();
+   auto processStartSample = GetDemandSample();
    for(int i= ((int)unorderedBlocks.size())-1;i>= 0;i--)
    {
       //check to see if the refcount is at least two before we add it to the list.
diff --git a/src/ondemand/ODTask.cpp b/src/ondemand/ODTask.cpp
index 39de3aaae6202c58b7845fcd79631b3566a61cde..4adcd0e6748d045b07d7bd4fd7bce9f366e27179 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 fda47040e80a41285a8f600dda9c0733d276bcfe..cf821dfb7bb45e975b521c1f00be90408ca895bf 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.
diff --git a/src/widgets/NumericTextCtrl.cpp b/src/widgets/NumericTextCtrl.cpp
index d7eacfc2cf269d6e565bb1c91b859c7c83192464..5b6369e065a4c962968b7393b941cbd1bdda42b7 100644
--- a/src/widgets/NumericTextCtrl.cpp
+++ b/src/widgets/NumericTextCtrl.cpp
@@ -1667,6 +1667,7 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event)
       }
       mValueString[digitPosition] = wxChar(keyCode);
       ControlsToValue();
+      Refresh();// Force an update of the control. [Bug 1497]
       ValueToControls();
       mFocusedDigit = (mFocusedDigit + 1) % (mDigits.GetCount());
       Updated();
@@ -1686,6 +1687,7 @@ void NumericTextCtrl::OnKeyDown(wxKeyEvent &event)
       if (theDigit != wxChar('-'))
          theDigit = '0';
       ControlsToValue();
+      Refresh();// Force an update of the control. [Bug 1497]
       ValueToControls();
       Updated();
    }