SoundFontInfoLib
2.21.6
Library for parsing and rendering SF2 files
|
A zone represents a collection of generator and modulator settings that apply to a range of MIDI key and velocity values. More...
#include <Zone.hpp>
Inherited by SF2::Render::InstrumentZone, and SF2::Render::PresetZone.
Public Types | |
using | GeneratorCollection = IO::ChunkItems< Entity::Generator::Generator >::ItemRefCollection |
using | ModulatorCollection = IO::ChunkItems< Entity::Modulator::Modulator >::ItemRefCollection |
Public Member Functions | |
const MIDIRange & | keyRange () const |
const MIDIRange & | velocityRange () const |
const GeneratorCollection & | generators () const |
const ModulatorCollection & | modulators () const |
bool | isGlobal () const |
bool | appliesTo (int key, int velocity) const |
Determines if this zone applies to a given MIDI key/velocity pair. More... | |
Static Public Attributes | |
static MIDIRange const | all = MIDIRange(0, 255) |
A range that always returns true for any MIDI value. More... | |
Protected Member Functions | |
Zone (GeneratorCollection &&gens, ModulatorCollection &&mods, Entity::Generator::Index terminal) | |
Constructor. More... | |
uint16_t | resourceLink () const |
Obtain the link to the resource used by this zone. More... | |
void | apply (Voice::State &state) const |
Apply the instrument zone to the given voice state. More... | |
void | refine (Voice::State &state) const |
Apply the zone to the given voice state by adjusting the value using the generator in the zone. More... | |
A zone represents a collection of generator and modulator settings that apply to a range of MIDI key and velocity values.
There are two types: instrument zones and preset zones. Generator settings for the former specify actual values to use, while those in preset zones define adjustments to values set by the instrument.
using SF2::Render::Zone::GeneratorCollection = IO::ChunkItems<Entity::Generator::Generator>::ItemRefCollection |
using SF2::Render::Zone::ModulatorCollection = IO::ChunkItems<Entity::Modulator::Modulator>::ItemRefCollection |
|
inlineprotected |
Constructor.
gens | collection of generator for the zone |
mods | collection of modulators for the zone |
terminal | the index type of a generator that signals the zone is NOT global |
|
inline |
Determines if this zone applies to a given MIDI key/velocity pair.
NOTE: this should not be called for a global zone, though technically doing so is OK since both key/velocity ranges will be set to all
by default.
key | MIDI key value |
velocity | MIDI velocity value |
References SF2::Render::Range< T >::contains().
|
inlineprotected |
Apply the instrument zone to the given voice state.
state | the voice state to update |
Referenced by SF2::Render::InstrumentZone::apply().
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
Apply the zone to the given voice state by adjusting the value using the generator in the zone.
Note that here we blindly perform this operation to ALL generators regardless of type. The spec specifically says NOT to do this for some generator types, but in this implementation there are no issues with doing so:
keyRange
and velocityRange
are only used during the filtering stage and so the update here is a waste of time but otherwise harmless.state | the voice state to update |
Referenced by SF2::Render::PresetZone::refine().
|
inlineprotected |
Obtain the link to the resource used by this zone.
For an instrument zone, this points to the sample buffer to use to render sounds. For a preset zone, this points to an instrument.
References SF2::Entity::Generator::instrument, and SF2::Entity::Generator::sampleID.
|
inline |
A range that always returns true for any MIDI value.