SoundFontInfoLib
2.21.6
Library for parsing and rendering SF2 files
|
Collection of general-purpose constants and routines involved in audio rendering. More...
Namespaces | |
Interpolation | |
Tables | |
Namespace for compile-time generated tables. | |
Functions | |
Float | centsToSeconds (Float value) |
Convert cents value into seconds, where There are 1200 cents per power of 2. More... | |
Float | centsToPower2 (Float value) |
Convert cents value into a power of 2. More... | |
Float | absoluteCentsToFrequency (Float value) |
Convert cents to frequency, with 0 being 8.175798 Hz. More... | |
Float | centibelsToAttenuation (Float centibels) |
Convert centiBels to attenuation, where 60 corresponds to a drop of 6dB or 0.5 reduction of audio samples. More... | |
Float | clampFilterCutoff (Float value) |
Restrict lowpass filter cutoff value to be between 1500 and 13500, inclusive. More... | |
Float | tenthPercentage (Float value) |
Convert integer from integer [0-1000] into [0.0-1.0]. More... | |
Float | unipolarToBipolar (Float modulator) |
Translate value in range [0, +1] into one in range [-1, +1]. More... | |
Float | bipolarToUnipolar (Float modulator) |
Translate value in range [-1, +1] into one in range [0, +1]. More... | |
Float | unipolarModulate (Float modulator, Float minValue, Float maxValue) |
Perform linear translation from a value in range [0.0, 1.0] into one in [minValue, maxValue]. More... | |
Float | bipolarModulate (Float modulator, Float minValue, Float maxValue) |
Perform linear translation from a value in range [-1.0, 1.0] into one in [minValue, maxValue]. More... | |
constexpr Float | parabolicSine (Float angle) |
Estimate sin() value from a radian angle between -PI and PI. More... | |
void | panLookup (Float pan, Float &left, Float &right) |
Calculate the amount of left and right signal gain in [0.0-1.0] for the given pan value which is in range [-500-+500]. More... | |
Float | sineLookup (Float radians) |
Obtain approximate sine value from table. More... | |
Float | centsToFrequencyMultiplier (int cent) |
Convert given cents value into a frequency multiplier. More... | |
Float | centsToFrequency (Float value) |
Quickly convert cent value into a frequency using a table lookup. More... | |
Float | centibelsToAttenuation (int centibels) |
Convert centibels [0-1441] into an attenuation value from [1.0-0.0]. More... | |
Float | centibelsToGain (Float centibels) |
Convert centibels [0-1441] into a gain value [0.0-1.0]. More... | |
Variables | |
constexpr Float | PI = M_PI |
constexpr Float | TwoPI = 2.0 * PI |
constexpr Float | HalfPI = PI / 2.0 |
constexpr Float | QuarterPI = PI / 4.0 |
constexpr Float | ReferenceNoteFrequency = 440.0 |
constexpr Float | ReferenceNoteMIDI = 69.0 |
constexpr Float | ReferenceNoteSemi = ReferenceNoteMIDI * 100 |
constexpr int | CentsPerSemitone = 100 |
constexpr int | SemitonePerOctave = 12 |
constexpr int | CentsPerOctave = 1200 |
constexpr Float | CentibelsPerDecade = 200.0 |
constexpr Float | CentsToFrequencyMin = -16000 |
constexpr Float | CentsToFrequencyMax = 4500 |
constexpr Float | LowestNoteFrequency = 8.17579891564370697665253828745335 |
constexpr Float | HalfSquareRoot2 = M_SQRT2 / 2.0 |
constexpr Float | InterNoteMultiplier = 1.05946309435929530984310531493975 |
Collection of general-purpose constants and routines involved in audio rendering.
Convert cents to frequency, with 0 being 8.175798 Hz.
Values are clamped to [-16000, 4500].
value | the value to convert |
References CentsToFrequencyMax, CentsToFrequencyMin, centsToPower2(), ReferenceNoteFrequency, and ReferenceNoteSemi.
Perform linear translation from a value in range [-1.0, 1.0] into one in [minValue, maxValue].
modulator | the value to translate |
minValue | the lowest value to return when modulator is -1 |
maxValue | the highest value to return when modulator is +1 |
Translate value in range [-1, +1] into one in range [0, +1].
modulator | the value to translate |
Convert centiBels to attenuation, where 60 corresponds to a drop of 6dB or 0.5 reduction of audio samples.
Note that for raw generator values in an SF2 file, better to use the centibelsToAttenuation(int) value below.
centibels | the value to convert |
References CentibelsPerDecade.
|
inline |
Convert centibels [0-1441] into an attenuation value from [1.0-0.0].
Zero indicates no attenuation (1.0), 60 is 0.5, and every 200 is a reduction by 10 (0.1, 0.001, etc.)
centibels | value to convert |
References SF2::DSP::Tables::AttenuationLookup::convert().
Convert centibels [0-1441] into a gain value [0.0-1.0].
This is the inverse of the above.
centibels | value to convert |
References SF2::DSP::Tables::GainLookup::convert().
Quickly convert cent value into a frequency using a table lookup.
These calculations are taken from the Fluid Synth fluid_conv.c file, in particular the fluid_ct2hz_real function. Uses CentPartialLookup above to convert values from 0 - 1199 into the proper multiplier.
References SF2::DSP::Tables::CentsPartialLookup::convert().
Referenced by SF2::Entity::Generator::Definition::convertedValueOf().
|
inline |
Convert given cents value into a frequency multiplier.
cent | the value to convert |
References SF2::DSP::Tables::CentsFrequencyLookup::convert().
Convert cents value into a power of 2.
There are 1200 cents per power of 2.
value | the value to convert |
References CentsPerOctave.
Referenced by absoluteCentsToFrequency().
Convert cents value into seconds, where There are 1200 cents per power of 2.
value | the number to convert |
Referenced by SF2::Entity::Generator::Definition::convertedValueOf(), SF2::Render::Envelope::Generator::Modulator(), and SF2::Render::Envelope::Generator::Volume().
Restrict lowpass filter cutoff value to be between 1500 and 13500, inclusive.
value | cutoff value |
Calculate the amount of left and right signal gain in [0.0-1.0] for the given pan
value which is in range [-500-+500].
A pan
of -500 is only left, and +500 is only right. A pan
of 0 should result in ~0.7078 for both.
pan | the value to convert |
left | reference to storage for the left gain |
right | reference to storage for the right gain |
References SF2::DSP::Tables::PanLookup::lookup().
Estimate sin() value from a radian angle between -PI and PI.
Derived from code in "Designing Audio Effect Plugins in C++" by Will C. Pirkle (2019) As can be seen in the unit test testParabolicSineAccuracy
, the worst-case deviation from std::sin is ~0.0011.
angle | value between -PI and PI |
Obtain approximate sine value from table.
radians | the value to use for theta |
References SF2::DSP::Tables::SineLookup::sine().
Convert integer from integer [0-1000] into [0.0-1.0].
value | percentage value expressed as tenths |
Perform linear translation from a value in range [0.0, 1.0] into one in [minValue, maxValue].
modulator | the value to translate |
minValue | the lowest value to return when modulator is 0 |
maxValue | the highest value to return when modulator is +1 |
Translate value in range [0, +1] into one in range [-1, +1].
modulator | the value to translate |
Referenced by SF2::DSP::Tables::Generator::generateTransform().
|
inlineconstexpr |
Referenced by centibelsToAttenuation().
|
inlineconstexpr |
Referenced by centsToPower2().
|
inlineconstexpr |
|
inlineconstexpr |
Referenced by absoluteCentsToFrequency().
|
inlineconstexpr |
Referenced by absoluteCentsToFrequency().
Referenced by SF2::DSP::Tables::SineLookup::sine().
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Referenced by SF2::DSP::Tables::SineLookup::sine().
|
inlineconstexpr |
Referenced by absoluteCentsToFrequency().
|
inlineconstexpr |
|
inlineconstexpr |
Referenced by absoluteCentsToFrequency().
|
inlineconstexpr |
Referenced by SF2::DSP::Tables::SineLookup::sine().