usdrt::UsdMediaSpatialAudio
Defined in usdrt/scenegraph/usd/usdMedia/spatialAudio.h
-
class UsdMediaSpatialAudio : public usdrt::UsdGeomXformable
The SpatialAudio primitive defines basic properties for encoding playback of an audio file or stream within a USD Stage. The SpatialAudio schema derives from UsdGeomXformable since it can support full spatial audio while also supporting non-spatial mono and stereo sounds. One or more SpatialAudio prims can be placed anywhere in the namespace, though it is advantageous to place truly spatial audio prims under/inside the models from which the sound emanates, so that the audio prim need only be transformed relative to the model, rather than copying its animation.
Timecode Attributes and Time Scaling
startTime and endTime are timecode valued attributes which gives them the special behavior that layer offsets affecting the layer in which one of these values is authored are applied to the attribute’s value itself during value resolution. This allows audio playback to be kept in sync with time sampled animation as the animation is affected by layer offsets in the composition. But this behavior brings with it some interesting edge cases and caveats when it comes to layer offsets that include scale.
Public Functions
-
inline explicit UsdMediaSpatialAudio(const UsdPrim &prim = UsdPrim())
Construct a UsdMediaSpatialAudio on UsdPrim
prim
. Equivalent to UsdMediaSpatialAudio::Get(prim.GetStage(), prim.GetPath()) for a validprim
, but will not immediately throw an error for an invalidprim
.
-
inline explicit UsdMediaSpatialAudio(const UsdSchemaBase &schemaObj)
Construct a UsdMediaSpatialAudio on the prim held by
schemaObj
. Should be preferred over UsdMediaSpatialAudio(schemaObj.GetPrim()), as it preserves SchemaBase state.
-
inline virtual ~UsdMediaSpatialAudio()
Destructor.
-
inline UsdAttribute GetFilePathAttr() const
Path to the audio file. In general, the formats allowed for audio files is no more constrained by USD than is image-type. As with images, however, usdz has stricter requirements based on DMA and format support in browsers and consumer devices. The allowed audio filetypes for usdz are M4A, MP3, WAV (in order of preference).
Declaration
uniform asset filePath = @@
C++ Type
Usd Type
SdfValueTypeNames->Asset
Variability
SdfVariabilityUniform
See also
-
inline UsdAttribute CreateFilePathAttr() const
See GetFilePathAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdAttribute GetAuralModeAttr() const
Determines how audio should be played. Valid values are:
spatial: Play the audio in 3D space if the device can support spatial audio. if not, fall back to mono.
nonSpatial: Play the audio without regard to the SpatialAudio prim’s position. If the audio media contains any form of stereo or other multi-channel sound, it is left to the application to determine whether the listener’s position should be taken into account. We expect nonSpatial to be the choice for ambient sounds and music sound-tracks.
Declaration
uniform token auralMode = "spatial"
C++ Type
Usd Type
SdfValueTypeNames->Token
Variability
SdfVariabilityUniform
Allowed Values
spatial, nonSpatial
-
inline UsdAttribute CreateAuralModeAttr() const
See GetAuralModeAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdAttribute GetPlaybackModeAttr() const
Along with startTime and endTime, determines when the audio playback should start and stop during the stage’s animation playback and whether the audio should loop during its duration. Valid values are:
onceFromStart: Play the audio once, starting at startTime, continuing until the audio completes.
onceFromStartToEnd: Play the audio once beginning at startTime, continuing until endTime or until the audio completes, whichever comes first.
loopFromStart: Start playing the audio at startTime and continue looping through to the stage’s authored endTimeCode.
loopFromStartToEnd: Start playing the audio at startTime and continue looping through, stopping the audio at endTime.
loopFromStage: Start playing the audio at the stage’s authored startTimeCode and continue looping through to the stage’s authored endTimeCode. This can be useful for ambient sounds that should always be active.
Declaration
uniform token playbackMode = "onceFromStart"
C++ Type
Usd Type
SdfValueTypeNames->Token
Variability
SdfVariabilityUniform
Allowed Values
onceFromStart, onceFromStartToEnd, loopFromStart, loopFromStartToEnd,
-
inline UsdAttribute CreatePlaybackModeAttr() const
See GetPlaybackModeAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdAttribute GetStartTimeAttr() const
Expressed in the timeCodesPerSecond of the containing stage, startTime specifies when the audio stream will start playing during animation playback. This value is ignored when playbackMode is set to loopFromStage as, in this mode, the audio will always start at the stage’s authored startTimeCode. Note that startTime is expressed as a timecode so that the stage can properly apply layer offsets when resolving its value. See Timecode Attributes and Time Scaling for more details and caveats.
Declaration
uniform timecode startTime = 0
C++ Type
SdfTimeCode
Usd Type
SdfValueTypeNames->TimeCode
Variability
SdfVariabilityUniform
-
inline UsdAttribute CreateStartTimeAttr() const
See GetStartTimeAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdAttribute GetEndTimeAttr() const
Expressed in the timeCodesPerSecond of the containing stage, endTime specifies when the audio stream will cease playing during animation playback if the length of the referenced audio clip is longer than desired. This only applies if playbackMode is set to onceFromStartToEnd or loopFromStartToEnd, otherwise the endTimeCode of the stage is used instead of endTime. If endTime is less than startTime, it is expected that the audio will instead be played from endTime to startTime. Note that endTime is expressed as a timecode so that the stage can properly apply layer offsets when resolving its value. See Timecode Attributes and Time Scaling for more details and caveats.
Declaration
uniform timecode endTime = 0
C++ Type
SdfTimeCode
Usd Type
SdfValueTypeNames->TimeCode
Variability
SdfVariabilityUniform
-
inline UsdAttribute CreateEndTimeAttr() const
See GetEndTimeAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdAttribute GetMediaOffsetAttr() const
Expressed in seconds, mediaOffset specifies the offset from the referenced audio file’s beginning at which we should begin playback when stage playback reaches the time that prim’s audio should start. If the prim’s playbackMode is a looping mode, mediaOffset is applied only to the first run-through of the audio clip; the second and all other loops begin from the start of the audio clip.
Declaration
uniform double mediaOffset = 0
C++ Type
double
Usd Type
SdfValueTypeNames->Double
Variability
SdfVariabilityUniform
-
inline UsdAttribute CreateMediaOffsetAttr() const
See GetMediaOffsetAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdAttribute GetGainAttr() const
Multiplier on the incoming audio signal. A value of 0 “mutes” the signal. Negative values will be clamped to 0.
Declaration
double gain = 1
C++ Type
double
Usd Type
SdfValueTypeNames->Double
-
inline UsdAttribute CreateGainAttr() const
See GetGainAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdAttribute GetXformOpOrderAttr() const
Encodes the sequence of transformation operations in the order in which they should be pushed onto a transform stack while visiting a UsdStage’s prims in a graph traversal that will effect the desired positioning for this prim and its descendant prims.
You should rarely, if ever, need to manipulate this attribute directly. It is managed by the AddXformOp(), SetResetXformStack(), and SetXformOpOrder(), and consulted by GetOrderedXformOps() and GetLocalTransformation().
Declaration
uniform token[] xformOpOrder
C++ Type
VtArray<TfToken>
Usd Type
SdfValueTypeNames->TokenArray
Variability
SdfVariabilityUniform
-
inline UsdAttribute CreateXformOpOrderAttr() const
See GetXformOpOrderAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdAttribute GetVisibilityAttr() const
Visibility is meant to be the simplest form of “pruning” visibility that is supported by most DCC apps. Visibility is animatable, allowing a sub-tree of geometry to be present for some segment of a shot, and absent from others; unlike the action of deactivating geometry prims, invisible geometry is still available for inspection, for positioning, for defining volumes, etc.
Declaration
token visibility = "inherited"
C++ Type
Usd Type
SdfValueTypeNames->Token
Allowed Values
inherited, invisible
-
inline UsdAttribute CreateVisibilityAttr() const
See GetVisibilityAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdAttribute GetPurposeAttr() const
Purpose is a classification of geometry into categories that can each be independently included or excluded from traversals of prims on a stage, such as rendering or bounding-box computation traversals.
See UsdGeom_ImageablePurpose for more detail about how purpose is computed and used.
Declaration
uniform token purpose = "default"
C++ Type
Usd Type
SdfValueTypeNames->Token
Variability
SdfVariabilityUniform
Allowed Values
default, render, proxy, guide
-
inline UsdAttribute CreatePurposeAttr() const
See GetPurposeAttr(), and also Create vs Get Property Methods for when to use Get vs Create. If specified, author
defaultValue
as the attribute’s default, sparsely (when it makes sense to do so) ifwriteSparsely
istrue
- the default forwriteSparsely
isfalse
.
-
inline UsdRelationship GetProxyPrimRel() const
The proxyPrim relationship allows us to link a prim whose purpose is “render” to its (single target) purpose=”proxy” prim. This is entirely optional, but can be useful in several scenarios:
In a pipeline that does pruning (for complexity management) by deactivating prims composed from asset references, when we deactivate a purpose=”render” prim, we will be able to discover and additionally deactivate its associated purpose=”proxy” prim, so that preview renders reflect the pruning accurately.
DCC importers may be able to make more aggressive optimizations for interactive processing and display if they can discover the proxy for a given render prim.
With a little more work, a Hydra-based application will be able to map a picked proxy prim back to its render geometry for selection.
Note
It is only valid to author the proxyPrim relationship on prims whose purpose is “render”.
-
inline UsdRelationship CreateProxyPrimRel() const
See GetProxyPrimRel(), and also Create vs Get Property Methods for when to use Get vs Create.
-
inline explicit operator bool() const
Check if this schema object is compatible with it’s held prim and that the prim is valid.
A typed schema object is compatible if the held prim’s type is or is a subtype of the schema’s type. Based on
prim.IsA()
.An API schema object is compatible if the API is of type SingleApplyAPI or UsdSchemaType::MultipleApplyAPI, and the schema has been applied to the prim. Based on
prim.HasAPI
.This method invokes polymorphic behaviour.
See also
- Returns
True if the help prim is valid, and the schema object is compatible with its held prim.
Public Static Functions
-
static inline UsdMediaSpatialAudio Define(const UsdStageRefPtr &stage, const SdfPath &path)
Attempt to ensure a UsdPrim adhering to this schema at
path
is defined (according to UsdPrim::IsDefined()) on this stage.
Public Static Attributes
-
static const UsdSchemaType schemaType = UsdSchemaType::ConcreteTyped
Compile time constant representing what kind of schema this class is.
See also
Protected Functions
-
inline virtual bool _IsCompatible() const
Helper for subclasses to do specific compatibility checking with the given prim. Subclassess may override
_isCompatible
to for example check type compatibility or value compatibility on the prim.Overrides exist for UsdTyped and UsdAPISchemaBase.
This check is called when clients invoke the bool operator.
- Returns
True if the schema object is compatible with its held prim.
-
inline explicit UsdMediaSpatialAudio(const UsdPrim &prim = UsdPrim())