Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::Sound Class Reference

Sound file loaded into memory that can be played on an AudioChannel. More...

Inherits G3D::ReferenceCountedObject.

Public Member Functions

 ~Sound ()
 
const Stringname () const
 
shared_ptr< AudioChannelplay (float initialVolume=1.0f, float initialPan=0.0f, float initialFrequency=DEFAULT_FREQUENCY, bool startPaused=false)
 Returns the channel on which the sound is playing so that it can be terminated or adjusted. More...
 
shared_ptr< AudioChannelplay (const Point3 &initialPosition, const Vector3 &initialVelocity, float initialVolume=1.0f, float initialFrequency=DEFAULT_FREQUENCY, bool startPaused=false)
 Play a positional sound. More...
 
Any toAny () const
 

Static Public Member Functions

static shared_ptr< Soundcreate (const String &filename, bool loop=false, bool positional=false)
 
static shared_ptr< Soundcreate (const Any &a)
 Positional defaults to true for this constructor. More...
 

Static Public Attributes

static const int16 DEFAULT_FREQUENCY = -1
 

Protected Member Functions

 Sound ()
 
void cleanup ()
 Delete resources. More...
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 

Protected Attributes

String m_filename
 
FMOD::Sound * m_fmodSound
 
bool m_loop
 
String m_name
 
bool m_positional
 

Friends

class AudioChannel
 
class AudioDevice
 

Detailed Description

Sound file loaded into memory that can be played on an AudioChannel.

Analogous to a graphics texture...a (typically) read-only value that can be

See also
AudioChannel

Constructor & Destructor Documentation

◆ Sound()

G3D::Sound::Sound ( )
protected

◆ ~Sound()

G3D::Sound::~Sound ( )

Member Function Documentation

◆ cleanup()

void G3D::Sound::cleanup ( )
protected

Delete resources.

◆ create() [1/2]

static shared_ptr<Sound> G3D::Sound::create ( const String filename,
bool  loop = false,
bool  positional = false 
)
static
Parameters
positionalSet to true for 3D audio

◆ create() [2/2]

static shared_ptr<Sound> G3D::Sound::create ( const Any a)
static

Positional defaults to true for this constructor.

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ name()

const String& G3D::Sound::name ( ) const
inline

◆ play() [1/2]

shared_ptr<AudioChannel> G3D::Sound::play ( float  initialVolume = 1.0f,
float  initialPan = 0.0f,
float  initialFrequency = DEFAULT_FREQUENCY,
bool  startPaused = false 
)

Returns the channel on which the sound is playing so that it can be terminated or adjusted.

The caller is not required to retain the AudioChannel pointer to keep the sound playing.

See also
G3D::Entity::play, G3D::SoundEntity, G3D::AudioChannel::stop

◆ play() [2/2]

shared_ptr<AudioChannel> G3D::Sound::play ( const Point3 initialPosition,
const Vector3 initialVelocity,
float  initialVolume = 1.0f,
float  initialFrequency = DEFAULT_FREQUENCY,
bool  startPaused = false 
)

Play a positional sound.

The initialPosition and initialVelocity are ignored if the sound was not loaded positionally.

See also
G3D::Entity::play, G3D::SoundEntity, G3D::AudioChannel::stop

◆ toAny()

Any G3D::Sound::toAny ( ) const

Friends And Related Function Documentation

◆ AudioChannel

friend class AudioChannel
friend

◆ AudioDevice

friend class AudioDevice
friend

Member Data Documentation

◆ DEFAULT_FREQUENCY

const int16 G3D::Sound::DEFAULT_FREQUENCY = -1
static

◆ m_filename

String G3D::Sound::m_filename
protected

◆ m_fmodSound

FMOD::Sound* G3D::Sound::m_fmodSound
protected

◆ m_loop

bool G3D::Sound::m_loop
protected

◆ m_name

String G3D::Sound::m_name
protected

Referenced by name().

◆ m_positional

bool G3D::Sound::m_positional
protected

documentation generated on Wed Nov 24 2021 08:02:00 using doxygen 1.8.15