Panda3D
Public Member Functions | Static Public Member Functions | List of all members
FmodAudioSound Class Reference
Inheritance diagram for FmodAudioSound:
AudioSound TypedReferenceCount TypedObject ReferenceCount MemoryBase MemoryBase

Public Member Functions

 FmodAudioSound (AudioManager *manager, Filename fn, bool positional)
 Constructor All sound will DEFAULT load as a 2D sound unless otherwise specified. More...
 
 ~FmodAudioSound ()
 DESTRUCTOR!!! More...
 
void finished ()
 Not implemented. More...
 
virtual TypeHandle force_init_type ()
 
void get_3d_attributes (PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz)
 Get position and velocity of this sound Currently unimplemented. More...
 
PN_stdfloat get_3d_max_distance () const
 Get the distance that this sound stops falling off. More...
 
PN_stdfloat get_3d_min_distance () const
 Get the distance that this sound begins to fall off. More...
 
bool get_active () const
 Returns whether the sound has been marked "active". More...
 
PN_stdfloat get_balance () const
 -1.0 to 1.0 scale -1 should be all the way left. More...
 
const string & get_finished_event () const
 NOT USED ANYMORE!!! Return the string the finished event is referenced by. More...
 
bool get_loop () const
 Returns whether looping is on or off. More...
 
unsigned long get_loop_count () const
 Return how many times a sound will loop. More...
 
const string & get_name () const
 Get name of sound file. More...
 
PN_stdfloat get_play_rate () const
 
virtual PN_stdfloat get_speaker_mix (AudioManager::SpeakerId speaker)
 In Multichannel Speaker systems [like Surround]. More...
 
PN_stdfloat get_time () const
 Gets the play position within the sound. More...
 
virtual TypeHandle get_type () const
 
PN_stdfloat get_volume () const
 Gets the current volume of a sound. More...
 
PN_stdfloat length () const
 Get length FMOD returns the time in MS so we have to convert to seconds. More...
 
void play ()
 Plays a sound. More...
 
void set_3d_attributes (PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz)
 Set position and velocity of this sound NOW LISTEN UP!!! THIS IS IMPORTANT! Both Panda3D and FMOD use a left handed coordinate system. More...
 
void set_3d_max_distance (PN_stdfloat dist)
 Set the distance that this sound stops falling off. More...
 
void set_3d_min_distance (PN_stdfloat dist)
 Set the distance that this sound begins to fall off. More...
 
void set_active (bool active=true)
 Sets whether the sound is marked "active". More...
 
void set_balance (PN_stdfloat balance_right=0.0)
 -1.0 to 1.0 scale More...
 
void set_finished_event (const string &event)
 NOT USED ANYMORE!!! Assign a string for the finished event to be referenced by in python by an accept method. More...
 
void set_loop (bool loop=true)
 Turns looping on and off. More...
 
void set_loop_count (unsigned long loop_count=1)
 Panda uses 0 to mean loop forever. More...
 
void set_play_rate (PN_stdfloat play_rate=1.0f)
 Sets the speed at which a sound plays back. More...
 
virtual void set_speaker_mix (PN_stdfloat frontleft, PN_stdfloat frontright, PN_stdfloat center, PN_stdfloat sub, PN_stdfloat backleft, PN_stdfloat backright, PN_stdfloat sideleft, PN_stdfloat sideright)
 This sets the speaker mix for Surround Sound sytems. More...
 
void set_time (PN_stdfloat start_time=0.0)
 Sets the time at which the next play() operation will begin. More...
 
void set_volume (PN_stdfloat volume=1.0)
 0.0 to 1.0 scale of volume converted to Fmod's internal 0.0 to 255.0 scale. More...
 
AudioSound::SoundStatus status () const
 Get status of the sound. More...
 
void stop ()
 Stop a sound. More...
 
- Public Member Functions inherited from AudioSound
virtual bool configure_filters (FilterProperties *config)
 Configure the local DSP filter chain. More...
 
virtual PN_stdfloat get_speaker_level (int index)
 For use only with Miles. More...
 
virtual PN_stdfloat get_speaker_mix (int speaker)
 For use only with FMOD. More...
 
virtual void output (ostream &out) const
 
virtual void set_speaker_levels (PN_stdfloat level1, PN_stdfloat level2=-1.0f, PN_stdfloat level3=-1.0f, PN_stdfloat level4=-1.0f, PN_stdfloat level5=-1.0f, PN_stdfloat level6=-1.0f, PN_stdfloat level7=-1.0f, PN_stdfloat level8=-1.0f, PN_stdfloat level9=-1.0f)
 For use only with Miles. More...
 
virtual void write (ostream &out) const
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
void operator= (const TypedObject &copy)
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 Returns the current reference count. More...
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
void weak_ref (WeakPointerToVoid *ptv)
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref (WeakPointerToVoid *ptv)
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from AudioSound
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Additional Inherited Members

- Public Types inherited from AudioSound
enum  SoundStatus { BAD, READY, PLAYING }
 

Detailed Description

Definition at line 81 of file fmodAudioSound.h.

Constructor & Destructor Documentation

◆ FmodAudioSound()

FmodAudioSound::FmodAudioSound ( AudioManager manager,
Filename  fn,
bool  positional 
)

◆ ~FmodAudioSound()

FmodAudioSound::~FmodAudioSound ( )

DESTRUCTOR!!!

Definition at line 216 of file fmodAudioSound.cxx.

References play().

Referenced by FmodAudioSound().

Member Function Documentation

◆ finished()

void FmodAudioSound::finished ( )

Not implemented.

Definition at line 936 of file fmodAudioSound.cxx.

References set_finished_event().

Referenced by get_active().

◆ get_3d_attributes()

void FmodAudioSound::get_3d_attributes ( PN_stdfloat *  px,
PN_stdfloat *  py,
PN_stdfloat *  pz,
PN_stdfloat *  vx,
PN_stdfloat *  vy,
PN_stdfloat *  vz 
)
virtual

Get position and velocity of this sound Currently unimplemented.

Get the attributes of the attached object.

Reimplemented from AudioSound.

Definition at line 654 of file fmodAudioSound.cxx.

References set_3d_min_distance().

Referenced by set_3d_attributes().

◆ get_3d_max_distance()

PN_stdfloat FmodAudioSound::get_3d_max_distance ( ) const
virtual

Get the distance that this sound stops falling off.

Reimplemented from AudioSound.

Definition at line 707 of file fmodAudioSound.cxx.

References get_speaker_mix().

Referenced by set_3d_max_distance().

◆ get_3d_min_distance()

PN_stdfloat FmodAudioSound::get_3d_min_distance ( ) const
virtual

Get the distance that this sound begins to fall off.

Reimplemented from AudioSound.

Definition at line 681 of file fmodAudioSound.cxx.

References set_3d_max_distance().

Referenced by set_3d_min_distance().

◆ get_active()

bool FmodAudioSound::get_active ( ) const
virtual

Returns whether the sound has been marked "active".

Implements AudioSound.

Definition at line 926 of file fmodAudioSound.cxx.

References finished().

Referenced by set_active().

◆ get_balance()

PN_stdfloat FmodAudioSound::get_balance ( ) const
virtual

-1.0 to 1.0 scale -1 should be all the way left.

1 is all the way to the right.

Implements AudioSound.

Definition at line 514 of file fmodAudioSound.cxx.

References set_play_rate().

Referenced by set_balance().

◆ get_finished_event()

const string & FmodAudioSound::get_finished_event ( ) const
virtual

NOT USED ANYMORE!!! Return the string the finished event is referenced by.

Implements AudioSound.

Definition at line 962 of file fmodAudioSound.cxx.

References VirtualFileSystem::close_read_file(), VirtualFile::get_file_size(), VirtualFileSystem::get_global_ptr(), VirtualFile::open_read_file(), and ReferenceCount::ref().

Referenced by set_finished_event().

◆ get_loop()

bool FmodAudioSound::get_loop ( ) const
virtual

Returns whether looping is on or off.

Implements AudioSound.

Definition at line 283 of file fmodAudioSound.cxx.

References get_loop_count(), and set_loop_count().

Referenced by set_loop().

◆ get_loop_count()

unsigned long FmodAudioSound::get_loop_count ( ) const
virtual

Return how many times a sound will loop.

Implements AudioSound.

Definition at line 334 of file fmodAudioSound.cxx.

References set_time().

Referenced by get_loop(), set_active(), and set_loop_count().

◆ get_name()

const string & FmodAudioSound::get_name ( ) const
virtual

Get name of sound file.

Implements AudioSound.

Definition at line 572 of file fmodAudioSound.cxx.

References length().

Referenced by set_play_rate().

◆ get_speaker_mix()

PN_stdfloat FmodAudioSound::get_speaker_mix ( AudioManager::SpeakerId  speaker)
virtual

In Multichannel Speaker systems [like Surround].

Speakers which don't exist in some systems will simply be ignored. But I haven't been able to test this yet, so I am jsut letting you know.

BTW This will also work in Stereo speaker systems, but since PANDA/FMOD has a balance [pan] function what is the point?

Definition at line 723 of file fmodAudioSound.cxx.

References set_speaker_mix().

Referenced by get_3d_max_distance().

◆ get_time()

PN_stdfloat FmodAudioSound::get_time ( ) const
virtual

Gets the play position within the sound.

Implements AudioSound.

Definition at line 373 of file fmodAudioSound.cxx.

References set_volume().

Referenced by set_active(), and set_time().

◆ get_volume()

PN_stdfloat FmodAudioSound::get_volume ( ) const
virtual

Gets the current volume of a sound.

1 is Max. O is Min.

Implements AudioSound.

Definition at line 410 of file fmodAudioSound.cxx.

References set_balance().

Referenced by set_volume().

◆ length()

PN_stdfloat FmodAudioSound::length ( ) const
virtual

Get length FMOD returns the time in MS so we have to convert to seconds.

Implements AudioSound.

Definition at line 583 of file fmodAudioSound.cxx.

References set_3d_attributes().

Referenced by get_name().

◆ play()

void FmodAudioSound::play ( )
virtual

Plays a sound.

Implements AudioSound.

Definition at line 235 of file fmodAudioSound.cxx.

References stop().

Referenced by set_active(), and ~FmodAudioSound().

◆ set_3d_attributes()

void FmodAudioSound::set_3d_attributes ( PN_stdfloat  px,
PN_stdfloat  py,
PN_stdfloat  pz,
PN_stdfloat  vx,
PN_stdfloat  vy,
PN_stdfloat  vz 
)
virtual

Set position and velocity of this sound NOW LISTEN UP!!! THIS IS IMPORTANT! Both Panda3D and FMOD use a left handed coordinate system.

But there is a major difference! In Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. In FMOD the Y-Axis is going up and the Z-Axis is going into the screen. The solution is simple, we just flip the Y and Z axis, as we move coordinates from Panda to FMOD and back. What does did mean to average Panda user? Nothing, they shouldn't notice anyway. But if you decide to do any 3D audio work in here you have to keep it in mind. I told you, so you can't say I didn't.

Reimplemented from AudioSound.

Definition at line 610 of file fmodAudioSound.cxx.

References get_3d_attributes().

Referenced by length().

◆ set_3d_max_distance()

void FmodAudioSound::set_3d_max_distance ( PN_stdfloat  dist)
virtual

Set the distance that this sound stops falling off.

Reimplemented from AudioSound.

Definition at line 691 of file fmodAudioSound.cxx.

References get_3d_max_distance().

Referenced by get_3d_min_distance().

◆ set_3d_min_distance()

void FmodAudioSound::set_3d_min_distance ( PN_stdfloat  dist)
virtual

Set the distance that this sound begins to fall off.

Also affects the rate it falls off.

Reimplemented from AudioSound.

Definition at line 665 of file fmodAudioSound.cxx.

References get_3d_min_distance().

Referenced by get_3d_attributes().

◆ set_active()

void FmodAudioSound::set_active ( bool  active = true)
virtual

Sets whether the sound is marked "active".

By default, the active flag true for all sounds. If the active flag is set to false for any particular sound, the sound will not be heard.

Implements AudioSound.

Definition at line 893 of file fmodAudioSound.cxx.

References get_active(), get_loop_count(), get_time(), play(), status(), and stop().

Referenced by status().

◆ set_balance()

void FmodAudioSound::set_balance ( PN_stdfloat  balance_right = 0.0)
virtual

-1.0 to 1.0 scale

Implements AudioSound.

Definition at line 500 of file fmodAudioSound.cxx.

References get_balance().

Referenced by get_volume().

◆ set_finished_event()

void FmodAudioSound::set_finished_event ( const string &  event)
virtual

NOT USED ANYMORE!!! Assign a string for the finished event to be referenced by in python by an accept method.

Implements AudioSound.

Definition at line 949 of file fmodAudioSound.cxx.

References get_finished_event().

Referenced by finished().

◆ set_loop()

void FmodAudioSound::set_loop ( bool  loop = true)
virtual

Turns looping on and off.

Implements AudioSound.

Definition at line 269 of file fmodAudioSound.cxx.

References get_loop(), and set_loop_count().

Referenced by stop().

◆ set_loop_count()

void FmodAudioSound::set_loop_count ( unsigned long  loop_count = 1)
virtual

Panda uses 0 to mean loop forever.

Fmod uses negative numbers to mean loop forever. (0 means don't loop, 1 means play twice, etc. We must convert!

Implements AudioSound.

Definition at line 301 of file fmodAudioSound.cxx.

References get_loop_count().

Referenced by get_loop(), and set_loop().

◆ set_play_rate()

void FmodAudioSound::set_play_rate ( PN_stdfloat  rate = 1.0f)
virtual

Sets the speed at which a sound plays back.

The rate is a multiple of the sound, normal playback speed. IE 2 would play back 2 times fast, 3 would play 3 times, and so on. This can also be set to a negative number so a sound plays backwards. But rememeber if the sound is not playing, you must set the sound's time to its end to hear a song play backwards.

Implements AudioSound.

Definition at line 529 of file fmodAudioSound.cxx.

References get_name().

Referenced by get_balance().

◆ set_speaker_mix()

void FmodAudioSound::set_speaker_mix ( PN_stdfloat  frontleft,
PN_stdfloat  frontright,
PN_stdfloat  center,
PN_stdfloat  sub,
PN_stdfloat  backleft,
PN_stdfloat  backright,
PN_stdfloat  sideleft,
PN_stdfloat  sideright 
)
virtual

This sets the speaker mix for Surround Sound sytems.

It required 8 parameters which match up to the following:

1 = Front Left 2 = Front Right 3 = Center 4 = Subwoofer 5 = Back Left 6 = Back Right 7 = Side Left 8 = Side Right

Reimplemented from AudioSound.

Definition at line 772 of file fmodAudioSound.cxx.

References status().

Referenced by get_speaker_mix().

◆ set_time()

void FmodAudioSound::set_time ( PN_stdfloat  start_time = 0.0)
virtual

Sets the time at which the next play() operation will begin.

If we are already playing, skips to that time immediatey.

Implements AudioSound.

Definition at line 357 of file fmodAudioSound.cxx.

References get_time(), and status().

Referenced by get_loop_count().

◆ set_volume()

void FmodAudioSound::set_volume ( PN_stdfloat  volume = 1.0)
virtual

0.0 to 1.0 scale of volume converted to Fmod's internal 0.0 to 255.0 scale.

Implements AudioSound.

Definition at line 398 of file fmodAudioSound.cxx.

References get_volume().

Referenced by get_time().

◆ status()

AudioSound::SoundStatus FmodAudioSound::status ( ) const
virtual

Get status of the sound.

Implements AudioSound.

Definition at line 867 of file fmodAudioSound.cxx.

References set_active().

Referenced by set_active(), set_speaker_mix(), and set_time().

◆ stop()

void FmodAudioSound::stop ( )
virtual

Stop a sound.

Implements AudioSound.

Definition at line 245 of file fmodAudioSound.cxx.

References set_loop().

Referenced by play(), and set_active().


The documentation for this class was generated from the following files: