You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just make sound in the FoleysSynth example in Plugin GUI Magic: https://github.com/ffAudio/foleys_gui_magic
The first sinusoid sample has phase -pi which becomes minInputValue (float) -3.14159274, and this is too negative.
It's basically just normal roundoff error in single-precision floating-point, but it leads to the index -0.00000620965511,
which triggers an assertion failure. Here is my workaround (fix?):
diff --git a/modules/juce_dsp/maths/juce_LookupTable.h b/modules/juce_dsp/maths/juce_LookupTable.h
index d4b455b1f..0580fcb93 100644
--- a/modules/juce_dsp/maths/juce_LookupTable.h
+++ b/modules/juce_dsp/maths/juce_LookupTable.h
@@ -231,7 +231,9 @@ public:
FloatType processSampleUnchecked (FloatType value) const noexcept
{
jassert (value >= minInputValue && value <= maxInputValue);
- return lookupTable[scaler * value + offset];
+ auto index = scaler * value + offset;
+ int roundedIndex = static_cast<int>(std::round(index));
+ return lookupTable[roundedIndex];
}
//==============================================================================
@@ -248,12 +250,15 @@ public:
@see processSampleUnchecked, operator(), operator[]
*/
+
FloatType processSample (FloatType value) const noexcept
{
- auto index = scaler * jlimit (minInputValue, maxInputValue, value) + offset;
- jassert (isPositiveAndBelow (index, FloatType (lookupTable.getNumPoints())));
-
- return lookupTable[index];
+ jassert (value >= minInputValue && value <= maxInputValue);
+ auto index = scaler * value + offset;
+ int roundedIndex = static_cast<int>(std::round(index));
+ int limitedIndex = jlimit<int>(0, int(lookupTable.getNumPoints()) - 1, roundedIndex);
+ jassert(roundedIndex == limitedIndex);
+ return lookupTable[limitedIndex];
}
What is the expected behaviour?
It should be impossible to access addresses outside of the LookupTable input range. They should clip.
Detailed steps on how to reproduce the bug
Just make sound in the FoleysSynth example in Plugin GUI Magic: https://github.com/ffAudio/foleys_gui_magic
The first sinusoid sample has phase -pi which becomes minInputValue (float) -3.14159274, and this is too negative.
It's basically just normal roundoff error in single-precision floating-point, but it leads to the index -0.00000620965511,
which triggers an assertion failure. Here is my workaround (fix?):
What is the expected behaviour?
It should be impossible to access addresses outside of the LookupTable input range. They should clip.
Operating systems
macOS
What versions of the operating systems?
Mac OS Sonoma 14.2.1
Architectures
ARM
Stacktrace
Plug-in formats (if applicable)
Standalone
Plug-in host applications (DAWs) (if applicable)
No response
Testing on the
develop
branchThe bug is present on the
develop
branchCode of Conduct
The text was updated successfully, but these errors were encountered: