Normalisable filter range lambda example


#1

Hi all. Here is a Normalisable filter range I’ve made, copying a hardware synth I have, well, best guesses anyway. I hope it helps with lambda coding for someone. The last missing function is the snapToLegalValue, which I don’t need with this range. I don’t think I do anyway… :slight_smile:

	NormalisableRange<float> filterNorm(50.0f, 20000.0f,
			[](float currentRangeStart,  float currentRangeEnd,  float normalisedValue)
			{
				// From 0-1...
				float v  = currentRangeStart * std::expf(normalisedValue *std::logf(currentRangeEnd/currentRangeStart));
				return v;
			},

			[](float currentRangeStart, float currentRangeEnd, float mappedValue)
			{
				// To 0-1...
				float v = std::logf(mappedValue/currentRangeStart)/std::logf(currentRangeEnd/currentRangeStart);
				return v;
			}
            // snapToLegalValue...
		);