Class SoundFontModulatorMath
The SoundFont 2.04 modulator transform curves (§8.2.4) and source
evaluation. A modulator's source controller value is normalised to
[0, 1], shaped by one of four curves (linear / concave / convex / switch)
in the direction and polarity selected by the source's D and
P bits, and the result drives the modulator amount.
The spec gives the concave law only "as variations of" a logarithmic equation, so these use the standard 96 dB convention: the concave curve spans the SoundFont peak-attenuation range, which makes the implicit velocity→attenuation default modulator (§8.4.1) reproduce the familiar near-square-law velocity response. The bar is musical fidelity to the spec, not sample-identity with any particular synth (the fidelity bar stated in Docs/Architecture/SamplerDesign.md). Public and static so the transforms can be unit-tested directly.
public static class SoundFontModulatorMath
- Inheritance
-
SoundFontModulatorMath
- Inherited Members
Methods
Concave(double)
The SoundFont concave curve over [0, 1]: 0 at 0, rising slowly then steeply to 1 at 1. Output is clamped to [0, 1].
public static double Concave(double x)
Parameters
xdouble
Returns
Convex(double)
The SoundFont convex curve over [0, 1]: the concave curve with its start and end points reversed (§8.2.4). Output is clamped to [0, 1].
public static double Convex(double x)
Parameters
xdouble
Returns
Curve(SourceTypeEnum, double)
Applies one of the four source-type curves to a value in [0, 1].
public static double Curve(SourceTypeEnum type, double x)
Parameters
typeSourceTypeEnumxdouble
Returns
EvaluateSource(ModulatorType, double, double)
Evaluates a modulator source: normalises raw against
max, applies the source's direction, curve and
polarity, and returns the multiplier — [0, 1] for a unipolar source,
[-1, 1] for a bipolar one. Bipolar concave/convex follow the §8.2.4
figures: zero at the controller centre, odd-symmetric to ±1 at the
extremes (matching FluidSynth's reading of the spec).
public static double EvaluateSource(ModulatorType source, double raw, double max)
Parameters
sourceModulatorTyperawdoublemaxdouble