Type agnosticism for some other variables that were not sampleCount...

... in some cases, this fixes narrowings.
This commit is contained in:
Paul Licameli 2016-08-24 07:56:33 -04:00
parent 79c79f9cd3
commit fd2b050d6f
16 changed files with 26 additions and 29 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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();

View File

@ -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;

View File

@ -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.

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;i<curretLength;i++)
for(decltype(curretLength) i=0;i<curretLength;i++)
buffer1[i]-=buffer2[i];
output->Append((samplePtr)buffer1, floatSample, curretLength);
currentSample+=curretLength;

View File

@ -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) {

View File

@ -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];

View File

@ -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];
}
}

View File

@ -448,7 +448,7 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
SampleBuffer buffer(maxBlock, mFormat);
unsigned long framescompleted = 0;
decltype(fileTotalFrames) framescompleted = 0;
long block;
do {