gvr::AudioApi

#include <gvr_audio.h>

This is a convenience C++ wrapper for the Audio C API.

Summary

This wrapper strategy prevents ABI compatibility issues between compilers by ensuring that the interface between client code and the implementation code in libgvr.so is a pure C interface. The translation from C++ calls to C calls provided by this wrapper runs entirely in the client's binary and is compiled by the client's compiler.

Methods in this class are only documented insofar as the C++ wrapping logic is concerned; for information about the method itself, please refer to the corresponding function in the C API.

THREADING: this class is thread-safe and reentrant after initialized with Init().

Inheritance

Inherits from: gvr::WrapperBase< gvr_audio_context, gvr_audio_destroy >

Public functions

CreateSoundObject(const std::string & filename)
AudioSourceId
Returns a new sound object.
CreateSoundfield(const std::string & filename)
AudioSourceId
Returns a new sound field.
CreateStereoSound(const std::string & filename)
AudioSourceId
Returns a new stereo sound.
EnableRoom(bool enable)
void
Turns on/off the room reverberation effect.
EnableStereoSpeakerMode(bool enable)
void
Enables the stereo speaker mode.
Init(AudioRenderingMode rendering_mode)
bool
Creates and initializes a gvr_audio_context.
IsSoundPlaying(AudioSourceId source_id) const
bool
Checks if a sound is playing.
IsSourceIdValid(AudioSourceId source_id)
bool
Checks if a source is in a valid playable state.
Pause()
void
Pauses the audio engine.
PauseSound(AudioSourceId source_id)
void
Pauses the playback of a sound.
PlaySound(AudioSourceId source_id, bool looping_enabled)
void
Starts the playback of a sound.
PreloadSoundfile(const std::string & filename)
bool
Preloads a local sound file.
Resume()
void
Resumes the audio engine.
ResumeSound(AudioSourceId source_id)
void
Resumes the playback of a sound.
SetHeadPose(const Mat4f & head_pose_matrix)
void
Sets the head position from a matrix representation.
SetMasterVolume(float volume)
void
Changes the master volume.
SetRoomProperties(float size_x, float size_y, float size_z, gvr_audio_material_type wall_material, gvr_audio_material_type ceiling_material, gvr_audio_material_type floor_material)
void
Sets the room properties describing the dimensions and surface materials of a given room.
SetRoomReverbAdjustments(float gain, float time_adjust, float brightness_adjust)
void
Adjusts the properties of the current reverb, allowing changes to the reverb's gain, duration and low/high frequency balance.
SetSoundObjectDirectivity(AudioSourceId sound_object_id, float alpha, float order)
void
Sets directivity constants for an existing sound object.
SetSoundObjectDistanceRolloffModel(AudioSourceId sound_object_id, gvr_audio_distance_rolloff_type rolloff_model, float min_distance, float max_distance)
void
SetSoundObjectPosition(AudioSourceId sound_object_id, float x, float y, float z)
void
Repositions an existing sound object.
SetSoundObjectRotation(AudioSourceId sound_object_id, const Quatf & sound_object_quat)
void
Sets the rotation for an existing sound object.
SetSoundVolume(AudioSourceId source_id, float volume)
void
Changes the volume of an existing sound.
SetSoundfieldRotation(AudioSourceId soundfield_id, const Quatf & soundfield_rotation)
void
Rotates an existing soundfield.
StopSound(AudioSourceId source_id)
void
Stops the playback of a sound.
UnloadSoundfile(const std::string & filename)
void
Unloads a previously preloaded sample from memory.
Update()
void
For more information, see gvr_audio_update().

Public functions

CreateSoundObject

AudioSourceId CreateSoundObject(
  const std::string & filename
)

Returns a new sound object.

For more information, see gvr_audio_create_sound_object().

CreateSoundfield

AudioSourceId CreateSoundfield(
  const std::string & filename
)

Returns a new sound field.

For more information, see gvr_audio_create_soundfield().

CreateStereoSound

AudioSourceId CreateStereoSound(
  const std::string & filename
)

Returns a new stereo sound.

For more information, see gvr_audio_create_stereo_sound().

EnableRoom

void EnableRoom(
  bool enable
)

Turns on/off the room reverberation effect.

For more information, see gvr_audio_enable_room().

EnableStereoSpeakerMode

void EnableStereoSpeakerMode(
  bool enable
)

Enables the stereo speaker mode.

For more information see gvr_audio_enable_stereo_speaker_mode().

Init

bool Init(
  AudioRenderingMode rendering_mode
)

Creates and initializes a gvr_audio_context.

For more information, see gvr_audio_create().

IsSoundPlaying

bool IsSoundPlaying(
  AudioSourceId source_id
) const 

Checks if a sound is playing.

For more information, see gvr_audio_is_sound_playing().

IsSourceIdValid

bool IsSourceIdValid(
  AudioSourceId source_id
)

Checks if a source is in a valid playable state.

For more information, see gvr_audio_is_source_id_valid().

Pause

void Pause()

Pauses the audio engine.

For more information, see gvr_audio_pause().

PauseSound

void PauseSound(
  AudioSourceId source_id
)

Pauses the playback of a sound.

For more information, see gvr_audio_pause_sound().

PlaySound

void PlaySound(
  AudioSourceId source_id,
  bool looping_enabled
)

Starts the playback of a sound.

For more information, see gvr_audio_play_sound().

PreloadSoundfile

bool PreloadSoundfile(
  const std::string & filename
)

Preloads a local sound file.

For more information, see gvr_audio_preload_soundfile().

Resume

void Resume()

Resumes the audio engine.

For more information, see gvr_audio_resume().

ResumeSound

void ResumeSound(
  AudioSourceId source_id
)

Resumes the playback of a sound.

For more information, see gvr_audio_resume_sound().

SetHeadPose

void SetHeadPose(
  const Mat4f & head_pose_matrix
)

Sets the head position from a matrix representation.

For more information, see gvr_audio_set_head_pose().

SetMasterVolume

void SetMasterVolume(
  float volume
)

Changes the master volume.

For more information, see gvr_audio_set_master_volume().

SetRoomProperties

void SetRoomProperties(
  float size_x,
  float size_y,
  float size_z,
  gvr_audio_material_type wall_material,
  gvr_audio_material_type ceiling_material,
  gvr_audio_material_type floor_material
)

Sets the room properties describing the dimensions and surface materials of a given room.

For more information, see gvr_audio_set_room_properties().

SetRoomReverbAdjustments

void SetRoomReverbAdjustments(
  float gain,
  float time_adjust,
  float brightness_adjust
)

Adjusts the properties of the current reverb, allowing changes to the reverb's gain, duration and low/high frequency balance.

For more information see gvr_audio_set_room_reverb_adjustments().

SetSoundObjectDirectivity

void SetSoundObjectDirectivity(
  AudioSourceId sound_object_id,
  float alpha,
  float order
)

Sets directivity constants for an existing sound object.

For more information, see gvr_audio_set_sound_object_directivity.

SetSoundObjectDistanceRolloffModel

void SetSoundObjectDistanceRolloffModel(
  AudioSourceId sound_object_id,
  gvr_audio_distance_rolloff_type rolloff_model,
  float min_distance,
  float max_distance
)

SetSoundObjectPosition

void SetSoundObjectPosition(
  AudioSourceId sound_object_id,
  float x,
  float y,
  float z
)

Repositions an existing sound object.

For more information, see gvr_audio_set_sound_object_position().

SetSoundObjectRotation

void SetSoundObjectRotation(
  AudioSourceId sound_object_id,
  const Quatf & sound_object_quat
)

Sets the rotation for an existing sound object.

For more information, see gvr_audio_set_sound_object_rotation.

SetSoundVolume

void SetSoundVolume(
  AudioSourceId source_id,
  float volume
)

Changes the volume of an existing sound.

For more information, see gvr_audio_set_sound_volume().

SetSoundfieldRotation

void SetSoundfieldRotation(
  AudioSourceId soundfield_id,
  const Quatf & soundfield_rotation
)

Rotates an existing soundfield.

For more information, see gvr_audio_set_soundfield_rotation().

StopSound

void StopSound(
  AudioSourceId source_id
)

Stops the playback of a sound.

For more information, see gvr_audio_stop_sound().

UnloadSoundfile

void UnloadSoundfile(
  const std::string & filename
)

Unloads a previously preloaded sample from memory.

For more information, see gvr_audio_preload_soundfile().

Update

void Update()

For more information, see gvr_audio_update().