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.
-
RangeLogallows 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. -
RangeSymmSkewallows 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). -
SnapperSigFiguresallows snapping to significant figures instead of intervals -
SnapperIntervalsallows completely arbitrary snapping by passing an array ofSnapperIntervalfor different sub-ranges -
RangeSkewedandSnapperIntervalare 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()andget_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!
(The code also assumes the juce header has been included already).
