mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 16:40:07 +02:00
Remove unnecessary casts to sampleCount
This commit is contained in:
parent
fd2b050d6f
commit
52417c444d
@ -375,7 +375,7 @@ double WaveClip::GetEndTime() const
|
|||||||
|
|
||||||
sampleCount WaveClip::GetStartSample() const
|
sampleCount WaveClip::GetStartSample() const
|
||||||
{
|
{
|
||||||
return (sampleCount)floor(mOffset * mRate + 0.5);
|
return floor(mOffset * mRate + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleCount WaveClip::GetEndSample() const
|
sampleCount WaveClip::GetEndSample() const
|
||||||
@ -472,11 +472,9 @@ fillWhere(std::vector<sampleCount> &where, int len, double bias, double correcti
|
|||||||
{
|
{
|
||||||
// Be careful to make the first value non-negative
|
// Be careful to make the first value non-negative
|
||||||
const double w0 = 0.5 + correction + bias + t0 * rate;
|
const double w0 = 0.5 + correction + bias + t0 * rate;
|
||||||
where[0] = sampleCount(std::max(0.0, floor(w0)));
|
where[0] = std::max(0.0, floor(w0));
|
||||||
for (decltype(len) x = 1; x < len + 1; x++)
|
for (decltype(len) x = 1; x < len + 1; x++)
|
||||||
where[x] = sampleCount(
|
where[x] = floor(w0 + double(x) * samplesPerPixel);
|
||||||
floor(w0 + double(x) * samplesPerPixel)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1198,7 +1196,7 @@ void WaveClip::TimeToSamplesClip(double t0, sampleCount *s0) const
|
|||||||
else if (t0 > mOffset + double(mSequence->GetNumSamples())/mRate)
|
else if (t0 > mOffset + double(mSequence->GetNumSamples())/mRate)
|
||||||
*s0 = mSequence->GetNumSamples();
|
*s0 = mSequence->GetNumSamples();
|
||||||
else
|
else
|
||||||
*s0 = (sampleCount)floor(((t0 - mOffset) * mRate) + 0.5);
|
*s0 = floor(((t0 - mOffset) * mRate) + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveClip::ClearDisplayRect() const
|
void WaveClip::ClearDisplayRect() const
|
||||||
|
@ -1851,7 +1851,7 @@ bool WaveTrack::Unlock() const
|
|||||||
|
|
||||||
AUDACITY_DLL_API sampleCount WaveTrack::TimeToLongSamples(double t0) 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
|
double WaveTrack::LongSamplesToTime(sampleCount pos) const
|
||||||
|
@ -306,7 +306,7 @@ bool EffectAutoDuck::Process()
|
|||||||
{
|
{
|
||||||
const auto len = limitSampleBufferSize( kBufSize, end - pos );
|
const auto len = limitSampleBufferSize( kBufSize, end - pos );
|
||||||
|
|
||||||
mControlTrack->Get((samplePtr)buf, floatSample, pos, (sampleCount)len);
|
mControlTrack->Get((samplePtr)buf, floatSample, pos, len);
|
||||||
|
|
||||||
for (auto i = pos; i < pos + len; i++)
|
for (auto i = pos; i < pos + len; i++)
|
||||||
{
|
{
|
||||||
|
@ -122,8 +122,8 @@ bool EffectDtmf::ProcessInitialize(sampleCount WXUNUSED(totalLen), ChannelNames
|
|||||||
numSamplesSequence = nT1 - nT0; // needs to be exact number of samples selected
|
numSamplesSequence = nT1 - nT0; // needs to be exact number of samples selected
|
||||||
|
|
||||||
//make under-estimates if anything, and then redistribute the few remaining samples
|
//make under-estimates if anything, and then redistribute the few remaining samples
|
||||||
numSamplesTone = (sampleCount)floor(dtmfTone * mSampleRate);
|
numSamplesTone = floor(dtmfTone * mSampleRate);
|
||||||
numSamplesSilence = (sampleCount)floor(dtmfSilence * mSampleRate);
|
numSamplesSilence = floor(dtmfSilence * mSampleRate);
|
||||||
|
|
||||||
// recalculate the sum, and spread the difference - due to approximations.
|
// 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)
|
// Since diff should be in the order of "some" samples, a division (resulting in zero)
|
||||||
|
@ -2019,7 +2019,7 @@ void Effect::GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len)
|
|||||||
if (t1 > t0) {
|
if (t1 > t0) {
|
||||||
*start = track->TimeToLongSamples(t0);
|
*start = track->TimeToLongSamples(t0);
|
||||||
auto end = track->TimeToLongSamples(t1);
|
auto end = track->TimeToLongSamples(t1);
|
||||||
*len = (sampleCount)(end - *start);
|
*len = end - *start;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*start = 0;
|
*start = 0;
|
||||||
|
@ -1147,7 +1147,7 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
|
|||||||
|
|
||||||
// now move the appropriate bit of the output back to the track
|
// now move the appropriate bit of the output back to the track
|
||||||
// (this could be enhanced in the future to use the tails)
|
// (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);
|
double lenT = t->LongSamplesToTime(originalLen);
|
||||||
// 'start' is the sample offset in 't', the passed in track
|
// 'start' is the sample offset in 't', the passed in track
|
||||||
// 'startT' is the equivalent time value
|
// 'startT' is the equivalent time value
|
||||||
|
@ -510,7 +510,7 @@ bool EffectEqualization48x::Benchmark(EffectEqualization* effectEqualization)
|
|||||||
|
|
||||||
bool EffectEqualization48x::ProcessTail(WaveTrack * t, WaveTrack * output, sampleCount start, sampleCount len)
|
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);
|
double lenT = t->LongSamplesToTime(len);
|
||||||
// 'start' is the sample offset in 't', the passed in track
|
// 'start' is the sample offset in 't', the passed in track
|
||||||
// 'startT' is the equivalent time value
|
// 'startT' is the equivalent time value
|
||||||
|
@ -1213,7 +1213,7 @@ sampleCount AudioUnitEffect::GetLatency()
|
|||||||
&latency,
|
&latency,
|
||||||
&dataSize);
|
&dataSize);
|
||||||
|
|
||||||
return (sampleCount) (latency * mSampleRate);
|
return latency * mSampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1231,7 +1231,7 @@ sampleCount AudioUnitEffect::GetTailSize()
|
|||||||
&tailTime,
|
&tailTime,
|
||||||
&dataSize);
|
&dataSize);
|
||||||
|
|
||||||
return (sampleCount) (tailTime * mSampleRate);
|
return tailTime * mSampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioUnitEffect::IsReady()
|
bool AudioUnitEffect::IsReady()
|
||||||
|
@ -203,12 +203,12 @@ void ODComputeSummaryTask::Update()
|
|||||||
const auto odpcmaFile =
|
const auto odpcmaFile =
|
||||||
std::static_pointer_cast<ODPCMAliasBlockFile>(file);
|
std::static_pointer_cast<ODPCMAliasBlockFile>(file);
|
||||||
odpcmaFile->SetStart(block.start);
|
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.
|
//these will always be linear within a sequence-lets take advantage of this by keeping a cursor.
|
||||||
while(insertCursor<(int)tempBlocks.size()&&
|
while(insertCursor<(int)tempBlocks.size()&&
|
||||||
(sampleCount)(tempBlocks[insertCursor]->GetStart()+tempBlocks[insertCursor]->GetClipOffset()) <
|
tempBlocks[insertCursor]->GetStart() + tempBlocks[insertCursor]->GetClipOffset() <
|
||||||
(sampleCount)(odpcmaFile->GetStart()+odpcmaFile->GetClipOffset()))
|
odpcmaFile->GetStart() + odpcmaFile->GetClipOffset())
|
||||||
insertCursor++;
|
insertCursor++;
|
||||||
|
|
||||||
tempBlocks.insert(tempBlocks.begin() + insertCursor++, odpcmaFile);
|
tempBlocks.insert(tempBlocks.begin() + insertCursor++, odpcmaFile);
|
||||||
|
@ -159,12 +159,12 @@ void ODDecodeTask::Update()
|
|||||||
std::static_pointer_cast<ODDecodeBlockFile>(file))->GetDecodeType() == this->GetODType())
|
std::static_pointer_cast<ODDecodeBlockFile>(file))->GetDecodeType() == this->GetODType())
|
||||||
{
|
{
|
||||||
oddbFile->SetStart(block.start);
|
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.
|
//these will always be linear within a sequence-lets take advantage of this by keeping a cursor.
|
||||||
while(insertCursor<(int)tempBlocks.size()&&
|
while(insertCursor<(int)tempBlocks.size()&&
|
||||||
(sampleCount)(tempBlocks[insertCursor]->GetStart()+tempBlocks[insertCursor]->GetClipOffset()) <
|
tempBlocks[insertCursor]->GetStart() + tempBlocks[insertCursor]->GetClipOffset() <
|
||||||
(sampleCount)((oddbFile->GetStart()+oddbFile->GetClipOffset())))
|
oddbFile->GetStart() + oddbFile->GetClipOffset())
|
||||||
insertCursor++;
|
insertCursor++;
|
||||||
|
|
||||||
tempBlocks.insert(tempBlocks.begin()+insertCursor++, oddbFile);
|
tempBlocks.insert(tempBlocks.begin()+insertCursor++, oddbFile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user