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

Representation of an instrument in an SF2 file. More...

#include <Instrument.hpp>

Inherits SF2::Render::WithZones< InstrumentZone, Entity::Instrument >.

Public Types

using InstrumentZoneCollection = WithZoneCollection
 
- Public Types inherited from SF2::Render::WithZones< InstrumentZone, Entity::Instrument >
using ZoneType = InstrumentZone
 
using EntityType = Entity::Instrument
 
using WithZoneCollection = ZoneCollection< ZoneType >
 

Public Member Functions

 Instrument (const IO::File &file, const Entity::Instrument &config)
 Construct new Instrument from SF2 entities. More...
 
InstrumentZoneCollection::Matches filter (int key, int velocity) const
 Locate the instrument zones that apply to the given key/velocity values. More...
 
- Public Member Functions inherited from SF2::Render::WithZones< InstrumentZone, Entity::Instrument >
bool hasGlobalZone () const
 
const ZoneTypeglobalZone () const
 
const WithZoneCollectionzones () const
 
const EntityTypeconfiguration () const
 

Additional Inherited Members

- Protected Member Functions inherited from SF2::Render::WithZones< InstrumentZone, Entity::Instrument >
 WithZones (size_t zoneCount, const EntityType &configuration)
 
- Protected Attributes inherited from SF2::Render::WithZones< InstrumentZone, Entity::Instrument >
WithZoneCollection zones_
 
const EntityTypeconfiguration_
 

Detailed Description

Representation of an instrument in an SF2 file.

An instrument is made up of one or more zones, where a zone is defined as a collection of generators and modulators that apply for a particular MIDI key value and/or velocity. All instrument zone generators except the very first must end with generator index #53 sampleID which indicates which SampleBuffer to use to render audio. If the first zone of an instrument does not end with a sampleID generator, then it is considered to be the one and only global zone, with its generators/modulators applied to all other zones unless a zone has its own definition.

Member Typedef Documentation

◆ InstrumentZoneCollection

Constructor & Destructor Documentation

◆ Instrument()

SF2::Render::Instrument::Instrument ( const IO::File file,
const Entity::Instrument config 
)
inline

Construct new Instrument from SF2 entities.

Parameters
filethe SF2 file that was loaded
configthe SF2 file entity that defines the instrument

References SF2::Render::ZoneCollection< Kind >::add(), SF2::Entity::Instrument::firstZoneIndex(), SF2::IO::File::instrumentZones(), SF2::Entity::Instrument::zoneCount(), and SF2::Render::WithZones< InstrumentZone, Entity::Instrument >::zones_.

Member Function Documentation

◆ filter()

InstrumentZoneCollection::Matches SF2::Render::Instrument::filter ( int  key,
int  velocity 
) const
inline

Locate the instrument zones that apply to the given key/velocity values.

Parameters
keythe MIDI key number
velocitythe MIDI velocity value
Returns
vector of matching zones

References SF2::Render::ZoneCollection< Kind >::filter(), and SF2::Render::WithZones< InstrumentZone, Entity::Instrument >::zones_.


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