Gin
Loading...
Searching...
No Matches
Files | Namespaces | Classes | Functions
utilities

Files

file  gin_easing.h
 Collection of easing functions for animation and interpolation.
 

Namespaces

namespace  Diff
 Binary diff/patch utilities using the bsdiff algorithm.
 
namespace  Lagrange
 Lagrange interpolation functions for obtaining smooth curves from discrete points.
 

Classes

class  DownloadManager
 Asynchronous HTTP download manager with queue and progress tracking. More...
 
struct  DownloadManager::DownloadResult
 Result of a completed or failed download. More...
 
class  EquationParser
 Mathematical equation parser and evaluator with variable and function support. More...
 
class  FileSystemWatcher
 Cross-platform file system watcher for monitoring folder changes. More...
 
class  FileSystemWatcher::Listener
 Listener interface for receiving file system change notifications. More...
 
class  Integrator
 Numerical integration using the trapezoidal rule for discrete data points. More...
 
class  LeastSquaresRegression
 Performs least squares regression to fit a quadratic curve to data points. More...
 
class  LinearRegression
 Performs linear regression to fit a straight line to data points. More...
 
class  LockFreeQueue< T >
 A lock-free FIFO queue for single-producer, single-consumer scenarios. More...
 
class  MessagePack
 Converts between MessagePack binary format and juce::var. More...
 
class  Point< T >
 A lightweight 2D point class for projects that don't use juce_graphics. More...
 
class  RealtimeAsyncUpdater
 An asynchronous update dispatcher that bypasses the message queue. More...
 
class  RealtimeEvent
 A realtime-safe event synchronization primitive for cross-thread signaling. More...
 
class  RIFFParser
 Parses RIFF (Resource Interchange File Format) files. More...
 
class  SharedMemory
 Creates a block of shared memory. More...
 
class  Spline
 Cubic spline interpolation for smooth curves through discrete data points. More...
 
class  Spline::Element
 
class  SystemSemaphore
 A system-wide semaphore for inter-process synchronization. More...
 
class  TextHistory
 Undo/redo history management for text editing with efficient diff-based storage. More...
 
class  PerlinNoise< T >
 Generates Perlin noise - a type of gradient noise with natural-looking characteristics. More...
 
class  RollingAverage
 Maintains a rolling average of a series of numbers. More...
 
class  TimeProfiler
 A simple RAII-based time profiler for measuring execution duration. More...
 
class  ValueTreeObject
 Maintains an object hierarchy that mirrors a ValueTree structure. More...
 
class  LambdaValueTreeListener
 Listens to ValueTree changes using lambda functions instead of virtual methods. More...
 
class  AsyncLambdaValueTreeListener
 Asynchronous ValueTree listener using lambda functions. More...
 

Functions

template<class T >
easeLinear (T p)
 Linear interpolation with no easing.
 
template<class T >
easeQuadraticIn (T p)
 Quadratic easing in - accelerating from zero velocity.
 
template<class T >
easeQuadraticOut (T p)
 Quadratic easing out - decelerating to zero velocity.
 
template<class T >
easeQuadraticInOut (T p)
 Quadratic easing in/out - acceleration until halfway, then deceleration.
 
template<class T >
easeCubicIn (T p)
 Cubic easing in - accelerating from zero velocity.
 
template<class T >
easeCubicOut (T p)
 Cubic easing out - decelerating to zero velocity.
 
template<class T >
easeCubicInOut (T p)
 Cubic easing in/out - acceleration until halfway, then deceleration.
 
template<class T >
easeQuarticIn (T p)
 Quartic easing in - accelerating from zero velocity.
 
template<class T >
easeQuarticOut (T p)
 Quartic easing out - decelerating to zero velocity.
 
template<class T >
easeQuarticInOut (T p)
 Quartic easing in/out - acceleration until halfway, then deceleration.
 
template<class T >
easeQuinticIn (T p)
 Quintic easing in - accelerating from zero velocity.
 
template<class T >
easeQuinticOut (T p)
 Quintic easing out - decelerating to zero velocity.
 
template<class T >
easeQuinticInOut (T p)
 Quintic easing in/out - acceleration until halfway, then deceleration.
 
template<class T >
easeSineIn (T p)
 Sine easing in - accelerating from zero velocity.
 
template<class T >
easeSineOut (T p)
 Sine easing out - decelerating to zero velocity.
 
template<class T >
easeSineInOut (T p)
 Sine easing in/out - acceleration until halfway, then deceleration.
 
template<class T >
easeCircularIn (T p)
 Circular easing in - accelerating from zero velocity.
 
template<class T >
easeCircularOut (T p)
 Circular easing out - decelerating to zero velocity.
 
template<class T >
easeCircularInOut (T p)
 Circular easing in/out - acceleration until halfway, then deceleration.
 
template<class T >
easeExponentialIn (T p)
 Exponential easing in - accelerating from zero velocity.
 
template<class T >
easeExponentialOut (T p)
 Exponential easing out - decelerating to zero velocity.
 
template<class T >
easeExponentialInOut (T p)
 Exponential easing in/out - acceleration until halfway, then deceleration.
 
template<class T >
easeElasticIn (T p)
 Elastic easing in - accelerating with oscillation.
 
template<class T >
easeElasticOut (T p)
 Elastic easing out - decelerating with oscillation.
 
template<class T >
easeElasticInOut (T p)
 Elastic easing in/out - acceleration and deceleration with oscillation.
 
template<class T >
easeBackIn (T p)
 Back easing in - accelerating with slight overshoot.
 
template<class T >
easeBackOut (T p)
 Back easing out - decelerating with overshoot.
 
template<class T >
easeBackInOut (T p)
 Back easing in/out - acceleration and deceleration with overshoot.
 
template<class T >
easeBounceOut (T p)
 Bounce easing out - decelerating with bounce effect.
 
template<class T >
easeBounceIn (T p)
 Bounce easing in - accelerating with bounce effect.
 
template<class T >
easeBounceInOut (T p)
 Bounce easing in/out - bouncing at both ends.
 
bool overwriteWithText (const juce::File &f, const juce::String &text, bool asUnicode=false, bool writeUnicodeHeaderBytes=false, const char *lineEndings=nullptr)
 Overwrites a file with text content in a single atomic operation.
 
bool overwriteWithData (const juce::File &f, const juce::MemoryBlock &data)
 Overwrites a file with binary data in a single atomic operation.
 
bool overwriteWithData (const juce::File &f, const void *data, size_t size)
 Overwrites a file with binary data in a single atomic operation.
 
juce::var parsePlist (const juce::File &f)
 Parses an Apple Property List (plist) file and returns its contents as a juce::var.
 
juce::var parsePlist (const juce::String &s)
 Parses an Apple Property List (plist) from a string and returns its contents.
 
juce::var parsePlist (const juce::XmlElement &f)
 Parses an Apple Property List (plist) from XML and returns its contents.
 
int getWavetableSize (const juce::MemoryBlock &m)
 Extracts wavetable size from a RIFF file in memory.
 
int getWavetableSize (const juce::File &f)
 Extracts wavetable size from a RIFF file.
 
void callInBackground (std::function< void(void)> function)
 Executes a function on a background thread.
 
template<typename T >
void multiThreadedFor (T start, T end, T interval, juce::ThreadPool *threadPool, std::function< void(T idx)> callback)
 Executes a for loop in parallel across multiple threads.
 
bool compareAndReset (bool &flag)
 Checks if a boolean flag is set, and if so, clears it and returns true.
 
float calculateRMS (const float *values, int n)
 Calculates the Root Mean Square (RMS) of an array of values.
 
float calculateMedian (const float *values, int n)
 Calculates the median value of an array of values.
 
template<typename T >
void shuffleArray (juce::Random &r, T &array)
 Randomly shuffles the elements of an array using the Fisher-Yates algorithm.
 
int versionStringToInt (const juce::String &versionString)
 Converts a version string to an integer for comparison purposes.
 
void delayedLambda (std::function< void()> callback, int delayMS)
 Executes a lambda function after a specified delay.
 
template<typename T >
juce::String formatNumber (T v)
 Formats a number as a string with appropriate decimal precision.
 
juce::String valueTreeToJSON (const juce::ValueTree &v)
 Converts a ValueTree to a JSON string representation.
 
juce::ValueTree valueTreeFromJSON (const juce::String &jsonText)
 Parses a JSON string and creates a ValueTree from it.
 

Detailed Description

Function Documentation

◆ easeLinear()

template<class T >
T easeLinear ( p)

Linear interpolation with no easing.

Modeled after the line y = x. Provides constant velocity with no acceleration or deceleration.

Parameters
pNormalized time value [0, 1]
Returns
Linearly interpolated value [0, 1]

Referenced by LinearEasing::ease().

◆ easeQuadraticIn()

template<class T >
T easeQuadraticIn ( p)

Quadratic easing in - accelerating from zero velocity.

Modeled after the parabola y = x^2. Starts slowly and accelerates.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by QuadraticInEasing::ease(), and ModMatrix::shape().

◆ easeQuadraticOut()

template<class T >
T easeQuadraticOut ( p)

Quadratic easing out - decelerating to zero velocity.

Modeled after the parabola y = -x^2 + 2x. Starts quickly and decelerates.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by QuadraticOutEasing::ease(), and ModMatrix::shape().

◆ easeQuadraticInOut()

template<class T >
T easeQuadraticInOut ( p)

Quadratic easing in/out - acceleration until halfway, then deceleration.

Modeled after the piecewise quadratic:

  • y = (1/2)((2x)^2) for [0, 0.5)
  • y = -(1/2)((2x-1)*(2x-3) - 1) for [0.5, 1]
Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by QuadraticInOutEasing::ease(), and ModMatrix::shape().

◆ easeCubicIn()

template<class T >
T easeCubicIn ( p)

Cubic easing in - accelerating from zero velocity.

Modeled after the cubic y = x^3. Provides smoother acceleration than quadratic.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by CubicInEasing::ease().

◆ easeCubicOut()

template<class T >
T easeCubicOut ( p)

Cubic easing out - decelerating to zero velocity.

Modeled after the cubic y = (x - 1)^3 + 1. Provides smoother deceleration than quadratic.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by CubicOutEasing::ease().

◆ easeCubicInOut()

template<class T >
T easeCubicInOut ( p)

Cubic easing in/out - acceleration until halfway, then deceleration.

Modeled after the piecewise cubic:

  • y = (1/2)((2x)^3) for [0, 0.5)
  • y = (1/2)((2x-2)^3 + 2) for [0.5, 1]
Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by CubicInOutEasing::ease().

◆ easeQuarticIn()

template<class T >
T easeQuarticIn ( p)

Quartic easing in - accelerating from zero velocity.

Modeled after the quartic x^4. More pronounced acceleration than cubic.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by QuarticInEasing::ease().

◆ easeQuarticOut()

template<class T >
T easeQuarticOut ( p)

Quartic easing out - decelerating to zero velocity.

Modeled after the quartic y = 1 - (x - 1)^4. More pronounced deceleration than cubic.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by QuarticOutEasing::ease().

◆ easeQuarticInOut()

template<class T >
T easeQuarticInOut ( p)

Quartic easing in/out - acceleration until halfway, then deceleration.

Modeled after the piecewise quartic:

  • y = (1/2)((2x)^4) for [0, 0.5)
  • y = -(1/2)((2x-2)^4 - 2) for [0.5, 1]
Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by QuarticInOutEasing::ease().

◆ easeQuinticIn()

template<class T >
T easeQuinticIn ( p)

Quintic easing in - accelerating from zero velocity.

Modeled after the quintic y = x^5. Very pronounced acceleration.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by QuinticInEasing::ease().

◆ easeQuinticOut()

template<class T >
T easeQuinticOut ( p)

Quintic easing out - decelerating to zero velocity.

Modeled after the quintic y = (x - 1)^5 + 1. Very pronounced deceleration.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by QuinticOutEasing::ease().

◆ easeQuinticInOut()

template<class T >
T easeQuinticInOut ( p)

Quintic easing in/out - acceleration until halfway, then deceleration.

Modeled after the piecewise quintic:

  • y = (1/2)((2x)^5) for [0, 0.5)
  • y = (1/2)((2x-2)^5 + 2) for [0.5, 1]
Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by QuinticInOutEasing::ease().

◆ easeSineIn()

template<class T >
T easeSineIn ( p)

Sine easing in - accelerating from zero velocity.

Modeled after a quarter-cycle of a sine wave. Provides smooth, gradual acceleration.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by SineInEasing::ease(), and ModMatrix::shape().

◆ easeSineOut()

template<class T >
T easeSineOut ( p)

Sine easing out - decelerating to zero velocity.

Modeled after a quarter-cycle of a sine wave (different phase). Provides smooth, gradual deceleration.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by SineOutEasing::ease(), and ModMatrix::shape().

◆ easeSineInOut()

template<class T >
T easeSineInOut ( p)

Sine easing in/out - acceleration until halfway, then deceleration.

Modeled after a half sine wave. Provides smooth, natural motion.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by SineInOutEasing::ease(), and ModMatrix::shape().

◆ easeCircularIn()

template<class T >
T easeCircularIn ( p)

Circular easing in - accelerating from zero velocity.

Modeled after a shifted quadrant IV of a unit circle. Creates a gentle curve that accelerates more smoothly than polynomial easings.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by CircularInEasing::ease().

◆ easeCircularOut()

template<class T >
T easeCircularOut ( p)

Circular easing out - decelerating to zero velocity.

Modeled after a shifted quadrant II of a unit circle. Creates a gentle curve that decelerates more smoothly than polynomial easings.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by CircularOutEasing::ease().

◆ easeCircularInOut()

template<class T >
T easeCircularInOut ( p)

Circular easing in/out - acceleration until halfway, then deceleration.

Modeled after the piecewise circular function:

  • y = (1/2)(1 - sqrt(1 - 4x^2)) for [0, 0.5)
  • y = (1/2)(sqrt(-(2x - 3)*(2x - 1)) + 1) for [0.5, 1]
Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by CircularInOutEasing::ease().

◆ easeExponentialIn()

template<class T >
T easeExponentialIn ( p)

Exponential easing in - accelerating from zero velocity.

Modeled after the exponential function y = 2^(10(x - 1)). Creates a very sharp, dramatic acceleration curve.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by ExponentialInEasing::ease(), and ModMatrix::shape().

◆ easeExponentialOut()

template<class T >
T easeExponentialOut ( p)

Exponential easing out - decelerating to zero velocity.

Modeled after the exponential function y = -2^(-10x) + 1. Creates a very sharp, dramatic deceleration curve.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by ExponentialOutEasing::ease(), and ModMatrix::shape().

◆ easeExponentialInOut()

template<class T >
T easeExponentialInOut ( p)

Exponential easing in/out - acceleration until halfway, then deceleration.

Modeled after the piecewise exponential:

  • y = (1/2)2^(10(2x - 1)) for [0, 0.5)
  • y = -(1/2)*2^(-10(2x - 1))) + 1 for [0.5, 1]
Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1]

Referenced by ExponentialInOutEasing::ease(), and ModMatrix::shape().

◆ easeElasticIn()

template<class T >
T easeElasticIn ( p)

Elastic easing in - accelerating with oscillation.

Modeled after a damped sine wave y = sin(13pi/2*x)*pow(2, 10 * (x - 1)). Creates an elastic, spring-like effect that overshoots and oscillates before settling.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1] with overshoot

Referenced by ElasticInEasing::ease().

◆ easeElasticOut()

template<class T >
T easeElasticOut ( p)

Elastic easing out - decelerating with oscillation.

Modeled after a damped sine wave y = sin(-13pi/2*(x + 1))*pow(2, -10x) + 1. Creates an elastic, spring-like effect that overshoots and oscillates before settling.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1] with overshoot

Referenced by ElasticOutEasing::ease().

◆ easeElasticInOut()

template<class T >
T easeElasticInOut ( p)

Elastic easing in/out - acceleration and deceleration with oscillation.

Modeled after a piecewise exponentially-damped sine wave:

  • y = (1/2)*sin(13pi/2*(2*x))*pow(2, 10 * ((2*x) - 1)) for [0, 0.5)
  • y = (1/2)*(sin(-13pi/2*((2x-1)+1))*pow(2,-10(2*x-1)) + 2) for [0.5, 1]
Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1] with overshoot

Referenced by ElasticInOutEasing::ease().

◆ easeBackIn()

template<class T >
T easeBackIn ( p)

Back easing in - accelerating with slight overshoot.

Modeled after the overshooting cubic y = x^3-x*sin(x*pi). Pulls back slightly before accelerating forward, creating anticipation.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1] with slight overshoot

Referenced by BackInEasing::ease().

◆ easeBackOut()

template<class T >
T easeBackOut ( p)

Back easing out - decelerating with overshoot.

Modeled after overshooting cubic y = 1-((1-x)^3-(1-x)*sin((1-x)*pi)). Overshoots the target slightly before settling back.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1] with overshoot

Referenced by BackOutEasing::ease().

◆ easeBackInOut()

template<class T >
T easeBackInOut ( p)

Back easing in/out - acceleration and deceleration with overshoot.

Modeled after the piecewise overshooting cubic function:

  • y = (1/2)*((2x)^3-(2x)*sin(2*x*pi)) for [0, 0.5)
  • y = (1/2)*(1-((1-x)^3-(1-x)*sin((1-x)*pi))+1) for [0.5, 1]
Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1] with overshoot

Referenced by BackInOutEasing::ease().

◆ easeBounceOut()

template<class T >
T easeBounceOut ( p)

Bounce easing out - decelerating with bounce effect.

Simulates a bouncing motion with decreasing amplitude, like a ball bouncing and coming to rest. Uses piecewise parabolic segments to create the bounce effect.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1] with bouncing

Referenced by BounceOutEasing::ease(), easeBounceIn(), and easeBounceInOut().

◆ easeBounceIn()

template<class T >
T easeBounceIn ( p)

Bounce easing in - accelerating with bounce effect.

The inverse of easeBounceOut. Creates a bouncing motion at the start before accelerating to the final value.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1] with bouncing

References easeBounceOut().

Referenced by BounceInEasing::ease(), and easeBounceInOut().

◆ easeBounceInOut()

template<class T >
T easeBounceInOut ( p)

Bounce easing in/out - bouncing at both ends.

Combines bounce in and bounce out, creating a bouncing effect at both the start and end of the transition.

Parameters
pNormalized time value [0, 1]
Returns
Eased value [0, 1] with bouncing

References easeBounceIn(), and easeBounceOut().

Referenced by BounceInOutEasing::ease().

◆ overwriteWithText()

bool overwriteWithText ( const juce::File &  f,
const juce::String &  text,
bool  asUnicode = false,
bool  writeUnicodeHeaderBytes = false,
const char lineEndings = nullptr 
)

Overwrites a file with text content in a single atomic operation.

Unlike juce::File::replaceWithText(), this function writes directly to the target file without creating a temporary file first. This is faster but provides less safety if the write operation fails partway through.

Parameters
fThe file to overwrite
textThe text content to write
asUnicodeIf true, writes as UTF-16, otherwise as UTF-8
writeUnicodeHeaderBytesIf true and asUnicode is true, writes a BOM (byte order mark)
lineEndingsThe line ending style to use (nullptr for platform default)
Returns
true if the operation succeeded, false otherwise

◆ overwriteWithData() [1/2]

bool overwriteWithData ( const juce::File &  f,
const juce::MemoryBlock &  data 
)

Overwrites a file with binary data in a single atomic operation.

Unlike juce::File::replaceWithData(), this function writes directly to the target file without creating a temporary file first. This is faster but provides less safety if the write operation fails partway through.

Parameters
fThe file to overwrite
dataThe memory block containing the data to write
Returns
true if the operation succeeded, false otherwise

◆ overwriteWithData() [2/2]

bool overwriteWithData ( const juce::File &  f,
const void data,
size_t  size 
)

Overwrites a file with binary data in a single atomic operation.

Unlike juce::File::replaceWithData(), this function writes directly to the target file without creating a temporary file first. This is faster but provides less safety if the write operation fails partway through.

Parameters
fThe file to overwrite
dataPointer to the data to write
sizeNumber of bytes to write
Returns
true if the operation succeeded, false otherwise

◆ parsePlist() [1/3]

juce::var parsePlist ( const juce::File &  f)

Parses an Apple Property List (plist) file and returns its contents as a juce::var.

Plist files are commonly used on macOS and iOS for storing application preferences and configuration data. Only XML plist format is supported; binary plists are not supported.

Parameters
fThe plist file to parse
Returns
A juce::var containing the parsed data structure (typically a DynamicObject)

◆ parsePlist() [2/3]

juce::var parsePlist ( const juce::String &  s)

Parses an Apple Property List (plist) from a string and returns its contents.

Parses plist data from a string containing XML-formatted plist content.

Parameters
sA string containing XML plist data
Returns
A juce::var containing the parsed data structure (typically a DynamicObject)

◆ parsePlist() [3/3]

juce::var parsePlist ( const juce::XmlElement &  f)

Parses an Apple Property List (plist) from XML and returns its contents.

Converts a parsed XML element representing a plist into a juce::var structure.

Parameters
fAn XmlElement containing the plist data
Returns
A juce::var containing the parsed data structure (typically a DynamicObject)

◆ getWavetableSize() [1/2]

int getWavetableSize ( const juce::MemoryBlock &  m)

Extracts wavetable size from a RIFF file in memory.

Searches for a "clm " chunk in the RIFF data and extracts the wavetable size from it. This is used for wavetable synthesis formats that store metadata in RIFF chunks.

Parameters
mMemoryBlock containing RIFF file data
Returns
The wavetable size in samples, or 0 if not found

Referenced by getWavetableSize().

◆ getWavetableSize() [2/2]

int getWavetableSize ( const juce::File &  f)

Extracts wavetable size from a RIFF file.

Searches for a "clm " chunk in the RIFF file and extracts the wavetable size from it. This is used for wavetable synthesis formats that store metadata in RIFF chunks.

Parameters
fThe RIFF file to read
Returns
The wavetable size in samples, or 0 if not found

References getWavetableSize().

◆ callInBackground()

void callInBackground ( std::function< void(void)>  function)

Executes a function on a background thread.

This is a convenience function for running code asynchronously without blocking the current thread. The function will be executed on a separate thread and return immediately.

Parameters
functionThe function to execute on the background thread

◆ multiThreadedFor()

template<typename T >
void multiThreadedFor ( start,
end,
interval,
juce::ThreadPool *  threadPool,
std::function< void(T idx)>  callback 
)

Executes a for loop in parallel across multiple threads.

This function distributes loop iterations across available CPU cores using a thread pool. Each thread processes a subset of iterations, with work distributed evenly. This is useful for parallelizing computationally intensive loops.

Example usage:

// Serial loop:
for (int i = 0; i < 10; i++)
// Parallel version:
multiThreadedFor<int> (0, 10, 1, threadPool, [&] (int i) {
});
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
Warning
Each iteration must be independent - there should be no dependencies between iterations or race conditions when accessing shared data.
Parameters
startThe starting index (inclusive)
endThe ending index (exclusive)
intervalThe step size between iterations
threadPoolThe thread pool to use (if nullptr, runs serially on current thread)
callbackThe function to call for each iteration, receiving the index as parameter

◆ compareAndReset()

bool compareAndReset ( bool flag)

Checks if a boolean flag is set, and if so, clears it and returns true.

This is useful for handling one-shot flags that need to be checked and reset atomically.

Parameters
flagThe boolean flag to check and reset
Returns
true if the flag was set (and has now been cleared), false if it was already clear

◆ calculateRMS()

float calculateRMS ( const float values,
int  n 
)

Calculates the Root Mean Square (RMS) of an array of values.

RMS is the square root of the mean of the squares of the values, commonly used to measure the magnitude of a varying signal.

Parameters
valuesPointer to an array of float values
nNumber of values in the array
Returns
The RMS value

◆ calculateMedian()

float calculateMedian ( const float values,
int  n 
)

Calculates the median value of an array of values.

The median is the middle value when the values are sorted. For an even number of values, it returns the average of the two middle values.

Parameters
valuesPointer to an array of float values
nNumber of values in the array
Returns
The median value

◆ shuffleArray()

template<typename T >
void shuffleArray ( juce::Random &  r,
T &  array 
)

Randomly shuffles the elements of an array using the Fisher-Yates algorithm.

This produces an unbiased random permutation where each possible ordering has equal probability of occurring.

Parameters
rReference to a juce::Random object used for generating random indices
arrayThe array to shuffle (must support size() and swap() methods)

Referenced by PerlinNoise< T >::PerlinNoise().

◆ versionStringToInt()

int versionStringToInt ( const juce::String &  versionString)

Converts a version string to an integer for comparison purposes.

Parses version strings in the format "major.minor.patch" and converts them to a single integer value that can be compared numerically.

Parameters
versionStringThe version string to convert (e.g., "1.2.3")
Returns
An integer representation of the version

◆ delayedLambda()

void delayedLambda ( std::function< void()>  callback,
int  delayMS 
)

Executes a lambda function after a specified delay.

The callback will be executed on the message thread after the specified delay. This is useful for deferred execution of code that needs to run later.

Parameters
callbackThe function to execute after the delay
delayMSThe delay in milliseconds before executing the callback

◆ formatNumber()

template<typename T >
juce::String formatNumber ( v)

Formats a number as a string with appropriate decimal precision.

Automatically chooses the number of decimal places based on the magnitude of the value:

  • Values >= 10: No decimal places (rounded to integer)
  • Values >= 1: 1 decimal place
  • Values >= 0.1: 2 decimal places
  • Values < 0.1: 3 decimal places
  • Values approximately equal to 0: Returns "0"
Parameters
vThe numeric value to format
Returns
A formatted string representation of the number

◆ valueTreeToJSON()

juce::String valueTreeToJSON ( const juce::ValueTree &  v)

Converts a ValueTree to a JSON string representation.

Serializes the entire ValueTree structure (including all properties and children) into JSON format. This is useful for saving, transmitting, or debugging ValueTree data.

Parameters
vThe ValueTree to convert
Returns
A JSON string representing the ValueTree

◆ valueTreeFromJSON()

juce::ValueTree valueTreeFromJSON ( const juce::String &  jsonText)

Parses a JSON string and creates a ValueTree from it.

The JSON must have been created by valueTreeToJSON() or follow the same format. This reconstructs the entire ValueTree structure from the JSON representation.

Parameters
jsonTextThe JSON string to parse
Returns
A ValueTree reconstructed from the JSON