Static utility helpers shared by procedural sound behavior implementations.
Behavior authors load audio clips from a prefixed source reference that names either a procedural-sound registry key or a Sound-schema model definition entry. Centralizing the classification and lookup logic here keeps every behavior consistent and lets new source kinds be added in one place.
- Source string formats
- The helper accepts three forms for a source string:
- "ProceduralSound:Ocean" – prefixed registry key; the prefix is stripped by extractKey() before the factory is queried.
- "ModelDefinition:myEntry" – prefixed Sound-schema model-definition entry name; resolved via DtModelDefinitionManager. When the entry specifies a procedural_sound_name the load dispatches through the ProceduralSound branch; otherwise a single-clip layer is installed from the entry's sound_filepath / sound_decibels.
- "Ocean" – legacy bare registry key (no prefix); recognized identically to the prefixed ProceduralSound form.
Any other string – empty, containing a path separator, or ending in ".wav" / ".meaf" – is classified as DtSourceKind::Invalid and produces a warning.
- Usage pattern 1 – inside DtProceduralSoundBehavior::setupSound()
void DtMyBehavior::setupSound(DtProceduralSound& sound, DtDe& de) override
{
auto& layer = sound.addLayer("myLayer");
layer.setBehavior(this);
layer, mySource, de);
if (!result.myLoaded)
{
layer.setGainRange(0.8f, 1.0f);
layer.setPitchRange(0.98f, 1.02f);
}
}
- Usage pattern 2 – inside DtProceduralSoundBehaviorCreator::create()
DtProceduralSoundBehavior* DtMyCreator::create(
DtDe& , const std::map<std::string, std::string>& params) override
{
std::string src = "ProceduralSound:Ocean";
auto it = params.find("source");
if (it != params.end()) src = it->second;
return new DtMyBehavior(src);
}
Load clips into layer from source, dispatching on classifySource(source).
DtSourceKind::ProceduralSound – the factory is queried with extractKey(source); on success clips are transferred via addClipsFrom() and the returned ClipLoadResult carries the factory layer's scheduling / gain / pitch settings with myLoaded == true.
DtSourceKind::ModelDefinition – the Sound-schema model definition entry named by extractKey(source) is looked up via DtModelDefinitionManager. When the entry specifies a non-empty procedural_sound_name the load re-dispatches through the ProceduralSound branch with that key. Otherwise a single clip is installed from the entry's sound_filepath and sound_decibels.
DtSourceKind::Invalid – a warning is emitted and the returned ClipLoadResult has myLoaded == false with defaults unchanged.
- Parameters
-
- Returns
- Populated ClipLoadResult.