SoundFontInfoLib  2.21.6
Library for parsing and rendering SF2 files
SF2::Render::Modulator Class Reference

Render-side modulator that understands how to fetch source values that will be used to modulate voice state. More...

#include <Modulator.hpp>

Public Member Functions

 Modulator (size_t index, const Entity::Modulator::Modulator &configuration, const Voice::State &state)
 Construct new modulator. More...
 
double value () const
 
const Entity::Modulator::Modulatorconfiguration () const
 
size_t index () const
 
void flagInvalid ()
 
bool isValid () const
 
void setSource (const Modulator &modulator)
 Resolve the linking between two modulators. More...
 
std::string description () const
 

Detailed Description

Render-side modulator that understands how to fetch source values that will be used to modulate voice state.

Per the SF2 spec, a modulator does the following:

  • takes a source value (Sv) (eg from a MIDI controller) and transforms it into a unipolar or bipolar value
  • takes an 'amount' source value (Av) and transforms it into a unipolar or bipolar value
  • calculates and returns Sv * Av * amount (from SF2 Entity::Modulator)

The Sv and Av transformations are done in the Transform class.

The Modulator instances operate in a 'pull' fashion: a call to their value() method fetches source values, which may themselves be modulator instances. In this way, the value() method will always return the most up-to-date values.

Constructor & Destructor Documentation

◆ Modulator()

Modulator::Modulator ( size_t  index,
const Entity::Modulator::Modulator configuration,
const Voice::State state 
)

Construct new modulator.

Parameters
indexthe index of the entity in the zone
configurationthe entity configuration that defines the modulator
statethe voice state that can be used as a source for modulators

References configuration(), SF2::Logger::debug(), SF2::Entity::Modulator::Modulator::description(), and index().

Member Function Documentation

◆ configuration()

const Entity::Modulator::Modulator& SF2::Render::Modulator::configuration ( ) const
inline
Returns
configuration of the modulator from the SF2 file

Referenced by description(), and Modulator().

◆ description()

std::string Modulator::description ( ) const

◆ flagInvalid()

void SF2::Render::Modulator::flagInvalid ( )
inline

◆ index()

size_t SF2::Render::Modulator::index ( ) const
inline
Returns
index offset for the modulator

Referenced by Modulator().

◆ isValid()

bool SF2::Render::Modulator::isValid ( ) const
inline

Referenced by value().

◆ setSource()

void SF2::Render::Modulator::setSource ( const Modulator modulator)
inline

Resolve the linking between two modulators.

Configures this modulator to invoke the value() method of another to obtain an Sv value. Per spec, linking is NOT allowed for Av values. Also per spec, source values fall in range 0-127 and are transformed into unipolar or bipolar ranges depending on their definition. This makes linking a bit strange: the 'source' modulator generates a unipolar or bipolar value per its definition, but unipolar is only useful in the linked case, and its amount must be 127 or 128 in order to get back a value that is reasonable to use as a source value for another modulator.

Parameters
modulatorprovider for an Sv to use for this modulator

References value().

◆ value()

double SF2::Render::Modulator::value ( ) const
inline
Returns
current value of the modulator

References isValid(), and SF2::MIDI::ValueTransformer::value().

Referenced by setSource().


The documentation for this class was generated from the following files: