HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
HephAudio::AudioObject Struct Reference

stores information that's necessary to play audio. More...

#include <AudioObject.h>

Public Member Functions

 AudioObject ()
 
 AudioObject (AudioObject &&rhs) noexcept
 
AudioObjectoperator= (AudioObject &&rhs) noexcept
 
double GetPosition () const
 
void SetPosition (double position)
 
void Pause ()
 
void Resume ()
 

Static Public Member Functions

static void DefaultRenderHandler (const Heph::EventParams &eventParams)
 
static void MatchFormatRenderHandler (const Heph::EventParams &eventParams)
 

Public Attributes

Heph::Guid id
 
std::filesystem::path filePath
 
std::string name
 
bool isPaused
 
uint32_t playCount
 
double volume
 
AudioBuffer buffer
 
size_t frameIndex
 
Heph::Event OnRender
 
Heph::Event OnFinishedPlaying
 

Detailed Description

stores information that's necessary to play audio.

Constructor & Destructor Documentation

◆ AudioObject() [1/2]

HephAudio::AudioObject::AudioObject ( )

creates a new instance and initializes it with default values.

◆ AudioObject() [2/2]

HephAudio::AudioObject::AudioObject ( AudioObject && rhs)
noexcept

creates a new instance and moves the rhs's data to it.

Parameters
rhsinstance whose data will be moved.

Member Function Documentation

◆ GetPosition()

double HephAudio::AudioObject::GetPosition ( ) const

calculates the playback position between 0 and 1.

◆ SetPosition()

void HephAudio::AudioObject::SetPosition ( double position)

sets the playback position.

Parameters
positionbetween 0 and 1.

◆ Pause()

void HephAudio::AudioObject::Pause ( )

stops playing the audio object.

◆ Resume()

void HephAudio::AudioObject::Resume ( )

starts playing the audio object.

◆ DefaultRenderHandler()

static void HephAudio::AudioObject::DefaultRenderHandler ( const Heph::EventParams & eventParams)
static

the default handler for the AudioObject::OnRender event. Plays the audio data as is.

◆ MatchFormatRenderHandler()

static void HephAudio::AudioObject::MatchFormatRenderHandler ( const Heph::EventParams & eventParams)
static

an handler for the AudioObject::OnRender event. Converts the audio data to the render format before playing.

Member Data Documentation

◆ id

Heph::Guid HephAudio::AudioObject::id

unique identifier of the object.

◆ filePath

std::filesystem::path HephAudio::AudioObject::filePath

path of the file the object is created with, or empty if created via NativeAudio::CreateAudioObject.

◆ name

std::string HephAudio::AudioObject::name

name of the object.

◆ isPaused

bool HephAudio::AudioObject::isPaused

indicates whether the object is paused. If true, the object will not be played until this field is set to false.

◆ playCount

uint32_t HephAudio::AudioObject::playCount

number of times the object will be played. Set this to HEPHAUDIO_INFINITE_LOOP in order to play it infinite times.

◆ volume

double HephAudio::AudioObject::volume

loudness of the audio between 0 and 1.

Important
values above 1 may cause distortion.

◆ buffer

AudioBuffer HephAudio::AudioObject::buffer

contains the audio data.

◆ frameIndex

size_t HephAudio::AudioObject::frameIndex

index of the first audio frame that will be rendered (played) next.

◆ OnRender

Heph::Event HephAudio::AudioObject::OnRender

event that will be invoked each time before rendering (playing) audio data.

◆ OnFinishedPlaying

Heph::Event HephAudio::AudioObject::OnFinishedPlaying

event that will be invoked each time when the object finishes playing.