32 using ReadFramesCallback = std::function<std::uint64_t(
float* pFramesOut, std::uint64_t frameCount)>;
52 bool init(std::uint32_t sampleRate, std::uint32_t frameSize);
58 bool init(std::uint32_t sampleRate, std::uint32_t frameSize,
const char* sofaFilePath);
74 void setListener(
const glm::vec3& position,
const glm::quat& orientation);
87 std::uint32_t channels,
const glm::vec3& position,
float volume,
bool loop);
112 void render(
float* pFramesOutInterleavedStereo, std::uint32_t frameCount);
bool init(std::uint32_t sampleRate, std::uint32_t frameSize)
Initialize Steam Audio with the built-in HRTF.
SourceId addSource(ReadFramesCallback readFrames, DestroyCallback onDestroy, std::uint32_t channels, const glm::vec3 &position, float volume, bool loop)
Register a spatialized source.
void shutdown()
Shut down Steam Audio and release all sources and effects. Must not run concurrently with render() (c...
void removeSource(SourceId source)
Release a source. The read backend is destroyed asynchronously on the audio thread; the source stops ...
static constexpr SourceId INVALID_SOURCE
bool isInitialized() const
Returns whether init() succeeded and shutdown() has not been called.
void setListener(const glm::vec3 &position, const glm::quat &orientation)
Set the listener pose (headset position and world orientation).
std::function< std::uint64_t(float *pFramesOut, std::uint64_t frameCount)> ReadFramesCallback
Reads interleaved PCM frames in the source's native channel layout.
SteamAudioBackend & operator=(const SteamAudioBackend &)=delete
SteamAudioBackend(const SteamAudioBackend &)=delete
void updateSourcePosition(SourceId source, const glm::vec3 &position)
Move an existing source to a new world position.
bool isSourceFinished(SourceId source) const
Check whether a source reached the end of its audio.
std::unique_ptr< Impl > impl_
void updateSourceVolume(SourceId source, float volume)
Change the base gain of an existing source.
bool init(std::uint32_t sampleRate, std::uint32_t frameSize, const char *sofaFilePath)
Initialize Steam Audio with an individualized HRTF from a SOFA file.
std::function< void()> DestroyCallback
Frees the source PCM backend (e.g. a miniaudio buffer). Invoked on the audio thread when the source i...
void render(float *pFramesOutInterleavedStereo, std::uint32_t frameCount)
Accumulate the spatialized mix into an interleaved stereo buffer.