Explicit type casts when moving from double to int
This commit is contained in:
@@ -239,6 +239,11 @@ protected:
|
||||
double msToSamples(double a) { return (a * mSamplingRate) / 1000.0; }
|
||||
double secondsToSamples(double a) { return a * mSamplingRate; }
|
||||
|
||||
// Convenience methods for moving from double to int values
|
||||
|
||||
long roundToInt(double a) { return static_cast<long>(round(a)); }
|
||||
unsigned long roundToUInt(double a) { return static_cast<unsigned long>(round(a)); }
|
||||
|
||||
private:
|
||||
|
||||
// Queueable Reset
|
||||
|
||||
@@ -73,7 +73,7 @@ unsigned long FrameLib_Gaussian::getLength()
|
||||
case kSeconds: time = secondsToSamples(time); break;
|
||||
}
|
||||
|
||||
return round(time);
|
||||
return roundToUInt(time);
|
||||
}
|
||||
|
||||
// Process
|
||||
|
||||
@@ -79,7 +79,7 @@ unsigned long FrameLib_Ramp::getLength()
|
||||
case kScaleSeconds: time = secondsToSamples(time); break;
|
||||
}
|
||||
|
||||
return round(time);
|
||||
return roundToUInt(time);
|
||||
}
|
||||
|
||||
// Process
|
||||
|
||||
@@ -70,7 +70,7 @@ unsigned long FrameLib_Random::getLength()
|
||||
case kSeconds: time = secondsToSamples(time); break;
|
||||
}
|
||||
|
||||
return round(time);
|
||||
return roundToUInt(time);
|
||||
}
|
||||
|
||||
// Process
|
||||
|
||||
@@ -75,7 +75,7 @@ unsigned long FrameLib_Uniform::getLength()
|
||||
case kSeconds: time = secondsToSamples(time); break;
|
||||
}
|
||||
|
||||
return round(time);
|
||||
return roundToUInt(time);
|
||||
}
|
||||
|
||||
// Process
|
||||
|
||||
@@ -71,7 +71,7 @@ unsigned long FrameLib_Sink::convertTimeToSamples(double time)
|
||||
case kSeconds: time = secondsToSamples(time); break;
|
||||
}
|
||||
|
||||
return round(time);
|
||||
return roundToUInt(time);
|
||||
}
|
||||
|
||||
void FrameLib_Sink::copyAndZero(double *output, unsigned long offset, unsigned long size)
|
||||
@@ -133,7 +133,7 @@ void FrameLib_Sink::process()
|
||||
|
||||
// Calculate time offset
|
||||
|
||||
unsigned long offset = round(delayTime + frameTime - blockStartTime);
|
||||
unsigned long offset = roundToUInt(delayTime + frameTime - blockStartTime);
|
||||
|
||||
// Safety
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ unsigned long FrameLib_Source::convertTimeToSamples(double time)
|
||||
case kSeconds: time = secondsToSamples(time); break;
|
||||
}
|
||||
|
||||
return round(time);
|
||||
return roundToUInt(time);
|
||||
}
|
||||
|
||||
void FrameLib_Source::copy(const double *input, unsigned long offset, unsigned long size)
|
||||
|
||||
@@ -91,7 +91,7 @@ unsigned long FrameLib_Trace::convertTimeToSamples(double time)
|
||||
case kSeconds: time = secondsToSamples(time); break;
|
||||
}
|
||||
|
||||
return round(time);
|
||||
return roundToUInt(time);
|
||||
}
|
||||
|
||||
void FrameLib_Trace::copyAndZero(double *output, unsigned long offset, unsigned long size)
|
||||
@@ -168,7 +168,7 @@ void FrameLib_Trace::process()
|
||||
|
||||
// Calculate time offset
|
||||
|
||||
unsigned long offset = round(delayTime + frameTime - getBlockStartTime());
|
||||
unsigned long offset = roundToUInt(delayTime + frameTime - getBlockStartTime());
|
||||
|
||||
// Safety
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ FrameLib_Pack::FrameLib_Pack(FrameLib_Context context, FrameLib_Parameters::Seri
|
||||
mParameters.addInt(0, "inputs", 2, 0 );
|
||||
mParameters.setInstantiation();
|
||||
mParameters.set(serialisedParameters);
|
||||
setIO(mParameters.getValue(kInputs), 1);
|
||||
setIO(mParameters.getInt(kInputs), 1);
|
||||
|
||||
mSerialisedParameters.write(serialisedParameters);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ FrameLib_Unpack::FrameLib_Unpack(FrameLib_Context context, FrameLib_Parameters::
|
||||
mParameters.addInt(kOutputs, "outputs", 2, 0);
|
||||
mParameters.setInstantiation();
|
||||
mParameters.set(serialisedParameters);
|
||||
setIO(1, mParameters.getValue(kOutputs));
|
||||
setIO(1, mParameters.getInt(kOutputs));
|
||||
|
||||
mSerialisedParameters.write(serialisedParameters);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ void FrameLib_Ticks::process()
|
||||
{
|
||||
unsigned long sizeOut;
|
||||
double *output = getOutput(0, &sizeOut);
|
||||
unsigned long currentLimit = mParameters.getValue(kLimit);
|
||||
unsigned long currentValue = mParameters.getValue(kSetValue);
|
||||
unsigned long currentLimit = mParameters.getInt(kLimit);
|
||||
unsigned long currentValue = mParameters.getInt(kSetValue);
|
||||
|
||||
switch (mode_run)
|
||||
{
|
||||
|
||||
@@ -73,7 +73,7 @@ void FrameLib_Chop::process()
|
||||
if (units == kSamples)
|
||||
chop = mParameters.getInt(kSize);
|
||||
else
|
||||
chop = round(mParameters.getValue(kSize) * sizeIn);
|
||||
chop = roundToUInt(mParameters.getValue(kSize) * sizeIn);
|
||||
|
||||
for (i = 0, sizeCalc = sizeIn; i < mNumOuts; i++)
|
||||
{
|
||||
|
||||
@@ -77,8 +77,8 @@ void FrameLib_Pad::process()
|
||||
}
|
||||
else
|
||||
{
|
||||
padStart = round(mParameters.getValue(kStart) * sizeIn);
|
||||
padEnd = round(mParameters.getValue(kEnd) * sizeIn);
|
||||
padStart = roundToUInt(mParameters.getValue(kStart) * sizeIn);
|
||||
padEnd = roundToUInt(mParameters.getValue(kEnd) * sizeIn);
|
||||
}
|
||||
|
||||
requestOutputSize(0, padStart + sizeIn + padEnd);
|
||||
|
||||
@@ -79,7 +79,7 @@ void FrameLib_Shift::process()
|
||||
if (units == kSamples)
|
||||
shift = mParameters.getInt(kShift);
|
||||
else
|
||||
shift = round(mParameters.getValue(kShift) * sizeIn);
|
||||
shift = roundToInt(mParameters.getValue(kShift) * sizeIn);
|
||||
|
||||
unsigned long absShift = std::abs(shift);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ void FrameLib_Split::process()
|
||||
if (units == kSamples)
|
||||
split = mParameters.getInt(kSplit);
|
||||
else
|
||||
split = round(mParameters.getValue(kSplit) * sizeIn);
|
||||
split = roundToUInt(mParameters.getValue(kSplit) * sizeIn);
|
||||
|
||||
split = split > sizeIn ? sizeIn : split;
|
||||
|
||||
|
||||
@@ -72,8 +72,8 @@ void FrameLib_Subframe::process()
|
||||
}
|
||||
else
|
||||
{
|
||||
start = round(mParameters.getValue(kStart) * sizeIn);
|
||||
end = round(mParameters.getValue(kEnd) * sizeIn);
|
||||
start = roundToUInt(mParameters.getValue(kStart) * sizeIn);
|
||||
end = roundToUInt(mParameters.getValue(kEnd) * sizeIn);
|
||||
}
|
||||
|
||||
start = start > sizeIn ? sizeIn : start;
|
||||
|
||||
Reference in New Issue
Block a user