From fd2b050d6f25b5e296a036e9c524f9bc0954c78b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 24 Aug 2016 07:56:33 -0400 Subject: [PATCH] Type agnosticism for some other variables that were not sampleCount... ... in some cases, this fixes narrowings. --- src/Benchmark.cpp | 2 +- src/Dependencies.cpp | 2 +- src/Mix.cpp | 8 +++----- src/Sequence.cpp | 5 ++--- src/WaveClip.cpp | 2 +- src/WaveTrack.cpp | 2 +- src/commands/CompareAudioCommand.cpp | 10 +++++----- src/effects/AutoDuck.cpp | 4 ++-- src/effects/BassTreble.cpp | 2 +- src/effects/Distortion.cpp | 2 +- src/effects/Effect.cpp | 2 +- src/effects/Equalization48x.cpp | 2 +- src/effects/FindClipping.cpp | 2 +- src/effects/Wahwah.cpp | 2 +- src/export/ExportFLAC.cpp | 6 +++--- src/import/ImportPCM.cpp | 2 +- 16 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/Benchmark.cpp b/src/Benchmark.cpp index 8a8417664..d6139d18a 100644 --- a/src/Benchmark.cpp +++ b/src/Benchmark.cpp @@ -335,7 +335,7 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event)) gPrefs->Flush(); // Rememebr the old blocksize, so that we can restore it later. - int oldBlockSize = Sequence::GetMaxDiskBlockSize(); + auto oldBlockSize = Sequence::GetMaxDiskBlockSize(); Sequence::SetMaxDiskBlockSize(blockSize * 1024); wxBusyCursor busy; diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index 5331d9b2c..ec7cf7f14 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -194,7 +194,7 @@ static void RemoveDependencies(AudacityProject *project, continue; // Convert it from an aliased file to an actual file in the project. - unsigned int len = aliasBlockFile->GetLength(); + auto len = aliasBlockFile->GetLength(); BlockFilePtr newBlockFile; { SampleBuffer buffer(len, format); diff --git a/src/Mix.cpp b/src/Mix.cpp index 827e9f091..d0f697d1e 100644 --- a/src/Mix.cpp +++ b/src/Mix.cpp @@ -150,7 +150,7 @@ void MixAndRender(TrackList *tracks, TrackFactory *trackFactory, - int maxBlockLen = mixLeft->GetIdealBlockSize(); + auto maxBlockLen = mixLeft->GetIdealBlockSize(); // If the caller didn't specify a time range, use the whole range in which // any input track had clips in it. @@ -338,9 +338,7 @@ Mixer::Mixer(const WaveTrackConstArray &inputTracks, mQueueLen[i] = 0; } - int envLen = mInterleavedBufferSize; - if (mQueueMaxLen > envLen) - envLen = mQueueMaxLen; + const auto envLen = std::max(mQueueMaxLen, mInterleavedBufferSize); mEnvValues = new double[envLen]; } @@ -557,7 +555,7 @@ sampleCount Mixer::MixSameRate(int *channelFlags, WaveTrackCache &cache, sampleCount *pos) { const WaveTrack *const track = cache.GetTrack(); - int slen = mMaxOut; + auto slen = mMaxOut; int c; const double t = *pos / track->GetRate(); const double trackEndTime = track->GetEndTime(); diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 031ba1171..801e835bb 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -1556,11 +1556,10 @@ void Sequence::Blockify(BlockArray &list, sampleCount start, samplePtr buffer, s { if (len <= 0) return; - - const int num = (len + (mMaxSamples - 1)) / mMaxSamples; + auto num = (len + (mMaxSamples - 1)) / mMaxSamples; list.reserve(list.size() + num); - for (int i = 0; i < num; i++) { + for (decltype(num) i = 0; i < num; i++) { SeqBlock b; const auto offset = i * len / num; diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index 2c539460e..2f684e8b1 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -608,7 +608,7 @@ bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0, /* handle values in the append buffer */ - int numSamples = mSequence->GetNumSamples(); + auto numSamples = mSequence->GetNumSamples(); int a; // Not all of the required columns might be in the sequence. diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 265fef6f8..61a972d0d 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -2106,7 +2106,7 @@ void WaveTrack::GetEnvelopeValues(double *buffer, size_t bufferLen, // be set twice. Unfortunately, there is no easy way around this since the clips are not // stored in increasing time order. If they were, we could just track the time as the // buffer is filled. - for (int i = 0; i < bufferLen; i++) + for (decltype(bufferLen) i = 0; i < bufferLen; i++) { buffer[i] = 1.0; } diff --git a/src/commands/CompareAudioCommand.cpp b/src/commands/CompareAudioCommand.cpp index e0344b307..874e48faa 100644 --- a/src/commands/CompareAudioCommand.cpp +++ b/src/commands/CompareAudioCommand.cpp @@ -98,15 +98,15 @@ bool CompareAudioCommand::Apply(CommandExecutionContext context) double errorThreshold = GetDouble(wxT("Threshold")); // Initialize buffers for track data to be analyzed - int buffSize = min(mTrack0->GetMaxBlockSize(), mTrack1->GetMaxBlockSize()); + auto buffSize = std::min(mTrack0->GetMaxBlockSize(), mTrack1->GetMaxBlockSize()); float *buff0 = new float[buffSize]; float *buff1 = new float[buffSize]; // Compare tracks block by block - long s0 = mTrack0->TimeToLongSamples(mT0); - long s1 = mTrack0->TimeToLongSamples(mT1); - long position = s0; - long length = s1 - s0; + auto s0 = mTrack0->TimeToLongSamples(mT0); + auto s1 = mTrack0->TimeToLongSamples(mT1); + auto position = s0; + auto length = s1 - s0; while (position < s1) { // Get a block of data into the buffers diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index ba31f0ed6..c3450303e 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -517,12 +517,12 @@ bool EffectAutoDuck::ApplyDuckFade(int trackNumber, WaveTrack* t, float *buf = new float[kBufSize]; auto pos = start; - int fadeDownSamples = t->TimeToLongSamples( + auto fadeDownSamples = t->TimeToLongSamples( mOuterFadeDownLen + mInnerFadeDownLen); if (fadeDownSamples < 1) fadeDownSamples = 1; - int fadeUpSamples = t->TimeToLongSamples( + auto fadeUpSamples = t->TimeToLongSamples( mOuterFadeUpLen + mInnerFadeUpLen); if (fadeUpSamples < 1) fadeUpSamples = 1; diff --git a/src/effects/BassTreble.cpp b/src/effects/BassTreble.cpp index 24bdf9ff2..73796b75c 100644 --- a/src/effects/BassTreble.cpp +++ b/src/effects/BassTreble.cpp @@ -361,7 +361,7 @@ sampleCount EffectBassTreble::InstanceProcess(EffectBassTrebleState & data, data.a0Treble, data.a1Treble, data.a2Treble, data.b0Treble, data.b1Treble, data.b2Treble); - for (sampleCount i = 0; i < blockLen; i++) { + for (decltype(blockLen) i = 0; i < blockLen; i++) { obuf[i] = DoFilter(data, ibuf[i]) * data.gain; } diff --git a/src/effects/Distortion.cpp b/src/effects/Distortion.cpp index 34b977ca6..dfdd6c42e 100644 --- a/src/effects/Distortion.cpp +++ b/src/effects/Distortion.cpp @@ -524,7 +524,7 @@ sampleCount EffectDistortion::InstanceProcess(EffectDistortionState& data, float data.param1 = mParams.mParam1; data.repeats = mParams.mRepeats; - for (sampleCount i = 0; i < blockLen; i++) { + for (decltype(blockLen) i = 0; i < blockLen; i++) { if (update && ((data.skipcount++) % skipsamples == 0)) { MakeTable(); } diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 778a0108e..88656ea9a 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1617,7 +1617,7 @@ bool Effect::ProcessTrack(int count, auto cnt = mBlockSize - curBlockSize; for (int i = 0; i < mNumChannels; i++) { - for (int j = 0 ; j < cnt; j++) + for (decltype(cnt) j = 0 ; j < cnt; j++) { mInBufPos[i][j + curBlockSize] = 0.0; } diff --git a/src/effects/Equalization48x.cpp b/src/effects/Equalization48x.cpp index 62a168c34..16c9d865c 100644 --- a/src/effects/Equalization48x.cpp +++ b/src/effects/Equalization48x.cpp @@ -420,7 +420,7 @@ bool EffectEqualization48x::DeltaTrack(WaveTrack * t, WaveTrack * t2, sampleCoun auto curretLength = (trackBlockSize > len) ? len : trackBlockSize; t->Get((samplePtr)buffer1, floatSample, currentSample, curretLength); t2->Get((samplePtr)buffer2, floatSample, currentSample, curretLength); - for(int i=0;iAppend((samplePtr)buffer1, floatSample, curretLength); currentSample+=curretLength; diff --git a/src/effects/FindClipping.cpp b/src/effects/FindClipping.cpp index 063c3d6bd..546724c70 100644 --- a/src/effects/FindClipping.cpp +++ b/src/effects/FindClipping.cpp @@ -164,7 +164,7 @@ bool EffectFindClipping::ProcessOne(LabelTrack * lt, float *ptr = buffer; decltype(len) s = 0, startrun = 0, stoprun = 0, samps = 0; - size_t block = 0; + decltype(blockSize) block = 0; double startTime = -1.0; while (s < len) { diff --git a/src/effects/Wahwah.cpp b/src/effects/Wahwah.cpp index c498c9d56..c8b5e7e86 100644 --- a/src/effects/Wahwah.cpp +++ b/src/effects/Wahwah.cpp @@ -355,7 +355,7 @@ sampleCount EffectWahwah::InstanceProcess(EffectWahwahState & data, float **inBl data.phase = mPhase * M_PI / 180.0; data.outgain = DB_TO_LINEAR(mOutGain); - for (int i = 0; i < blockLen; i++) + for (decltype(blockLen) i = 0; i < blockLen; i++) { in = (double) ibuf[i]; diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index ef5075ff9..a935ebbc0 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -311,7 +311,7 @@ int ExportFLAC::Export(AudacityProject *project, numChannels, SAMPLES_PER_RUN, false, rate, format, true, mixerSpec); - int i, j; + int i; FLAC__int32 **tmpsmplbuf = new FLAC__int32*[numChannels]; for (i = 0; i < numChannels; i++) { tmpsmplbuf[i] = (FLAC__int32 *) calloc(SAMPLES_PER_RUN, sizeof(FLAC__int32)); @@ -332,12 +332,12 @@ int ExportFLAC::Export(AudacityProject *project, for (i = 0; i < numChannels; i++) { samplePtr mixed = mixer->GetBuffer(i); if (format == int24Sample) { - for (j = 0; j < samplesThisRun; j++) { + for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) { tmpsmplbuf[i][j] = ((int *)mixed)[j]; } } else { - for (j = 0; j < samplesThisRun; j++) { + for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) { tmpsmplbuf[i][j] = ((short *)mixed)[j]; } } diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index 7279b40db..05c628a4c 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -448,7 +448,7 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory, SampleBuffer buffer(maxBlock, mFormat); - unsigned long framescompleted = 0; + decltype(fileTotalFrames) framescompleted = 0; long block; do {