1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-02 14:17:07 +01:00

Convert sampleCount <-> floating or -> long long explicitly ...

... A non-narrowing conversion out to long long is a necessity, but the
conversions to float and double are simply conveniences.

Conversion from floating is explicit, to avoid unintended consequences with
arithmetic operators, when later sampleCount ceases to be an alias for an
integral type.

Some conversions are not made explicit, where I expect to change the type of
the variable later to have mere size_t width.
This commit is contained in:
Paul Licameli
2016-08-25 08:53:59 -04:00
parent 99dca62cff
commit 78be459fa1
53 changed files with 329 additions and 207 deletions

View File

@@ -178,7 +178,7 @@ bool EffectSoundTouch::ProcessOne(WaveTrack *track,
//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);
auto len = (end - start).as_double();
//Initiate a processing buffer. This buffer will (most likely)
//be shorter than the length of the track being processed.
@@ -211,7 +211,7 @@ bool EffectSoundTouch::ProcessOne(WaveTrack *track,
s += block;
//Update the Progress meter
if (TrackProgress(mCurTrackNum, (s - start) / len))
if (TrackProgress(mCurTrackNum, (s - start).as_double() / len))
return false;
}
@@ -256,7 +256,7 @@ bool EffectSoundTouch::ProcessStereo(WaveTrack* leftTrack, WaveTrack* rightTrack
//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);
double len = (end - start).as_double();
//Initiate a processing buffer. This buffer will (most likely)
//be shorter than the length of the track being processed.
@@ -304,7 +304,7 @@ bool EffectSoundTouch::ProcessStereo(WaveTrack* leftTrack, WaveTrack* rightTrack
//Update the Progress meter
// mCurTrackNum is left track. Include right track.
int nWhichTrack = mCurTrackNum;
double frac = (sourceSampleCount - start) / len;
double frac = (sourceSampleCount - start).as_double() / len;
if (frac < 0.5)
frac *= 2.0; // Show twice as far for each track, because we're doing 2 at once.
else