SoundFontInfoLib
2.21.6
Library for parsing and rendering SF2 files
|
Generator state values for a rendering voice. More...
#include <State.hpp>
Public Types | |
enum | LoopingMode { none = 0 , continuously = 1 , duringKeyPress = 3 } |
These are values for the sampleModes (#54) generator. More... | |
using | Amount = Entity::Generator::Amount |
using | Index = Entity::Generator::Index |
using | Definition = Entity::Generator::Definition |
Public Member Functions | |
State (double sampleRate, const MIDI::Channel &channel, int key, int velocity) | |
Mock constructor – only used in unit tests. More... | |
State (double sampleRate, const MIDI::Channel &channel, const Setup &setup) | |
Create new state vector with a given sample rate. More... | |
void | setValue (Index index, int value) |
Set a generator value. More... | |
void | adjustValue (Index index, int value) |
Set a generator's adjustment value. More... | |
void | addModulator (const Entity::Modulator::Modulator &modulator) |
Install a modulator. More... | |
double | modulated (Index index) const |
Obtain a generator value after applying any registered modulators to it. More... | |
int | unmodulated (Index index) const |
Obtain a generator value without any modulation applied to it. More... | |
double | pitch () const |
int | key () const |
int | velocity () const |
int | eventKey () const |
int | eventVelocity () const |
double | keyedVolumeEnvelopeHold () const |
double | keyedVolumeEnvelopeDecay () const |
double | keyedModulatorEnvelopeHold () const |
double | keyedModulatorEnvelopeDecay () const |
double | sustainLevelVolumeEnvelope () const |
double | sustainLevelModulatorEnvelope () const |
LoopingMode | loopingMode () const |
const MIDI::Channel & | channel () const |
double | sampleRate () const |
Generator state values for a rendering voice.
These are the values from generators. There is the initial state which is the default values. Next, there are instrument generators from the zones that match the MIDI key/velocity values of a MIDI event. These can override any default values. Finally, there are the preset generators which refine any values by adding to them. Note that not all generators are available for refining. Those that are return true from Generator::Definition::isAvailableInPreset
.
|
inline |
Mock constructor – only used in unit tests.
State::State | ( | double | sampleRate, |
const MIDI::Channel & | channel, | ||
const Setup & | setup | ||
) |
Create new state vector with a given sample rate.
sampleRate | the sample rate of audio being rendered |
channel | the MIDI channel that is in control |
setup | the voice configuration to use |
References SF2::Render::Voice::Setup::apply().
void State::addModulator | ( | const Entity::Modulator::Modulator & | modulator | ) |
Install a modulator.
modulator | the modulator to install |
References SF2::Entity::Modulator::Modulator::generatorDestination(), SF2::Entity::Modulator::Modulator::hasGeneratorDestination(), and SF2::Entity::Generator::indexValue().
|
inline |
Set a generator's adjustment value.
Instrument zones set generator values; preset zones set their adjustments. It can be set twice, once by a global preset generator setting, and again by a non-global preset generator setting.
index | the generator to set |
value | the value to use |
References SF2::Logger::debug(), SF2::Entity::Generator::Definition::definition(), and SF2::Entity::Generator::Definition::name().
|
inline |
|
inline |
Referenced by key().
|
inline |
Referenced by velocity().
|
inline |
|
inline |
Referenced by SF2::Render::Envelope::Generator::Modulator().
|
inline |
Referenced by SF2::Render::Envelope::Generator::Modulator().
|
inline |
Referenced by SF2::Render::Envelope::Generator::Volume().
|
inline |
Referenced by SF2::Render::Envelope::Generator::Volume().
|
inline |
References unmodulated().
|
inline |
Obtain a generator value after applying any registered modulators to it.
Due to the modulation calculations this returns a floating-point value, but the value has not been converted from/into any particular units and should still reflect the definitions found in the spec.
index | the index of the generator |
Referenced by SF2::Render::Envelope::Generator::Modulator(), pitch(), SF2::Render::Sample::PitchControl::PitchControl(), SF2::Render::Voice::Voice::render(), and SF2::Render::Envelope::Generator::Volume().
|
inline |
References key(), and modulated().
|
inline |
Referenced by SF2::Render::Envelope::Generator::Modulator(), and SF2::Render::Envelope::Generator::Volume().
|
inline |
Set a generator value.
Instrument zones set generator values; preset zones set their adjustments. It can be set twice, once by a global instrument generator setting, and again by a non-global instrument generator setting.
index | the generator to set |
value | the value to use |
References SF2::Logger::debug(), SF2::Entity::Generator::Definition::definition(), and SF2::Entity::Generator::Definition::name().
|
inline |
Referenced by SF2::Render::Envelope::Generator::Modulator().
|
inline |
Referenced by SF2::Render::Envelope::Generator::Volume().
|
inline |
Obtain a generator value without any modulation applied to it.
This is the original result from the zone generator definitions and so it is expressed as an integer. Most of the time, the modulated
method is what is desired in order to account for any MIDI controller values.
index | the index of the generator |
Referenced by SF2::Render::Sample::Bounds::Bounds(), key(), loopingMode(), and velocity().
|
inline |
References eventVelocity(), and unmodulated().