C Specification

The XrHapticPcmVibrationFB structure is defined as:

// Provided by XR_FB_haptic_pcm
typedef struct XrHapticPcmVibrationFB {
    XrStructureType    type;
    const void*        next;
    uint32_t           bufferSize;
    const float*       buffer;
    float              sampleRate;
    XrBool32           append;
    uint32_t*          samplesConsumed;
} XrHapticPcmVibrationFB;

Members

Member Descriptions
  • type is the XrStructureType of this structure.

  • next is NULL or a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.

  • bufferSize is the number of samples in the buffer.

  • buffer is a pointer to a float array representing the PCM samples. If you consider the haptic effect as a sampled analog audio, then this buffer will contain the samples representing that effect. The values in this buffer are expected to be in the range [-1.0, 1.0].

  • sampleRate is the number of samples to be played per second, this is used to determine the duration of the haptic effect.

  • append if set to XR_FALSE, any existing samples will be cleared and a new haptic effect will begin, if XR_TRUE, samples will be appended to the currently playing effect

  • samplesConsumed is a pointer to an unsigned integer; it is populated by runtime, to tell the application about how many samples were consumed from the input buffer

Description

This structure describes a PCM haptic effect.

The runtime may resample the provided samples in the buffer, and maintain an internal buffer which should be of XR_MAX_HAPTIC_PCM_BUFFER_SIZE_FB length. The resampling should happen based on the sampleRate and the device’s sample rate.

If append is XR_TRUE and a preceding XrHapticPcmVibrationFB haptic effect on this action has not yet completed, then the runtime must finish playing the preceding samples and then play the new haptic effect. If a preceding haptic event on this action has not yet completed, and either the preceding effect is not an XrHapticPcmVibrationFB haptic effect or append is XR_FALSE, the runtime must cancel the preceding incomplete effects on that action and start playing the new haptic effect, as usual for the core specification.

When append is true and a preceding XrHapticPcmVibrationFB haptic effect on this action has not yet completed, then the application can provide a different sampleRate in the new haptic effect.

The runtime must populate the samplesConsumed with the count of the samples from buffer which were consumed. The samplesConsumed is populated before the xrApplyHapticFeedback returns.

Valid Usage (Implicit)
  • The XR_FB_haptic_pcm extension must be enabled prior to using XrHapticPcmVibrationFB

  • type must be XR_TYPE_HAPTIC_PCM_VIBRATION_FB

  • next must be NULL or a valid pointer to the next structure in a structure chain

  • buffer must be a pointer to an array of bufferSize float values

  • samplesConsumed must be a pointer to a uint32_t value

  • The bufferSize parameter must be greater than 0

See Also

Document Notes

For more information, see the OpenXR Specification

This page is extracted from the OpenXR Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2024, The Khronos Group Inc.