SoundFontInfoLib  2.21.6
Library for parsing and rendering SF2 files
SF2::Entity::Bag Class Reference

Memory layout of a 'ibag/pbag' entry in a sound font resource. More...

#include <Bag.hpp>

Inherits SF2::Entity::Entity.

Public Member Functions

 Bag (IO::Pos &pos)
 Constructor that reads from file. More...
 
uint16_t firstGeneratorIndex () const
 
uint16_t generatorCount () const
 
uint16_t firstModulatorIndex () const
 
uint16_t modulatorCount () const
 
void dump (const std::string &indent, int index) const
 Utility for displaying bag contents on output stream. More...
 

Static Public Attributes

constexpr static size_t size = 4
 

Detailed Description

Memory layout of a 'ibag/pbag' entry in a sound font resource.

Used to access packed values from a resource. Per spec, the size of this must be 4. The wGenNdx and wModNdx properties contain the first index of the generator/modulator that belongs to the instrument/preset zone. The number of generator or modulator settings is found by subtracting index value of this instance from the index value of the subsequent instance. This is guaranteed to be safe in a well-formed SF2 file, as all collections that operate in this way have a terminating instance whose index value is the total number of generators or modulators in the preset or instrument zones.

Constructor & Destructor Documentation

◆ Bag()

SF2::Entity::Bag::Bag ( IO::Pos pos)
inlineexplicit

Constructor that reads from file.

Parameters
poslocation to read from

References SF2::IO::Pos::readInto().

Member Function Documentation

◆ dump()

void Bag::dump ( const std::string &  indent,
int  index 
) const

Utility for displaying bag contents on output stream.

Parameters
indentthe prefix to write out before each line
indexa prefix index value to write out before each lines

References firstGeneratorIndex(), firstModulatorIndex(), generatorCount(), and modulatorCount().

◆ firstGeneratorIndex()

uint16_t SF2::Entity::Bag::firstGeneratorIndex ( ) const
inline
Returns
first generator index in this collection

Referenced by dump(), and generatorCount().

◆ firstModulatorIndex()

uint16_t SF2::Entity::Bag::firstModulatorIndex ( ) const
inline
Returns
first modulator index in this collection

Referenced by dump(), and modulatorCount().

◆ generatorCount()

uint16_t SF2::Entity::Bag::generatorCount ( ) const
inline
Returns
number of generators in this collection

References SF2::Entity::Entity::calculateSize(), firstGeneratorIndex(), and SF2::Entity::Entity::next().

Referenced by SF2::Render::ZoneCollection< Kind >::add(), and dump().

◆ modulatorCount()

uint16_t SF2::Entity::Bag::modulatorCount ( ) const
inline
Returns
number of modulators in this collection

References SF2::Entity::Entity::calculateSize(), firstModulatorIndex(), and SF2::Entity::Entity::next().

Referenced by SF2::Render::ZoneCollection< Kind >::add(), and dump().

Member Data Documentation

◆ size

constexpr static size_t SF2::Entity::Bag::size = 4
staticconstexpr

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