Juce-compatible improved normalisable ranges & snappers in a single header file

I am sharing here the header file that I use to generate improved normalisable ranges for my Juce projects: Juce-compatible improved normalisable ranges - Pastebin.com

The features are:

  • All ranges are reversible.
  • RangeLog allows you to generate normalisable ranges where (for example) all powers of 10 are equidistant, that you might use for a frequency control. This is not possible with juce’s current skew implementation.
  • RangeSymmSkew allows a skewed range, but with non-centred symmetry. For example, if you have a dB control that goes from -60 to +12, you will want the range [-12,+12] to be exactly symmetrical about 0, but you might want the centre value to be -16. This is also not possible with juce’s current skew implementation (eg, if you were to set -16 as the centre value in the range [-60, +12], the sub range [-12,+12] would not be symmetrical).
  • SnapperSigFigures allows snapping to significant figures instead of intervals
  • SnapperIntervals allows completely arbitrary snapping by passing an array of SnapperInterval for different sub-ranges
  • RangeSkewed and SnapperInterval are the same as juce’s normalisable range implementation (eg if you need to combine a standard range with a non-standard snapper)
  • The short inline functions get_juce_norm_range() and get_juce_norm_ranges() allow you to create juce normalisable ranges which can then be passed to audio parameters, GUI sliders, etc

The code is probably longer than it needs to be, but hopefully someone will find this useful! It has been tested in my own projects both for audio parameters and GUI sliders, but I can’t guarantee there are no bugs! :slight_smile: (The code also assumes the juce header has been included already).

1 Like