mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
*** empty log message ***
This commit is contained in:
parent
cb65e0c44e
commit
be22aa9d15
@ -20,6 +20,7 @@
|
||||
#define __AUDIO_H__
|
||||
|
||||
#include "audioSound.h"
|
||||
#include "audioDSP.h"
|
||||
#include "audioManager.h"
|
||||
|
||||
#endif /* __AUDIO_H__ */
|
||||
|
195
panda/src/audio/audioDSP.cxx
Normal file
195
panda/src/audio/audioDSP.cxx
Normal file
@ -0,0 +1,195 @@
|
||||
// Filename: audioDSP.cxx
|
||||
// Created by: Stan Rosenbaum "Staque" - Spring 2006
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "audioDSP.h"
|
||||
|
||||
TypeHandle AudioDSP::_type_handle;
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::reset
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioDSP::
|
||||
reset() {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::remove
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioDSP::
|
||||
remove() {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::set_bypass
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioDSP::
|
||||
set_bypass(bool bypass) {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::get_bypass
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AudioDSP::get_bypass() {
|
||||
// intentionally blank
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::set_parameter
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioDSP::
|
||||
set_parameter(const string &name, float value) {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::list_parameters_info
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioDSP::
|
||||
list_parameters_info() {
|
||||
int np = get_num_parameters();
|
||||
for (int i=0; i<np; i++) {
|
||||
string name = get_parameter_name(i);
|
||||
string desc = get_parameter_description(i);
|
||||
float minv = get_parameter_min(i);
|
||||
float maxv = get_parameter_max(i);
|
||||
cerr << "Parameter: " << name << " (" << desc << ") " << minv << " to " << maxv << endl ;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::get_num_parameters
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int AudioDSP::
|
||||
get_num_parameters() {
|
||||
// intentionally blank
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::get_parameter_name
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string AudioDSP::
|
||||
get_parameter_name(int index) {
|
||||
// intentionally blank
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::get_parameter_description
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string AudioDSP::
|
||||
get_parameter_description(int index) {
|
||||
// intentionally blank
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::get_parameter_min
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float AudioDSP::
|
||||
get_parameter_min(int index) {
|
||||
// intentionally blank
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::get_parameter_max
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float AudioDSP::
|
||||
get_parameter_max(int index) {
|
||||
// intentionally blank
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::get_parameter_value
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float AudioDSP::
|
||||
get_parameter_value(const string &name) {
|
||||
// intentionally blank
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::Constructor
|
||||
// Access: Protected
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
AudioDSP::AudioDSP() {
|
||||
// Intentionally blank.
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioDSP::Destructor
|
||||
// Access: Published, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
AudioDSP::~AudioDSP() {
|
||||
}
|
||||
|
80
panda/src/audio/audioDSP.h
Normal file
80
panda/src/audio/audioDSP.h
Normal file
@ -0,0 +1,80 @@
|
||||
// Filename: audioDSP.h
|
||||
// Created by: Stan Rosenbaum "Staque" - Spring 2006
|
||||
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __AUDIODSP_H__
|
||||
#define __AUDIODSP_H__
|
||||
|
||||
#include "config_audio.h"
|
||||
#include "typedReferenceCount.h"
|
||||
#include "pointerTo.h"
|
||||
|
||||
class AudioManager;
|
||||
|
||||
|
||||
class EXPCL_PANDA AudioDSP : public TypedReferenceCount {
|
||||
PUBLISHED:
|
||||
virtual void reset();
|
||||
virtual void remove();
|
||||
virtual void set_bypass(bool bypass);
|
||||
virtual void set_parameter(const string &name, float value);
|
||||
virtual float get_parameter_value(const string &name);
|
||||
|
||||
virtual bool get_bypass();
|
||||
void list_parameters_info();
|
||||
|
||||
virtual int get_num_parameters();
|
||||
virtual string get_parameter_name(int index);
|
||||
virtual string get_parameter_description(int index);
|
||||
virtual float get_parameter_min(int index);
|
||||
virtual float get_parameter_max(int index);
|
||||
|
||||
|
||||
virtual ~AudioDSP();
|
||||
|
||||
protected:
|
||||
AudioDSP();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//These are needed for Panda's Pointer System. DO NOT ERASE!
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
TypedReferenceCount::init_type();
|
||||
register_type(_type_handle, "AudioDSP",
|
||||
TypedReferenceCount::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//DONE
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
|
||||
#endif /* __AudioDSP_H__ */
|
@ -38,8 +38,7 @@ namespace {
|
||||
Create_AudioManager_proc* AudioManager::_create_AudioManager
|
||||
=create_NullAudioManger;
|
||||
|
||||
void AudioManager::
|
||||
register_AudioManager_creator(Create_AudioManager_proc* proc) {
|
||||
void AudioManager::register_AudioManager_creator(Create_AudioManager_proc* proc) {
|
||||
nassertv(_create_AudioManager==create_NullAudioManger);
|
||||
_create_AudioManager=proc;
|
||||
}
|
||||
@ -47,10 +46,8 @@ register_AudioManager_creator(Create_AudioManager_proc* proc) {
|
||||
|
||||
|
||||
// Factory method for getting a platform specific AudioManager:
|
||||
PT(AudioManager) AudioManager::
|
||||
create_AudioManager() {
|
||||
audio_debug("create_AudioManager()\n audio_library_name=\""
|
||||
<<audio_library_name<<"\"");
|
||||
PT(AudioManager) AudioManager::create_AudioManager() {
|
||||
audio_debug("create_AudioManager()\n audio_library_name=\""<<audio_library_name<<"\"");
|
||||
static int lib_load;
|
||||
if (!lib_load) {
|
||||
lib_load=1;
|
||||
@ -91,8 +88,7 @@ create_AudioManager() {
|
||||
// Access: Published, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
AudioManager::
|
||||
~AudioManager() {
|
||||
AudioManager::~AudioManager() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -104,8 +100,7 @@ AudioManager::
|
||||
// change your mind and want to play sounds again, you
|
||||
// will have to recreate all of these objects.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioManager::
|
||||
shutdown() {
|
||||
void AudioManager::shutdown() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -116,8 +111,7 @@ shutdown() {
|
||||
// sound. This same object may also be returned by
|
||||
// get_sound() if it fails.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(AudioSound) AudioManager::
|
||||
get_null_sound() {
|
||||
PT(AudioSound) AudioManager::get_null_sound() {
|
||||
if (_null_sound == (AudioSound *)NULL) {
|
||||
_null_sound = new NullAudioSound;
|
||||
}
|
||||
@ -125,13 +119,74 @@ get_null_sound() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::create_dsp
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(AudioDSP) AudioManager::
|
||||
create_dsp(DSP_category) {
|
||||
// intentionally blank.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::add_dsp
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AudioManager::
|
||||
add_dsp(PT(AudioDSP) x) {
|
||||
// intentionally blank
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::remove_dsp
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AudioManager::
|
||||
remove_dsp(PT(AudioDSP) x) {
|
||||
// intentionally blank
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::getSpeakerSetup()
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int AudioManager::
|
||||
getSpeakerSetup() {
|
||||
// intentionally blank
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::setSpeakerSetup()
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioManager::
|
||||
setSpeakerSetup(SPEAKERMODE_category cat) {
|
||||
// intentionally blank
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::audio_3d_update
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioManager::
|
||||
audio_3d_update() {
|
||||
void AudioManager::audio_3d_update() {
|
||||
// intentionally blank.
|
||||
}
|
||||
|
||||
@ -140,8 +195,7 @@ audio_3d_update() {
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioManager::
|
||||
audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float vy, float vz, float fx, float fy, float fz, float ux, float uy, float uz) {
|
||||
void AudioManager::audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float vy, float vz, float fx, float fy, float fz, float ux, float uy, float uz) {
|
||||
// intentionally blank.
|
||||
}
|
||||
|
||||
@ -150,8 +204,7 @@ audio_3d_set_listener_attributes(float px, float py, float pz, float vx, float v
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioManager::
|
||||
audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz, float *fx, float *fy, float *fz, float *ux, float *uy, float *uz) {
|
||||
void AudioManager::audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz, float *fx, float *fy, float *fz, float *ux, float *uy, float *uz) {
|
||||
// intentionally blank.
|
||||
}
|
||||
|
||||
@ -160,8 +213,7 @@ audio_3d_get_listener_attributes(float *px, float *py, float *pz, float *vx, flo
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioManager::
|
||||
audio_3d_set_distance_factor(float factor) {
|
||||
void AudioManager::audio_3d_set_distance_factor(float factor) {
|
||||
// intentionally blank.
|
||||
}
|
||||
|
||||
@ -170,8 +222,7 @@ audio_3d_set_distance_factor(float factor) {
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float AudioManager::
|
||||
audio_3d_get_distance_factor() const {
|
||||
float AudioManager::audio_3d_get_distance_factor() const {
|
||||
// intentionally blank.
|
||||
return 0.0f;
|
||||
}
|
||||
@ -181,8 +232,7 @@ audio_3d_get_distance_factor() const {
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioManager::
|
||||
audio_3d_set_doppler_factor(float factor) {
|
||||
void AudioManager::audio_3d_set_doppler_factor(float factor) {
|
||||
// intentionally blank.
|
||||
}
|
||||
|
||||
@ -191,8 +241,7 @@ audio_3d_set_doppler_factor(float factor) {
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float AudioManager::
|
||||
audio_3d_get_doppler_factor() const {
|
||||
float AudioManager::audio_3d_get_doppler_factor() const {
|
||||
// intentionally blank.
|
||||
return 0.0f;
|
||||
}
|
||||
@ -202,8 +251,7 @@ audio_3d_get_doppler_factor() const {
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioManager::
|
||||
audio_3d_set_drop_off_factor(float factor) {
|
||||
void AudioManager::audio_3d_set_drop_off_factor(float factor) {
|
||||
// intentionally blank.
|
||||
}
|
||||
|
||||
@ -212,8 +260,7 @@ audio_3d_set_drop_off_factor(float factor) {
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float AudioManager::
|
||||
audio_3d_get_drop_off_factor() const {
|
||||
float AudioManager::audio_3d_get_drop_off_factor() const {
|
||||
// intentionally blank.
|
||||
return 0.0f;
|
||||
}
|
||||
|
@ -22,12 +22,68 @@
|
||||
|
||||
#include "config_audio.h"
|
||||
#include "audioSound.h"
|
||||
#include "audioDSP.h"
|
||||
|
||||
typedef PT(AudioManager) Create_AudioManager_proc();
|
||||
|
||||
|
||||
class EXPCL_PANDA AudioManager : public TypedReferenceCount {
|
||||
PUBLISHED:
|
||||
|
||||
|
||||
//This is an enumerator for the FMOD DSPs.
|
||||
//The reason why this is here, is because Panda's DTOOL interegator
|
||||
//For the Python Bindings, does not seem to like getting 'PUBLISHED'
|
||||
//Functions in the AudioTraits.
|
||||
//I guess this is a bug, but it was beyond me.
|
||||
enum DSP_category {
|
||||
// These enumerants line up one-to-one
|
||||
// with the FMOD DSP enumerants.
|
||||
DSP_unknown,
|
||||
DSP_mixer,
|
||||
DSP_oscillator,
|
||||
DSP_lowpass,
|
||||
DSP_itlowpass,
|
||||
DSP_highpass,
|
||||
DSP_echo,
|
||||
DSP_flange,
|
||||
DSP_distortion,
|
||||
DSP_normalize,
|
||||
DSP_parameq,
|
||||
DSP_pitchshift,
|
||||
DSP_chorus,
|
||||
DSP_reverb,
|
||||
DSP_vstplugin,
|
||||
DSP_winampplugin,
|
||||
DSP_itecho,
|
||||
DSP_compressor,
|
||||
DSP_COUNT
|
||||
};
|
||||
|
||||
enum SPEAKERMODE_category{
|
||||
// These enumerants line up one-to-one
|
||||
// with the FMOD SPEAKERMODE enumerants.
|
||||
SPEAKERMODE_raw,
|
||||
SPEAKERMODE_mono,
|
||||
SPEAKERMODE_stereo,
|
||||
SPEAKERMODE_quad,
|
||||
SPEAKERMODE_surround,
|
||||
SPEAKERMODE_5point1,
|
||||
SPEAKERMODE_7point1,
|
||||
SPEAKERMODE_prologic,
|
||||
SPEAKERMODE_max,
|
||||
SPEAKERMODE_COUNT
|
||||
};
|
||||
|
||||
virtual PT(AudioDSP) create_dsp(DSP_category cat);
|
||||
|
||||
virtual bool add_dsp(PT(AudioDSP) x);
|
||||
virtual bool remove_dsp(PT(AudioDSP) x);
|
||||
|
||||
|
||||
virtual int getSpeakerSetup();
|
||||
virtual void setSpeakerSetup(SPEAKERMODE_category cat);
|
||||
|
||||
// Create an AudioManager for each category of sounds you have.
|
||||
// E.g.
|
||||
// MySoundEffects = create_AudioManager::AudioManager();
|
||||
@ -52,6 +108,7 @@ PUBLISHED:
|
||||
|
||||
// Get a sound:
|
||||
virtual PT(AudioSound) get_sound(const string& file_name, bool positional = false) = 0;
|
||||
|
||||
PT(AudioSound) get_null_sound();
|
||||
|
||||
// Tell the AudioManager there is no need to keep this one cached.
|
||||
|
@ -72,3 +72,71 @@ get_3d_max_distance() const {
|
||||
// Intentionally blank.
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::add_dsp
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AudioSound::
|
||||
add_dsp(PT(AudioDSP) x) {
|
||||
// intentionally blank
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::remove_dsp
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool AudioSound::
|
||||
remove_dsp(PT(AudioDSP) x) {
|
||||
// intentionally blank
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::getSpeakerMix
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float AudioSound::
|
||||
get_speaker_mix(int speaker) {
|
||||
// intentionally blank
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::setSpeakerMix
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioSound::
|
||||
set_speaker_mix(float frontleft, float frontright, float center, float sub, float backleft, float backright, float sideleft, float sideright) {
|
||||
// intentionally blank
|
||||
;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::get_priority
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int AudioSound::
|
||||
get_priority() {
|
||||
// intentionally blank
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: AudioManager::set_priority
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void AudioSound::
|
||||
set_priority(int priority) {
|
||||
// intentionally blank
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -24,130 +24,141 @@
|
||||
#include "typedReferenceCount.h"
|
||||
#include "pointerTo.h"
|
||||
|
||||
#include "audioDSP.h"
|
||||
|
||||
class AudioManager;
|
||||
|
||||
|
||||
class EXPCL_PANDA AudioSound : public TypedReferenceCount {
|
||||
PUBLISHED:
|
||||
virtual ~AudioSound();
|
||||
|
||||
// For best compatability, set the loop_count,
|
||||
// volume, and balance, prior to calling play(). You may
|
||||
// set them while they're playing, but it's implementation
|
||||
// specific whether you get the results.
|
||||
// - Calling play() a second time on the same sound before it is
|
||||
// finished will start the sound again (creating a skipping or
|
||||
// stuttering effect).
|
||||
virtual void play() = 0;
|
||||
virtual void stop() = 0;
|
||||
|
||||
// loop: false = play once; true = play forever.
|
||||
// inits to false.
|
||||
virtual void set_loop(bool loop=true) = 0;
|
||||
virtual bool get_loop() const = 0;
|
||||
|
||||
// loop_count: 0 = forever; 1 = play once; n = play n times.
|
||||
// inits to 1.
|
||||
virtual void set_loop_count(unsigned long loop_count=1) = 0;
|
||||
virtual unsigned long get_loop_count() const = 0;
|
||||
|
||||
// Control time position within the sound.
|
||||
// This is similar (in concept) to the seek position within
|
||||
// a file.
|
||||
// time in seconds: 0 = beginning; length() = end.
|
||||
// inits to 0.0.
|
||||
// - Unlike the other get_* and set_* calls for a sound, the
|
||||
// current time position will change while the sound is playing.
|
||||
// To play the same sound from a time offset a second time,
|
||||
// explicitly set the time position again. When looping, the
|
||||
// second and later loops will start from the beginning of the
|
||||
// sound.
|
||||
// - If a sound is playing, calling get_time() repeatedly will
|
||||
// return different results over time. e.g.:
|
||||
// float percent_complete = s.get_time() / s.length();
|
||||
virtual void set_time(float start_time=0.0) = 0;
|
||||
virtual float get_time() const = 0;
|
||||
|
||||
// 0 = minimum; 1.0 = maximum.
|
||||
// inits to 1.0.
|
||||
virtual void set_volume(float volume=1.0) = 0;
|
||||
virtual float get_volume() const = 0;
|
||||
|
||||
// -1.0 is hard left
|
||||
// 0.0 is centered
|
||||
// 1.0 is hard right
|
||||
// inits to 0.0.
|
||||
virtual void set_balance(float balance_right=0.0) = 0;
|
||||
virtual float get_balance() const = 0;
|
||||
|
||||
// play_rate is any positive float value.
|
||||
// inits to 1.0.
|
||||
virtual void set_play_rate(float play_rate=1.0f) = 0;
|
||||
virtual float get_play_rate() const = 0;
|
||||
PUBLISHED:
|
||||
virtual ~AudioSound();
|
||||
|
||||
// For best compatability, set the loop_count,
|
||||
// volume, and balance, prior to calling play(). You may
|
||||
// set them while they're playing, but it's implementation
|
||||
// specific whether you get the results.
|
||||
// - Calling play() a second time on the same sound before it is
|
||||
// finished will start the sound again (creating a skipping or
|
||||
// stuttering effect).
|
||||
virtual void play() = 0;
|
||||
virtual void stop() = 0;
|
||||
|
||||
// loop: false = play once; true = play forever.
|
||||
// inits to false.
|
||||
virtual void set_loop(bool loop=true) = 0;
|
||||
virtual bool get_loop() const = 0;
|
||||
|
||||
// loop_count: 0 = forever; 1 = play once; n = play n times.
|
||||
// inits to 1.
|
||||
virtual void set_loop_count(unsigned long loop_count=1) = 0;
|
||||
virtual unsigned long get_loop_count() const = 0;
|
||||
|
||||
// Control time position within the sound.
|
||||
// This is similar (in concept) to the seek position within
|
||||
// a file.
|
||||
// time in seconds: 0 = beginning; length() = end.
|
||||
// inits to 0.0.
|
||||
// - Unlike the other get_* and set_* calls for a sound, the
|
||||
// current time position will change while the sound is playing.
|
||||
// To play the same sound from a time offset a second time,
|
||||
// explicitly set the time position again. When looping, the
|
||||
// second and later loops will start from the beginning of the
|
||||
// sound.
|
||||
// - If a sound is playing, calling get_time() repeatedly will
|
||||
// return different results over time. e.g.:
|
||||
// float percent_complete = s.get_time() / s.length();
|
||||
virtual void set_time(float start_time=0.0) = 0;
|
||||
virtual float get_time() const = 0;
|
||||
|
||||
// 0 = minimum; 1.0 = maximum.
|
||||
// inits to 1.0.
|
||||
virtual void set_volume(float volume=1.0) = 0;
|
||||
virtual float get_volume() const = 0;
|
||||
|
||||
// -1.0 is hard left
|
||||
// 0.0 is centered
|
||||
// 1.0 is hard right
|
||||
// inits to 0.0.
|
||||
virtual void set_balance(float balance_right=0.0) = 0;
|
||||
virtual float get_balance() const = 0;
|
||||
|
||||
// play_rate is any positive float value.
|
||||
// inits to 1.0.
|
||||
virtual void set_play_rate(float play_rate=1.0f) = 0;
|
||||
virtual float get_play_rate() const = 0;
|
||||
|
||||
// inits to manager's state.
|
||||
virtual void set_active(bool flag=true) = 0;
|
||||
virtual bool get_active() const = 0;
|
||||
// inits to manager's state.
|
||||
virtual void set_active(bool flag=true) = 0;
|
||||
virtual bool get_active() const = 0;
|
||||
|
||||
// Set (or clear) the event that will be thrown when the sound
|
||||
// finishes playing. To clear the event, pass an empty string.
|
||||
virtual void set_finished_event(const string& event) = 0;
|
||||
virtual const string& get_finished_event() const = 0;
|
||||
|
||||
// There is no set_name(), this is intentional.
|
||||
virtual const string& get_name() const = 0;
|
||||
|
||||
// return: playing time in seconds.
|
||||
virtual float length() const = 0;
|
||||
// Set (or clear) the event that will be thrown when the sound
|
||||
// finishes playing. To clear the event, pass an empty string.
|
||||
virtual void set_finished_event(const string& event) = 0;
|
||||
virtual const string& get_finished_event() const = 0;
|
||||
|
||||
// There is no set_name(), this is intentional.
|
||||
virtual const string& get_name() const = 0;
|
||||
|
||||
// return: playing time in seconds.
|
||||
virtual float length() const = 0;
|
||||
|
||||
// Controls the position of this sound's emitter.
|
||||
// px, py and pz are the emitter's position.
|
||||
// vx, vy and vz are the emitter's velocity in UNITS PER SECOND (default: meters).
|
||||
virtual void set_3d_attributes(float px, float py, float pz,
|
||||
float vx, float vy, float vz);
|
||||
virtual void get_3d_attributes(float *px, float *py, float *pz,
|
||||
float *vx, float *vy, float *vz);
|
||||
// Controls the position of this sound's emitter.
|
||||
// px, py and pz are the emitter's position.
|
||||
// vx, vy and vz are the emitter's velocity in UNITS PER SECOND (default: meters).
|
||||
virtual void set_3d_attributes(float px, float py, float pz,
|
||||
float vx, float vy, float vz);
|
||||
virtual void get_3d_attributes(float *px, float *py, float *pz,
|
||||
float *vx, float *vy, float *vz);
|
||||
|
||||
|
||||
// Controls the distance (in units) that this sound begins to fall off.
|
||||
// Also affects the rate it falls off.
|
||||
// Default is 1.0
|
||||
// Closer/Faster, <1.0
|
||||
// Farther/Slower, >1.0
|
||||
virtual void set_3d_min_distance(float dist);
|
||||
virtual float get_3d_min_distance() const;
|
||||
// Controls the distance (in units) that this sound begins to fall off.
|
||||
// Also affects the rate it falls off.
|
||||
// Default is 1.0
|
||||
// Closer/Faster, <1.0
|
||||
// Farther/Slower, >1.0
|
||||
virtual void set_3d_min_distance(float dist);
|
||||
virtual float get_3d_min_distance() const;
|
||||
|
||||
// Controls the maximum distance (in units) that this sound stops falling off.
|
||||
// The sound does not stop at that point, it just doesn't get any quieter.
|
||||
// You should rarely need to adjust this.
|
||||
// Default is 1000000000.0
|
||||
virtual void set_3d_max_distance(float dist);
|
||||
virtual float get_3d_max_distance() const;
|
||||
// Controls the maximum distance (in units) that this sound stops falling off.
|
||||
// The sound does not stop at that point, it just doesn't get any quieter.
|
||||
// You should rarely need to adjust this.
|
||||
// Default is 1000000000.0
|
||||
virtual void set_3d_max_distance(float dist);
|
||||
virtual float get_3d_max_distance() const;
|
||||
|
||||
enum SoundStatus { BAD, READY, PLAYING };
|
||||
virtual SoundStatus status() const = 0;
|
||||
virtual bool add_dsp(PT(AudioDSP) x);
|
||||
virtual bool remove_dsp(PT(AudioDSP) x);
|
||||
|
||||
protected:
|
||||
AudioSound();
|
||||
virtual float get_speaker_mix(int speaker);
|
||||
virtual void set_speaker_mix(float frontleft, float frontright, float center, float sub, float backleft, float backright, float sideleft, float sideright);
|
||||
|
||||
friend class AudioManager;
|
||||
virtual int get_priority();
|
||||
virtual void set_priority(int priority);
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
TypedReferenceCount::init_type();
|
||||
register_type(_type_handle, "AudioSound",
|
||||
TypedReferenceCount::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
enum SoundStatus { BAD, READY, PLAYING };
|
||||
virtual SoundStatus status() const = 0;
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
protected:
|
||||
AudioSound();
|
||||
|
||||
friend class AudioManager;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
TypedReferenceCount::init_type();
|
||||
register_type(_type_handle, "AudioSound",
|
||||
TypedReferenceCount::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#endif /* __AUDIOSOUND_H__ */
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "config_audio.cxx"
|
||||
#include "audioManager.cxx"
|
||||
#include "audioSound.cxx"
|
||||
#include "audioDSP.cxx"
|
||||
#include "nullAudioManager.cxx"
|
||||
#include "nullAudioSound.cxx"
|
||||
|
||||
|
@ -24,62 +24,38 @@
|
||||
Configure(config_audio);
|
||||
NotifyCategoryDef(audio, "");
|
||||
|
||||
|
||||
ConfigVariableBool audio_active
|
||||
("audio-active", true);
|
||||
|
||||
ConfigVariableInt audio_cache_limit
|
||||
("audio-cache-limit", 15,
|
||||
PRC_DESC("The number of sounds in the cache."));
|
||||
|
||||
ConfigVariableDouble audio_volume
|
||||
("audio-volume", 1.0f);
|
||||
|
||||
ConfigVariableDouble audio_doppler_factor
|
||||
("audio-doppler-factor", 1.0f);
|
||||
|
||||
ConfigVariableDouble audio_distance_factor
|
||||
("audio-distance-factor", 1.0f);
|
||||
|
||||
ConfigVariableDouble audio_drop_off_factor
|
||||
("audio-drop-off-factor", 1.0f);
|
||||
|
||||
ConfigVariableInt audio_min_hw_channels
|
||||
("audio-min-hw-channels", 15,
|
||||
PRC_DESC("Guarantee this many channels on the local sound card, or just "
|
||||
"play EVERYTHING in software."));
|
||||
|
||||
ConfigVariableBool audio_software_midi
|
||||
("audio-software-midi", false);
|
||||
|
||||
ConfigVariableFilename audio_dls_file
|
||||
("audio-dls-file", "");
|
||||
|
||||
ConfigVariableBool audio_play_midi
|
||||
("audio-play-midi", true);
|
||||
|
||||
ConfigVariableBool audio_play_wave
|
||||
("audio-play-wave", true);
|
||||
|
||||
ConfigVariableBool audio_play_mp3
|
||||
("audio-play-mp3", true);
|
||||
|
||||
ConfigVariableInt audio_output_rate
|
||||
("audio-output-rate", 22050);
|
||||
|
||||
ConfigVariableInt audio_output_bits
|
||||
("audio-output-bits", 16);
|
||||
|
||||
ConfigVariableInt audio_output_channels
|
||||
("audio-output-channels", 2);
|
||||
|
||||
ConfigVariableString audio_library_name
|
||||
("audio-library-name", "miles_audio");
|
||||
|
||||
//I should note this somewhere.
|
||||
//The actual number of sound one could play is 2 times whatever the default is here.
|
||||
//In this case 32 * 2 = 64.
|
||||
//The reason for this, is because of the way Panda creates two seperate audio managers.
|
||||
//One for sound effects, the other for music files.
|
||||
//At one time this used to be a concern, because wave files [WAV, AIF, MP3, etc...] and
|
||||
//Music files [MID MOD IT] used to be treated differently.
|
||||
//However in current Audio APIs [particularly FMOD] a sound file is treated the same
|
||||
//no matter what it is.
|
||||
ConfigVariableInt fmod_number_of_sound_channels
|
||||
("fmod-number-of-sound-channels", 32,
|
||||
PRC_DESC("Guarantee this many channels you will have with FMOD. AKA the max number of sounds you can play at one time.") );
|
||||
|
||||
ConfigVariableBool fmod_use_surround_sound
|
||||
("fmod-use-surround-sound", false,
|
||||
PRC_DESC("Determines if an FMOD Flavor of PANDA use 5.1 Surround Sound or Not.") );
|
||||
|
||||
|
||||
//ConfigVariableInt
|
||||
//ConfigVariableDouble
|
||||
//ConfigVariableBool
|
||||
//ConfigVariableFilename
|
||||
|
||||
|
||||
|
||||
ConfigureFn(config_audio) {
|
||||
AudioManager::init_type();
|
||||
AudioSound::init_type();
|
||||
AudioDSP::init_type();
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,29 +33,19 @@
|
||||
|
||||
NotifyCategoryDecl(audio, EXPCL_PANDA, EXPTP_PANDA);
|
||||
|
||||
extern EXPCL_PANDA ConfigVariableBool audio_active;
|
||||
extern EXPCL_PANDA ConfigVariableInt audio_cache_limit;
|
||||
extern EXPCL_PANDA ConfigVariableDouble audio_volume;
|
||||
|
||||
extern EXPCL_PANDA ConfigVariableDouble audio_doppler_factor;
|
||||
extern EXPCL_PANDA ConfigVariableDouble audio_distance_factor;
|
||||
extern EXPCL_PANDA ConfigVariableDouble audio_drop_off_factor;
|
||||
|
||||
extern EXPCL_PANDA ConfigVariableInt audio_min_hw_channels;
|
||||
|
||||
extern EXPCL_PANDA ConfigVariableBool audio_software_midi;
|
||||
extern EXPCL_PANDA ConfigVariableFilename audio_dls_file;
|
||||
|
||||
extern EXPCL_PANDA ConfigVariableBool audio_play_midi;
|
||||
extern EXPCL_PANDA ConfigVariableBool audio_play_wave;
|
||||
extern EXPCL_PANDA ConfigVariableBool audio_play_mp3;
|
||||
|
||||
extern EXPCL_PANDA ConfigVariableInt audio_output_rate;
|
||||
extern EXPCL_PANDA ConfigVariableInt audio_output_bits;
|
||||
extern EXPCL_PANDA ConfigVariableInt audio_output_channels;
|
||||
|
||||
//We Need This one.
|
||||
extern EXPCL_PANDA ConfigVariableString audio_library_name;
|
||||
|
||||
//This Specifies the number of possible [max] audio channels.
|
||||
extern EXPCL_PANDA ConfigVariableInt fmod_number_of_sound_channels;
|
||||
|
||||
//This is to turn on Surround Sound.
|
||||
extern EXPCL_PANDA ConfigVariableBool fmod_use_surround_sound;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef NDEBUG //[
|
||||
// Non-release build:
|
||||
#define audio_debug(msg) \
|
||||
|
187
panda/src/audio/nullAudioDSP.cxx
Normal file
187
panda/src/audio/nullAudioDSP.cxx
Normal file
@ -0,0 +1,187 @@
|
||||
// Filename: nullAudioDSP.cxx
|
||||
// Created by: Stan Rosenbaum "Staque" - Spring 2006
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "nullAudioDSP.h"
|
||||
|
||||
TypeHandle nullAudioDSP::_type_handle;
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::reset
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void nullAudioDSP::
|
||||
reset() {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::remove
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void nullAudioDSP::
|
||||
remove() {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::set_bypass
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void nullAudioDSP::
|
||||
set_bypass(bool bypass) {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::get_bypass
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool nullAudioDSP::get_bypass() {
|
||||
// intentionally blank
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::set_parameter
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void nullAudioDSP::
|
||||
set_parameter(const string &name, float value) {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::list_parameters_info
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void nullAudioDSP::
|
||||
list_parameters_info() {
|
||||
// intentionally blank
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::get_num_parameters
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int nullAudioDSP::
|
||||
get_num_parameters() {
|
||||
// intentionally blank
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::get_parameter_name
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string nullAudioDSP::
|
||||
get_parameter_name(int index) {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::get_parameter_description
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string nullAudioDSP::
|
||||
get_parameter_description(int index) {
|
||||
// intentionally blank
|
||||
return "";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::get_parameter_min
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float nullAudioDSP::
|
||||
get_parameter_min(int index) {
|
||||
// intentionally blank
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::get_parameter_max
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float nullAudioDSP::
|
||||
get_parameter_max(int index) {
|
||||
// intentionally blank
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::get_parameter_value
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float nullAudioDSP::
|
||||
get_parameter_value(const string &name) {
|
||||
// intentionally blank
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::Constructor
|
||||
// Access: Protected
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
nullAudioDSP::nullAudioDSP() {
|
||||
// Intentionally blank.
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: nullAudioDSP::Destructor
|
||||
// Access: Published, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
nullAudioDSP::~nullAudioDSP() {
|
||||
}
|
||||
|
80
panda/src/audio/nullAudioDSP.h
Normal file
80
panda/src/audio/nullAudioDSP.h
Normal file
@ -0,0 +1,80 @@
|
||||
// Filename: nullAudioDSP.h
|
||||
// Created by: Stan Rosenbaum "Staque" - Spring 2006
|
||||
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __NULLAUDIODSP_H__
|
||||
#define __NULLAUDIODSP_H__
|
||||
|
||||
#include "config_audio.h"
|
||||
#include "typedReferenceCount.h"
|
||||
#include "pointerTo.h"
|
||||
|
||||
class AudioManager;
|
||||
|
||||
|
||||
class EXPCL_PANDA nullAudioDSP : public TypedReferenceCount {
|
||||
PUBLISHED:
|
||||
virtual void reset();
|
||||
virtual void remove();
|
||||
virtual void set_bypass(bool bypass);
|
||||
virtual void set_parameter(const string &name, float value);
|
||||
virtual float get_parameter_value(const string &name);
|
||||
|
||||
virtual bool get_bypass();
|
||||
void list_parameters_info();
|
||||
|
||||
virtual int get_num_parameters();
|
||||
virtual string get_parameter_name(int index);
|
||||
virtual string get_parameter_description(int index);
|
||||
virtual float get_parameter_min(int index);
|
||||
virtual float get_parameter_max(int index);
|
||||
|
||||
|
||||
virtual ~nullAudioDSP();
|
||||
|
||||
protected:
|
||||
nullAudioDSP();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//These are needed for Panda's Pointer System. DO NOT ERASE!
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
TypedReferenceCount::init_type();
|
||||
register_type(_type_handle, "nullAudioDSP",
|
||||
TypedReferenceCount::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//DONE
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
|
||||
#endif /* __nullAudioDSP_H__ */
|
@ -23,6 +23,7 @@
|
||||
#include "config_fmodAudio.h"
|
||||
#include "fmodAudioManager.h"
|
||||
#include "fmodAudioSound.h"
|
||||
#include "fmodAudioDSP.h"
|
||||
#include "pandaSystem.h"
|
||||
#include "dconfig.h"
|
||||
|
||||
@ -52,6 +53,10 @@ init_libFmodAudio() {
|
||||
|
||||
AudioManager::register_AudioManager_creator(Create_AudioManager);
|
||||
|
||||
FmodAudioManager::init_type();
|
||||
FmodAudioSound::init_type();
|
||||
FmodAudioDSP::init_type();
|
||||
|
||||
PandaSystem *ps = PandaSystem::get_global_ptr();
|
||||
ps->add_system("FMOD");
|
||||
ps->add_system("audio");
|
||||
|
25
panda/src/audiotraits/fmodAudioDSP.I
Normal file
25
panda/src/audiotraits/fmodAudioDSP.I
Normal file
@ -0,0 +1,25 @@
|
||||
// Filename: fmodAudioDSP.I
|
||||
// Created by: Stan Rosenbaum "Staque" - Spring 2006
|
||||
//
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
451
panda/src/audiotraits/fmodAudioDSP.cxx
Normal file
451
panda/src/audiotraits/fmodAudioDSP.cxx
Normal file
@ -0,0 +1,451 @@
|
||||
// Filename: fmodAudioDSP.cxx
|
||||
// Created by: Stan Rosenbaum "Staque" - Spring 2006
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pandabase.h"
|
||||
#include "dcast.h"
|
||||
|
||||
#ifdef HAVE_FMOD //[
|
||||
|
||||
//Panda Headers
|
||||
#include "config_audio.h"
|
||||
#include "fmodAudioDSP.h"
|
||||
|
||||
|
||||
TypeHandle FmodAudioDSP::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::FmodAudioDSP
|
||||
// Access: Protected
|
||||
// Description: Constructor
|
||||
// This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
FmodAudioDSP::FmodAudioDSP(AudioManager *manager, AudioManager::DSP_category cat) {
|
||||
// Intentionally blank.
|
||||
|
||||
audio_debug("FmodAudioDSP::FmodAudioDSP() Creating new DSP " );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
//Assign the values we need
|
||||
DCAST_INTO_V(_manager, manager);
|
||||
|
||||
FMOD_DSP_TYPE dsptype = (FMOD_DSP_TYPE)cat;
|
||||
|
||||
result = _manager->_system->createDSPByType( dsptype, &_dsp);
|
||||
ERRCHECK(result);
|
||||
|
||||
set_in_chain(false);
|
||||
|
||||
cerr << get_dsp_name() << endl;
|
||||
|
||||
audio_debug("DSP Loaded");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::Destructor
|
||||
// Access: Published, Virtual
|
||||
// Description: DESTRUCTOR!!!
|
||||
////////////////////////////////////////////////////////////////////
|
||||
FmodAudioDSP::~FmodAudioDSP() {
|
||||
|
||||
audio_debug("FmodAudioSound::FmodAudioDSP() Destruction!!! " );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
result = _dsp->remove();
|
||||
ERRCHECK(result);
|
||||
|
||||
result = _dsp->release();
|
||||
ERRCHECK(result);
|
||||
|
||||
audio_debug("DSP GONE");
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::reset
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
// [This resets an FMOD DSP to its default values]
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FmodAudioDSP::reset() {
|
||||
|
||||
audio_debug("FmodAudioSound::reset() Reset DSP to default settings." );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
result = _dsp->reset();
|
||||
ERRCHECK(result);
|
||||
|
||||
audio_debug("DSP Reset.");
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::remove
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
// [This removes the DSP from an Effects Chain]
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FmodAudioDSP::remove() {
|
||||
audio_debug("FmodAudioSound::remove() Removes a DSP from and effect chain." );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
result = _dsp->remove();
|
||||
ERRCHECK(result);
|
||||
|
||||
audio_debug("DSP Removed from relative effects chain.");
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::set_bypass
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
// [This turns the Bypass for an Effect on and off]/
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FmodAudioDSP::set_bypass(bool bypass) {
|
||||
audio_debug("FmodAudioSound::set_bypass() ." );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
result = _dsp->setBypass(bypass);
|
||||
ERRCHECK(result);
|
||||
|
||||
audio_debug("DSP Bypass set to:" << bypass );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::get_bypass
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool FmodAudioDSP::get_bypass() {
|
||||
audio_debug("FmodAudioSound::get_bypass() ." );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
bool bypass;
|
||||
|
||||
result = _dsp->getBypass(&bypass);
|
||||
ERRCHECK(result);
|
||||
|
||||
return bypass;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::set_parameter
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FmodAudioDSP::set_parameter(const string &name, float value) {
|
||||
|
||||
int parameterIndex = find_parameter(name);
|
||||
if (parameterIndex < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
result = _dsp->setParameter(parameterIndex, value);
|
||||
ERRCHECK(result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::get_num_parameters
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int FmodAudioDSP::get_num_parameters() {
|
||||
audio_debug("FmodAudioSound::get_num_parameters() ." );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
int numOfParameters;
|
||||
|
||||
result = _dsp->getNumParameters(&numOfParameters);
|
||||
ERRCHECK(result);
|
||||
|
||||
return numOfParameters;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::get_parameter_name
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string FmodAudioDSP::get_parameter_name(int parameterIndex) {
|
||||
// intentionally blank
|
||||
|
||||
audio_debug("FmodAudioSound::get_parameter_name()" );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
//int parameterIndex;
|
||||
char parameterName[32];
|
||||
char parameterLabel[32];
|
||||
char parameterDescription[32];
|
||||
int parameterDescriptionLength = 0;
|
||||
float parameterMin;
|
||||
float parameterMax;
|
||||
|
||||
result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax);
|
||||
ERRCHECK(result);
|
||||
|
||||
string returnInfo = (parameterName);
|
||||
|
||||
return returnInfo;
|
||||
|
||||
//return "";
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::get_parameter_description
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
// This Method actually returns FMOD's Parameter Label
|
||||
// Information, and not Description.
|
||||
// The reason is, that most of the FMOD's Description
|
||||
// Properties seem to be empty.
|
||||
// Also the Label sort of serves as as a description by
|
||||
// return the type of unit the cooresponding parameter
|
||||
// modifies for a DSP.
|
||||
// IE. For the Echo. The first parameter is 'Delay'
|
||||
// and the units for measuring the Delay is in Milliseconds.
|
||||
// The Label returns Milliseconds letting you know that.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string FmodAudioDSP::get_parameter_description(int parameterIndex) {
|
||||
// intentionally blank
|
||||
|
||||
audio_debug("FmodAudioSound::get_parameter_description()." );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
//int parameterIndex;
|
||||
char parameterName[32];
|
||||
char parameterLabel[32];
|
||||
char parameterDescription[32];
|
||||
int parameterDescriptionLength = 0;
|
||||
float parameterMin;
|
||||
float parameterMax;
|
||||
|
||||
result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax);
|
||||
ERRCHECK(result);
|
||||
|
||||
return parameterLabel;
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::get_parameter_min
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float FmodAudioDSP::get_parameter_min(int parameterIndex) {
|
||||
|
||||
audio_debug("FmodAudioSound::get_parameter_min()." );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
//int parameterIndex;
|
||||
char parameterName[32];
|
||||
char parameterLabel[32];
|
||||
char parameterDescription[32];
|
||||
int parameterDescriptionLength = 0;
|
||||
float parameterMin;
|
||||
float parameterMax;
|
||||
|
||||
result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax);
|
||||
ERRCHECK(result);
|
||||
|
||||
return parameterMin;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::get_parameter_max
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float FmodAudioDSP::get_parameter_max(int parameterIndex) {
|
||||
|
||||
audio_debug("FmodAudioSound::get_parameter_min()." );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
//int parameterIndex;
|
||||
char parameterName[32];
|
||||
char parameterLabel[32];
|
||||
char parameterDescription[32];
|
||||
int parameterDescriptionLength = 0;
|
||||
float parameterMin;
|
||||
float parameterMax;
|
||||
|
||||
result = _dsp->getParameterInfo(parameterIndex, parameterName, parameterLabel, parameterDescription, parameterDescriptionLength, ¶meterMin, ¶meterMax);
|
||||
ERRCHECK(result);
|
||||
|
||||
return parameterMax;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::get_parameter_value
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
float FmodAudioDSP::get_parameter_value(const string &name) {
|
||||
|
||||
int parameterIndex = find_parameter(name);
|
||||
if (parameterIndex < 0) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
|
||||
float parameterValue;
|
||||
char valuestr[32];
|
||||
int valuestrlen = 32;
|
||||
|
||||
|
||||
result = _dsp->getParameter(parameterIndex, ¶meterValue, valuestr, valuestrlen);
|
||||
ERRCHECK(result);
|
||||
|
||||
return parameterValue;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::find_parameter
|
||||
// Access: Private
|
||||
// Description: Convert a parameter name to an fmod parameter index.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int FmodAudioDSP::find_parameter(const string &name) {
|
||||
int np = get_num_parameters();
|
||||
for (int i=0; i<np; i++) {
|
||||
if ( name == get_parameter_name(i) ) {
|
||||
|
||||
audio_debug("FmodAudioSound::find_parameter() returning: " << get_parameter_name(i) << " " << i );
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::get_dsp_name()
|
||||
// Access: Protected
|
||||
// Description: This is a thin wrapper around FMOD-EX.
|
||||
// See the FMOD-EX documentation.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
string FmodAudioDSP::get_dsp_name() {
|
||||
|
||||
audio_debug("FmodAudioSound::get_dsp_name()." );
|
||||
|
||||
//Local Variables that are needed.
|
||||
FMOD_RESULT result;
|
||||
char name[32];
|
||||
unsigned int version;
|
||||
int channels;
|
||||
int configwidth;
|
||||
int configheight;
|
||||
|
||||
result = _dsp->getInfo(name, &version, &channels, &configwidth, &configheight);
|
||||
ERRCHECK(result);
|
||||
|
||||
string returnInfo = (name);
|
||||
//returnInfo.append(" Version: ");
|
||||
//returnInfo.append(version);
|
||||
//returnInfo.append("\n");
|
||||
|
||||
return returnInfo;
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::get_in_chain()
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a functiont to query if a DSP have been assigned
|
||||
// to the GLOBAL or a SOUND's effect chain.
|
||||
// This is to make sure you 'remove' an effect from a chain
|
||||
// before you move it somewhere else or destroy it.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool FmodAudioDSP::get_in_chain() {
|
||||
|
||||
audio_debug("FmodAudioSound::get_in_chain()." );
|
||||
|
||||
return _in_chain;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FmodAudioDSP::set_in_chain()
|
||||
// Access: Published, Virtual
|
||||
// Description: This is a functiont to set if a DSP have been assigned
|
||||
// to the GLOBAL or a SOUND's effect chain.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FmodAudioDSP::set_in_chain(bool chain_state) {
|
||||
|
||||
audio_debug("FmodAudioSound::set_in_chain()." );
|
||||
|
||||
_in_chain = chain_state;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //]
|
164
panda/src/audiotraits/fmodAudioDSP.h
Normal file
164
panda/src/audiotraits/fmodAudioDSP.h
Normal file
@ -0,0 +1,164 @@
|
||||
// Filename: fmodAudioDSP.h
|
||||
// Created by: Stan Rosenbaum "Staque" - Spring 2006
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//[FIRST READ FmodAudioManager and then maybe FmodAudioSound for an Introduction
|
||||
//if you haven't already].
|
||||
//
|
||||
//Hello, all future Panda audio code people! This is my errata documentation to
|
||||
//Help any future programmer maintain FMOD and PANDA.
|
||||
//
|
||||
//Finally let’s talk about the DSP, or Digital Signal Processing. To the layman,
|
||||
//these are filters and shaders for sound.
|
||||
//
|
||||
//Currently FmodAudioDSP give you access to all of FMOD’s built in DSP functions.
|
||||
//
|
||||
//The enumerated list for the types are found in the ‘AudioManager.h’, but I will
|
||||
//repeat it here for good fortune.
|
||||
//
|
||||
// enum DSP_category {
|
||||
// // These enumerants line up one-to-one
|
||||
// // with the FMOD DSP enumerants.
|
||||
// DSP_unknown,
|
||||
// DSP_mixer,
|
||||
// DSP_oscillator,
|
||||
// DSP_lowpass,
|
||||
// DSP_itlowpass,
|
||||
// DSP_highpass,
|
||||
// DSP_echo,
|
||||
// DSP_flange,
|
||||
// DSP_distortion,
|
||||
// DSP_normalize,
|
||||
// DSP_parameq,
|
||||
// DSP_pitchshift,
|
||||
// DSP_chorus,
|
||||
// DSP_reverb,
|
||||
// DSP_vstplugin,
|
||||
// DSP_winampplugin,
|
||||
// DSP_itecho,
|
||||
// DSP_COUNT
|
||||
// };
|
||||
//
|
||||
//Now, I want to point a couple things out. First, we have to place the above list
|
||||
//in AudioManager.h because that was the only way to them to be ‘PUBLISHED’ in
|
||||
//Panda’s Python bindings when you build Panda.
|
||||
//
|
||||
//Second, you only need to use the ‘it####’ named DSP effects if you are using
|
||||
//mod/tracker files. [If you don’t know what a mod/tracker file is you probably
|
||||
//aren’t using them so don’t worry about it.]
|
||||
//
|
||||
//I think that is everything, the DSP info was pretty short.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
|
||||
|
||||
#ifndef __FMOD_AUDIO_DSP_H__
|
||||
#define __FMOD_AUDIO_DSP_H__
|
||||
|
||||
#include <pandabase.h>
|
||||
|
||||
#ifdef HAVE_FMOD //[
|
||||
|
||||
#include "audioManager.h"
|
||||
#include "audioDSP.h"
|
||||
|
||||
#include <fmod.hpp>
|
||||
#include <fmod_errors.h>
|
||||
|
||||
class EXPCL_FMOD_AUDIO FmodAudioDSP : public AudioDSP {
|
||||
|
||||
public:
|
||||
|
||||
FmodAudioDSP(AudioManager *mgr, AudioManager::DSP_category);
|
||||
|
||||
virtual void reset();
|
||||
virtual void remove();
|
||||
virtual void set_bypass(bool bypass);
|
||||
virtual void set_parameter(const string &name, float value);
|
||||
virtual float get_parameter_value(const string &name);
|
||||
|
||||
virtual bool get_bypass();
|
||||
|
||||
virtual int get_num_parameters();
|
||||
virtual string get_parameter_name(int index);
|
||||
virtual string get_parameter_description(int index);
|
||||
virtual float get_parameter_min(int index);
|
||||
virtual float get_parameter_max(int index);
|
||||
|
||||
bool get_in_chain();
|
||||
void set_in_chain(bool chain_state);
|
||||
|
||||
virtual ~FmodAudioDSP();
|
||||
|
||||
protected:
|
||||
virtual string get_dsp_name();
|
||||
|
||||
|
||||
private:
|
||||
int find_parameter(const string &pn);
|
||||
|
||||
bool _in_chain;
|
||||
FmodAudioManager *_manager;
|
||||
FMOD::DSP *_dsp;
|
||||
|
||||
friend class FmodAudioManager;
|
||||
friend class FmodAudioSound;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//These are needed for Panda's Pointer System. DO NOT ERASE!
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
AudioDSP::init_type();
|
||||
register_type(_type_handle, "FmodAudioDSP", AudioDSP::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {
|
||||
init_type();
|
||||
return get_class_type();
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//DONE
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
|
||||
#include "fmodAudioDSP.I"
|
||||
|
||||
#endif //]
|
||||
|
||||
#endif /* __FMOD_AUDIO_DSP_H__ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,8 @@
|
||||
// Created by: cort (January 22, 2003)
|
||||
// Extended by: ben (October 22, 2003)
|
||||
// Prior system by: cary
|
||||
// Rewrite [for new Version of FMOD-EX] by: Stan Rosenbaum "Staque" - Spring 2006
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -18,147 +20,233 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//Hello, all future Panda audio code people! This is my errata documentation to
|
||||
//help any future programmer maintain FMOD and PANDA.
|
||||
//
|
||||
//This documentation more then that is needed, but I wanted to go all out, with
|
||||
//the documentation. Because I was a totally newbie at programming [especially
|
||||
//with C/C++] this semester I want to make sure future code maintainers have that
|
||||
//insight I did not when starting on the PANDA project here at the ETC/CMU.
|
||||
//
|
||||
//As of Spring 2006, Panda's FMOD audio support has been pretty much completely
|
||||
//rewritten. This has been done so PANDA can use FMOD-EX [or AKA FMOD 4] and some
|
||||
//of its new features.
|
||||
//
|
||||
//First, the FMOD-EX API itself has been completely rewritten compared to previous
|
||||
//versions. FMOD now handles any type of audio files, wave audio [WAV, AIF, MP3,
|
||||
//OGG, etc...] or musical file [MID, TRACKERS] as the same type of an object. The
|
||||
//API has also been structured more like a sound studio, with 'sounds' and
|
||||
//'channels'. This will be covered more in the FmodAudioSound.h/.cxx sources.
|
||||
//
|
||||
//Second, FMOD now offers virtually unlimited sounds to be played at once via
|
||||
//their virtual channels system. Actually the theoretical limit is around 4000,
|
||||
//but that is still a lot. What you need to know about this, is that even thought
|
||||
//you might only hear 32 sound being played at once, FMOD will keep playing any
|
||||
//additional sounds, and swap those on virtual channels in and out with those on real channels
|
||||
//depending on priority, or distance [if you are dealing with 3D audio].
|
||||
//
|
||||
//Third, FMOD's DSP support has been added. So you can now add GLOBAL or SOUND
|
||||
//specific DSP effects. Right not you can only use FMOD's built in DSP effects.
|
||||
//But adding support for FMOD's support of VST effects shouldn't be that hard.
|
||||
//
|
||||
//As for the FmodManager itself, it is pretty straight forward, I hope. As a
|
||||
//manager class, it will create the FMOD system with the ‘_system’ variable which
|
||||
//is an instance of FMOD::SYSTEM. This class is also the one responsible for
|
||||
//creation of Sounds, DSP, and maintaining the GLOBAL DSP chains [The GLOBAL DSP
|
||||
//chain is the DSP Chain which affects ALL the sounds].
|
||||
//
|
||||
//Any way that is it for an intro, lets move on to looking at the rest of the
|
||||
//code.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef __FMOD_AUDIO_MANAGER_H__
|
||||
#define __FMOD_AUDIO_MANAGER_H__
|
||||
|
||||
//First the includes.
|
||||
#include "pandabase.h"
|
||||
#include "pset.h"
|
||||
|
||||
#ifdef HAVE_FMOD //[
|
||||
|
||||
#include "audioManager.h"
|
||||
class FmodAudioSound;
|
||||
#include "filename.h"
|
||||
#include "pdeque.h"
|
||||
#include "pmap.h"
|
||||
#include "pset.h"
|
||||
|
||||
#include <fmod.h> // Is fmod.h really a system file? I think maybe this should be "fmod.h".
|
||||
//The Includes needed for FMOD
|
||||
#include <fmod.hpp>
|
||||
#include <fmod_errors.h>
|
||||
|
||||
class FmodAudioSound;
|
||||
class FmodAudioDSP;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// OK I am not sure if there is the best place for this one,
|
||||
// but it seems to work. IE, the FmodSound and FmodDSP classes can find it.
|
||||
// All FMOD API calls return a success or failure error.
|
||||
// [I am sure there is a name for this type of programming but I don't know it.]
|
||||
// Anyway, by adding the line "notify-level-audio debug" to the config.prc file
|
||||
// of Panda, of the config.in file of MAKEPANDA, you can see the Debugs printed out at the
|
||||
// Python Prompt
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
void ERRCHECK(FMOD_RESULT result);
|
||||
|
||||
|
||||
class EXPCL_FMOD_AUDIO FmodAudioManager : public AudioManager {
|
||||
// All of these methods are stubbed out to some degree.
|
||||
// If you're looking for a starting place for a new AudioManager,
|
||||
// please consider looking at the milesAudioManager.
|
||||
|
||||
public:
|
||||
FmodAudioManager();
|
||||
virtual ~FmodAudioManager();
|
||||
|
||||
virtual bool is_valid();
|
||||
|
||||
virtual PT(AudioSound) get_sound(const string&, bool positional = false);
|
||||
virtual void uncache_sound(const string&);
|
||||
virtual void clear_cache();
|
||||
virtual void set_cache_limit(unsigned int count);
|
||||
virtual unsigned int get_cache_limit() const;
|
||||
// All of these methods are stubbed out to some degree.
|
||||
// If you're looking for a starting place for a new AudioManager,
|
||||
// please consider looking at the milesAudioManager.
|
||||
friend class FmodAudioSound;
|
||||
friend class FmodAudioDSP;
|
||||
|
||||
// Indicates that the given sound was the most recently used.
|
||||
void most_recently_used(const string& path);
|
||||
public:
|
||||
|
||||
// Uncaches the least recently used sound.
|
||||
bool uncache_a_sound();
|
||||
//Constructor and Destructor
|
||||
FmodAudioManager();
|
||||
virtual ~FmodAudioManager();
|
||||
|
||||
virtual void set_volume(float);
|
||||
virtual float get_volume() const;
|
||||
|
||||
virtual void set_active(bool);
|
||||
virtual bool get_active() const;
|
||||
virtual bool is_valid();
|
||||
|
||||
virtual PT(AudioSound) get_sound(const string&, bool positional = false);
|
||||
|
||||
virtual PT(AudioDSP) create_dsp(DSP_category);
|
||||
virtual bool add_dsp(PT(AudioDSP) dspToAdd);
|
||||
virtual bool remove_dsp(PT(AudioDSP) x);
|
||||
|
||||
virtual void set_concurrent_sound_limit(unsigned int limit = 0);
|
||||
virtual unsigned int get_concurrent_sound_limit() const;
|
||||
virtual int getSpeakerSetup();
|
||||
virtual void setSpeakerSetup(SPEAKERMODE_category cat);
|
||||
|
||||
virtual void reduce_sounds_playing_to(unsigned int count);
|
||||
virtual void set_volume(float);
|
||||
virtual float get_volume() const;
|
||||
|
||||
virtual void set_active(bool);
|
||||
virtual bool get_active() const;
|
||||
|
||||
//virtual void stop_a_sound();
|
||||
virtual void stop_all_sounds();
|
||||
virtual void stop_all_sounds();
|
||||
|
||||
// Changes to the positions of 3D spacialized sounds and the listener
|
||||
// are all made at once when this method is called. It should be put
|
||||
// in the main program loop.
|
||||
virtual void audio_3d_update();
|
||||
// Changes to the positions of 3D spacialized sounds and the listener
|
||||
// are all made at once when this method is called. It should be put
|
||||
// in the main program loop.
|
||||
virtual void audio_3d_update();
|
||||
|
||||
// This controls the "set of ears" that listens to 3D spacialized sound
|
||||
// px, py, pz are position coordinates. Can be 0.0f to ignore.
|
||||
// vx, vy, vz are a velocity vector in UNITS PER SECOND (default: meters).
|
||||
// fx, fy and fz are the respective components of a unit forward-vector
|
||||
// ux, uy and uz are the respective components of a unit up-vector
|
||||
// These changes will NOT be invoked until audio_3d_update() is called.
|
||||
virtual void audio_3d_set_listener_attributes(float px, float py, float pz,
|
||||
float vx, float xy, float xz,
|
||||
float fx, float fy, float fz,
|
||||
float ux, float uy, float uz);
|
||||
virtual void audio_3d_get_listener_attributes(float *px, float *py, float *pz,
|
||||
float *vx, float *vy, float *vz,
|
||||
float *fx, float *fy, float *fz,
|
||||
float *ux, float *uy, float *uz);
|
||||
|
||||
// Control the "relative distance factor" for 3D spacialized audio. Default is 1.0
|
||||
// Fmod uses meters internally, so give a float in Units-per meter
|
||||
// Don't know what Miles uses.
|
||||
virtual void audio_3d_set_distance_factor(float factor);
|
||||
virtual float audio_3d_get_distance_factor() const;
|
||||
// This controls the "set of ears" that listens to 3D spacialized sound
|
||||
// px, py, pz are position coordinates. Can be 0.0f to ignore.
|
||||
// vx, vy, vz are a velocity vector in UNITS PER SECOND (default: meters).
|
||||
// fx, fy and fz are the respective components of a unit forward-vector
|
||||
// ux, uy and uz are the respective components of a unit up-vector
|
||||
// These changes will NOT be invoked until audio_3d_update() is called.
|
||||
virtual void audio_3d_set_listener_attributes(float px, float py, float pz,
|
||||
float vx, float xy, float xz,
|
||||
float fx, float fy, float fz,
|
||||
float ux, float uy, float uz);
|
||||
|
||||
// Control the presence of the Doppler effect. Default is 1.0
|
||||
// Exaggerated Doppler, use >1.0
|
||||
// Diminshed Doppler, use <1.0
|
||||
virtual void audio_3d_set_doppler_factor(float factor);
|
||||
virtual float audio_3d_get_doppler_factor() const;
|
||||
// REMOVE THIS ONE
|
||||
virtual void audio_3d_get_listener_attributes(float *px, float *py, float *pz,
|
||||
float *vx, float *vy, float *vz,
|
||||
float *fx, float *fy, float *fz,
|
||||
float *ux, float *uy, float *uz);
|
||||
|
||||
// Control the "relative distance factor" for 3D spacialized audio. Default is 1.0
|
||||
// Fmod uses meters internally, so give a float in Units-per meter
|
||||
// Don't know what Miles uses.
|
||||
virtual void audio_3d_set_distance_factor(float factor);
|
||||
virtual float audio_3d_get_distance_factor() const;
|
||||
|
||||
// Exaggerate or diminish the effect of distance on sound. Default is 1.0
|
||||
// Faster drop off, use >1.0
|
||||
// Slower drop off, use <1.0
|
||||
virtual void audio_3d_set_drop_off_factor(float factor);
|
||||
virtual float audio_3d_get_drop_off_factor() const;
|
||||
// Control the presence of the Doppler effect. Default is 1.0
|
||||
// Exaggerated Doppler, use >1.0
|
||||
// Diminshed Doppler, use <1.0
|
||||
virtual void audio_3d_set_doppler_factor(float factor);
|
||||
virtual float audio_3d_get_doppler_factor() const;
|
||||
|
||||
protected:
|
||||
// increment or decrement the refcount of the given file's cache entry.
|
||||
// sounds can only be uncached when their refcounts are zero.
|
||||
void inc_refcount(const string& file_name);
|
||||
void dec_refcount(const string& file_name);
|
||||
private:
|
||||
typedef struct {
|
||||
size_t size; // size of the data field, in bytes
|
||||
unsigned int refcount; // how many AudioSound objects are referencing me?
|
||||
bool stale; // can this entry be purged from the cache?
|
||||
char *data; // the memory-mapped audio file.
|
||||
} SoundCacheEntry;
|
||||
typedef phash_map<string, SoundCacheEntry, string_hash> SoundMap;
|
||||
SoundMap _sounds;
|
||||
// Exaggerate or diminish the effect of distance on sound. Default is 1.0
|
||||
// Faster drop off, use >1.0
|
||||
// Slower drop off, use <1.0
|
||||
virtual void audio_3d_set_drop_off_factor(float factor);
|
||||
virtual float audio_3d_get_drop_off_factor() const;
|
||||
|
||||
typedef phash_set<FmodAudioSound*, pointer_hash> AudioSet;
|
||||
// The offspring of this manager:
|
||||
AudioSet _soundsOnLoan;
|
||||
unsigned int _concurrent_sound_limit;
|
||||
//THESE ARE NOT USED ANYMORE.
|
||||
//THEY ARE ONLY HERE BECAUSE THEY are still needed by Miles.
|
||||
//THESE are stubs in FMOD-EX version
|
||||
////////////////////////////////////////////////////////////////////
|
||||
virtual void set_concurrent_sound_limit(unsigned int limit = 0);
|
||||
virtual unsigned int get_concurrent_sound_limit() const;
|
||||
virtual void reduce_sounds_playing_to(unsigned int count);
|
||||
virtual void uncache_sound(const string&);
|
||||
virtual void clear_cache();
|
||||
virtual void set_cache_limit(unsigned int count);
|
||||
virtual unsigned int get_cache_limit() const;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef phash_set<FmodAudioSound*, pointer_hash> SoundsPlaying;
|
||||
// The sounds from this manager that are currently playing
|
||||
SoundsPlaying _sounds_playing;
|
||||
protected:
|
||||
|
||||
// The Least Recently Used mechanism:
|
||||
typedef pdeque<string> LRU;
|
||||
LRU _lru;
|
||||
// This is the main FMOD system varible. Without it you got nothing.
|
||||
FMOD::System *_system;
|
||||
|
||||
// RobCode
|
||||
// List of supported sound formats
|
||||
typedef pvector<string> SupportedTypes;
|
||||
SupportedTypes _supported_types;
|
||||
private:
|
||||
|
||||
void release_sound(FmodAudioSound *audioSound);
|
||||
// This varible is something to receive the FMOD_RESULTs which we use to check
|
||||
// FMOD's State
|
||||
FMOD_VECTOR _position;
|
||||
FMOD_VECTOR _velocity;
|
||||
FMOD_VECTOR _forward;
|
||||
FMOD_VECTOR _up;
|
||||
|
||||
int _cache_limit;
|
||||
static int _active_managers;
|
||||
bool _is_valid;
|
||||
bool _active;
|
||||
float _volume;
|
||||
float _listener_pos [3];
|
||||
float _listener_vel [3];
|
||||
float _listener_forward [3];
|
||||
float _listener_up [3];
|
||||
float _distance_factor;
|
||||
float _doppler_factor;
|
||||
float _drop_off_factor;
|
||||
|
||||
char* load(const Filename& filename, size_t &size) const;
|
||||
|
||||
friend class FmodAudioSound;
|
||||
bool _is_valid;
|
||||
bool _active;
|
||||
|
||||
float _distance_factor;
|
||||
float _doppler_factor;
|
||||
float _drop_off_factor;
|
||||
|
||||
//The Data Structure that holds all the sounds.
|
||||
//BTW. Notice that this IS NOT A PT Structure.
|
||||
//It probably should never bee either.
|
||||
//We tried it as a PT, and you run into a problem with
|
||||
//PANDA's garbage collection system, when you finally get around
|
||||
//to destroying the sounds.
|
||||
//So you are probably wondering why we even need a set like the one below by now.
|
||||
//Mainly becuase we need something for the 'stop_all_sounds()' function.
|
||||
//Which does just take it stop all the sounds at once [and believe it is needed at times.]
|
||||
typedef pset<FmodAudioSound *> SoundSet;
|
||||
SoundSet _all_sounds;
|
||||
|
||||
//The Data Structure that holds all the DSPs.
|
||||
typedef pset<PT (FmodAudioDSP) > DSPSet;
|
||||
DSPSet _system_dsp;
|
||||
|
||||
friend class FmodAudioSound;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//These are needed for Panda's Pointer System. DO NOT ERASE!
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
AudioManager::init_type();
|
||||
register_type(_type_handle, "FmodAudioManager", AudioManager::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {
|
||||
init_type();
|
||||
return get_class_type();
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//DONE
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
||||
|
||||
EXPCL_FMOD_AUDIO PT(AudioManager) Create_AudioManager();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,8 @@
|
||||
// Filename: fmodAudioSound.h
|
||||
// Created by: cort (January 22, 2003)
|
||||
// Prior system by: cary
|
||||
// Rewrite [for new Version of FMOD-EX] by: Stan Rosenbaum "Staque" - Spring 2006
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -16,117 +18,237 @@
|
||||
// panda3d-general@lists.sourceforge.net .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//[FIRST READ FmodAudioManager for an Introduction if you haven't already].
|
||||
//
|
||||
//Hello, all future Panda audio code people! This is my errata documentation to
|
||||
//Help any future programmer maintain FMOD and PANDA.
|
||||
//
|
||||
//Well, if you reading this you probably want to know how PANDA deals with sounds
|
||||
//directly using FMOD-EX. Well I am going to tell you.
|
||||
//
|
||||
//The first thing, you as the programmer have to understand, especially if you
|
||||
//never have done sound programming before, is how the FMOD-EX API works.
|
||||
//
|
||||
//With FMOD-EX the guys at Firelight, adopted a model of managing sounds with FMOD
|
||||
//similar to how a Sound Designer creates sound in a sound studio using ‘SOUNDS’
|
||||
//and ‘CHANNELS’. Although this may seem strange at first, if you are not familiar
|
||||
//with sound programming, there is a very good metaphor you are probably already
|
||||
//familiar with to explain how FMOD-EX works.
|
||||
//
|
||||
//Think of you standard GUI API. Usually a GUI API is made up of two things:
|
||||
//Windows and Widgets. These correspond to ‘CHANNELS’ and ‘SOUNDS’, where a
|
||||
//Channel is a Window and a Sound is Widget. Sounds are played within channels,
|
||||
//and channels don’t exist unless they have something to display.
|
||||
//
|
||||
//Now why am I explaining all of this? When PANDA was created they set up the
|
||||
//basic audio classes to handle only the idea of a ‘SOUND’. The idea of a
|
||||
//‘Channel’ really wasn't prevalent as in more modern Audio APIs. With this rewrite
|
||||
//of PANDA to use the FMOD-EX API, the PANDA FmodAudioSound Class, now has to
|
||||
//handle two different parts of the FMOD-EX API in order to play a sound.
|
||||
//
|
||||
//SOUND: The object the handles the audio data in form of WAV, AIF, OGG, MID, IT,
|
||||
//MP3, etc... And CHANNEL: The object that actually plays the sound and
|
||||
//manipulates it in real time.
|
||||
//
|
||||
//Ultimately this isn’t a problem expect for a couple situations when you go to
|
||||
//play a sound, which I will explain in more detail in that part of the code. All
|
||||
//that you have to know right now is that ‘Channels’ in FMOD do not exist
|
||||
//unless they are playing a sound. And in the PANDA FmodAudioSound API class there
|
||||
//is only ONE dedicated channel per sound.
|
||||
//Otherwise there is really nothing to worry about.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef __FMOD_AUDIO_SOUND_H__
|
||||
#define __FMOD_AUDIO_SOUND_H__
|
||||
|
||||
#include <pandabase.h>
|
||||
|
||||
#ifdef HAVE_FMOD //[
|
||||
|
||||
#include "audioSound.h"
|
||||
class FmodAudioManager;
|
||||
#include <fmod.h>
|
||||
|
||||
#include <fmod.hpp>
|
||||
#include <fmod_errors.h>
|
||||
|
||||
class FmodAudioDSP;
|
||||
|
||||
|
||||
class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound {
|
||||
public:
|
||||
~FmodAudioSound();
|
||||
|
||||
// For best compatability, set the loop_count, start_time,
|
||||
// volume, and balance, prior to calling play(). You may
|
||||
// set them while they're playing, but it's implementation
|
||||
// specific whether you get the results.
|
||||
void play();
|
||||
void stop();
|
||||
|
||||
// loop: false = play once; true = play forever.
|
||||
// inits to false.
|
||||
void set_loop(bool loop=true);
|
||||
bool get_loop() const;
|
||||
|
||||
// loop_count: 0 = forever; 1 = play once; n = play n times.
|
||||
// inits to 1.
|
||||
void set_loop_count(unsigned long loop_count=1);
|
||||
unsigned long get_loop_count() const;
|
||||
|
||||
// 0 = begining; length() = end.
|
||||
// inits to 0.0.
|
||||
void set_time(float start_time=0.0);
|
||||
float get_time() const;
|
||||
|
||||
// 0 = minimum; 1.0 = maximum.
|
||||
// inits to 1.0.
|
||||
void set_volume(float volume=1.0);
|
||||
float get_volume() const;
|
||||
|
||||
// -1.0 is hard left
|
||||
// 0.0 is centered
|
||||
// 1.0 is hard right
|
||||
// inits to 0.0.
|
||||
void set_balance(float balance_right=0.0);
|
||||
float get_balance() const;
|
||||
public:
|
||||
|
||||
// play_rate is any positive float value.
|
||||
// inits to 1.0.
|
||||
void set_play_rate(float play_rate=1.0f);
|
||||
float get_play_rate() const;
|
||||
FmodAudioSound(AudioManager *manager, string file_name, bool positional );
|
||||
~FmodAudioSound();
|
||||
|
||||
// For best compatability, set the loop_count, start_time,
|
||||
// volume, and balance, prior to calling play(). You may
|
||||
// set them while they're playing, but it's implementation
|
||||
// specific whether you get the results.
|
||||
void play();
|
||||
void stop();
|
||||
|
||||
// loop: false = play once; true = play forever.
|
||||
// inits to false.
|
||||
void set_loop(bool loop=true);
|
||||
bool get_loop() const;
|
||||
|
||||
// loop_count: 0 = forever; 1 = play once; n = play n times.
|
||||
// inits to 1.
|
||||
void set_loop_count(unsigned long loop_count=1);
|
||||
unsigned long get_loop_count() const;
|
||||
|
||||
// 0 = begining; length() = end.
|
||||
// inits to 0.0.
|
||||
void set_time(float start_time=0.0);
|
||||
float get_time() const;
|
||||
|
||||
// 0 = minimum; 1.0 = maximum.
|
||||
// inits to 1.0.
|
||||
void set_volume(float volume=1.0);
|
||||
float get_volume() const;
|
||||
|
||||
// -1.0 is hard left
|
||||
// 0.0 is centered
|
||||
// 1.0 is hard right
|
||||
// inits to 0.0.
|
||||
void set_balance(float balance_right=0.0);
|
||||
float get_balance() const;
|
||||
|
||||
// inits to manager's state.
|
||||
void set_active(bool active=true);
|
||||
bool get_active() const;
|
||||
// play_rate is any positive float value.
|
||||
// inits to 1.0.
|
||||
void set_play_rate(float play_rate=1.0f);
|
||||
float get_play_rate() const;
|
||||
|
||||
void set_finished_event(const string& event);
|
||||
const string& get_finished_event() const;
|
||||
|
||||
const string& get_name() const;
|
||||
|
||||
// return: playing time in seconds.
|
||||
float length() const;
|
||||
const string& get_name() const;
|
||||
|
||||
// return: playing time in seconds.
|
||||
float length() const;
|
||||
|
||||
// Controls the position of this sound's emitter.
|
||||
// pos is a pointer to an xyz triplet of the emitter's position.
|
||||
// vel is a pointer to an xyz triplet of the emitter's velocity.
|
||||
void set_3d_attributes(float px, float py, float pz,
|
||||
float vx, float vy, float vz);
|
||||
void get_3d_attributes(float *px, float *py, float *pz,
|
||||
float *vx, float *vy, float *vz);
|
||||
void set_3d_min_distance(float dist);
|
||||
float get_3d_min_distance() const;
|
||||
void set_3d_max_distance(float dist);
|
||||
float get_3d_max_distance() const;
|
||||
|
||||
AudioSound::SoundStatus status() const;
|
||||
// Controls the position of this sound's emitter.
|
||||
// pos is a pointer to an xyz triplet of the emitter's position.
|
||||
// vel is a pointer to an xyz triplet of the emitter's velocity.
|
||||
void set_3d_attributes(float px, float py, float pz, float vx, float vy, float vz);
|
||||
void get_3d_attributes(float *px, float *py, float *pz, float *vx, float *vy, float *vz);
|
||||
|
||||
void finished();
|
||||
void set_3d_min_distance(float dist);
|
||||
float get_3d_min_distance() const;
|
||||
|
||||
protected:
|
||||
void set_3d_max_distance(float dist);
|
||||
float get_3d_max_distance() const;
|
||||
|
||||
AudioSound::SoundStatus status() const;
|
||||
|
||||
private:
|
||||
PT(FmodAudioManager) _manager;
|
||||
FSOUND_STREAM *_audio;
|
||||
string _file_name;
|
||||
string _finished_event;
|
||||
float _volume; // 0..1.0
|
||||
float _balance; // -1..1
|
||||
float _pos [3];
|
||||
float _vel [3];
|
||||
float _min_dist;
|
||||
float _max_dist;
|
||||
unsigned long _loop_count;
|
||||
mutable float _length; // in seconds.
|
||||
bool _active;
|
||||
bool _paused;
|
||||
bool _bExclusive; //stops all other sounds before playing when true
|
||||
int _channel;
|
||||
virtual bool add_dsp( PT(AudioDSP) dspToAdd );
|
||||
virtual bool remove_dsp( PT(AudioDSP) x);
|
||||
|
||||
FmodAudioSound(FmodAudioManager* manager, FSOUND_STREAM *audio_data,
|
||||
string file_name, float length=0.0f);
|
||||
virtual float get_speaker_mix(int speaker);
|
||||
virtual void set_speaker_mix(float frontleft, float frontright, float center, float sub, float backleft, float backright, float sideleft, float sideright);
|
||||
|
||||
// forbidden functions!
|
||||
FmodAudioSound(const FmodAudioSound& rhs) {}
|
||||
const FmodAudioSound& operator=(const FmodAudioSound& rhs) { return *this; }
|
||||
//THESE ARE NOT USED ANYMORE.
|
||||
//THEY ARE ONLY HERE BECAUSE THEY are still needed by Miles.
|
||||
//THESE are stubs in FMOD-EX version
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void set_active(bool active=true);
|
||||
bool get_active() const;
|
||||
|
||||
friend class FmodAudioManager;
|
||||
void finished();
|
||||
void set_finished_event(const string& event);
|
||||
const string& get_finished_event() const;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
FmodAudioManager *_manager;
|
||||
FMOD::Sound *_sound;
|
||||
FMOD::Channel *_channel;
|
||||
|
||||
string _file_name;
|
||||
|
||||
float _volume;
|
||||
float _balance;
|
||||
float _playrate;
|
||||
int _priority;
|
||||
|
||||
float _sampleFrequency;
|
||||
mutable float _length; //in seconds.
|
||||
|
||||
FMOD_SPEAKERMODE _speakermode;
|
||||
|
||||
float _frontleft;
|
||||
float _frontright;
|
||||
float _center;
|
||||
float _sub;
|
||||
float _backleft;
|
||||
float _backright;
|
||||
float _sideleft;
|
||||
float _sideright;
|
||||
|
||||
FMOD_VECTOR _location;
|
||||
FMOD_VECTOR _velocity;
|
||||
|
||||
float _min_dist;
|
||||
float _max_dist;
|
||||
|
||||
void play2DSound();
|
||||
void play3DSound();
|
||||
|
||||
void prepareSound();
|
||||
void prepare2DSound();
|
||||
void prepare3DSound();
|
||||
|
||||
void set_volume_on_channel();
|
||||
void set_balance_on_channel();
|
||||
void set_play_rate_on_channel();
|
||||
void set_speaker_mix_on_channel();
|
||||
void add_dsp_on_channel();
|
||||
void set_speaker_mix_or_balance_on_channel();
|
||||
|
||||
virtual int get_priority();
|
||||
virtual void set_priority(int priority);
|
||||
|
||||
//The Data Structure that holds all the DSPs.
|
||||
typedef pset<PT (FmodAudioDSP) > DSPSet;
|
||||
DSPSet _sound_dsp;
|
||||
|
||||
//THESE AREN'T USED ANYMORE.
|
||||
//THEY ARE ONLY HERE BECAUSE THEY are still need by Miles.
|
||||
//THESE are stubs in FMOD-EX version
|
||||
string _finished_event;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//These are needed for Panda's Pointer System. DO NOT ERASE!
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
AudioSound::init_type();
|
||||
register_type(_type_handle, "FmodAudioSound", AudioSound::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {
|
||||
init_type();
|
||||
return get_class_type();
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//DONE
|
||||
////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
#include "fmodAudioSound.I"
|
||||
|
@ -2,4 +2,5 @@
|
||||
#include "config_fmodAudio.cxx"
|
||||
#include "fmodAudioManager.cxx"
|
||||
#include "fmodAudioSound.cxx"
|
||||
#include "fmodAudioDSP.cxx"
|
||||
|
||||
|
@ -140,6 +140,31 @@ specifies_mode(int bits) const {
|
||||
return (_frame_buffer_mode & bits) != 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::is_basic
|
||||
// Access: Published
|
||||
// Description: Returns true if the properties are extremely basic.
|
||||
// The following count as basic: rgb or rgba, depth.
|
||||
// If anything else is specified, the properties are
|
||||
// non-basic.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool FrameBufferProperties::
|
||||
is_basic() const {
|
||||
if (_frame_buffer_mode & (~(FM_alpha | FM_depth))) {
|
||||
return false;
|
||||
}
|
||||
if (_depth_bits || _color_bits || _alpha_bits || _stencil_bits) {
|
||||
return false;
|
||||
}
|
||||
if (_multisamples) {
|
||||
return false;
|
||||
}
|
||||
if (_aux_rgba || _aux_hrgba || _aux_float) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::is_stereo
|
||||
// Access: Published
|
||||
@ -544,6 +569,16 @@ set_specified() {
|
||||
recalc_buffer_mask();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::get_specified
|
||||
// Access: Public
|
||||
// Description: Returns the specified flags.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int FrameBufferProperties::
|
||||
get_specified() const {
|
||||
return _specified;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: FrameBufferProperties::get_buffer_mask
|
||||
// Access: Public
|
||||
|
@ -61,7 +61,55 @@ operator = (const FrameBufferProperties ©) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool FrameBufferProperties::
|
||||
subsumes(const FrameBufferProperties &other) const {
|
||||
// NOT IMPLEMENTED YET
|
||||
if (other._specified & S_depth_bits) {
|
||||
if (((_specified & S_depth_bits)==0) || (other._depth_bits > _depth_bits)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (other._specified & S_color_bits) {
|
||||
if (((_specified & S_color_bits)==0) || (other._color_bits > _color_bits)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (other._specified & S_alpha_bits) {
|
||||
if (((_specified & S_alpha_bits)==0) || (other._alpha_bits > _alpha_bits)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (other._specified & S_stencil_bits) {
|
||||
if (((_specified & S_stencil_bits)==0) || (other._stencil_bits > _stencil_bits)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((other._specified & S_multisamples) && (other._multisamples > 1)) {
|
||||
// Multisample spec of 1 is ignored - 1 multisample is tautologous.
|
||||
if (((_specified & S_multisamples)==0) || (other._multisamples > _multisamples)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (other._specified & S_aux_rgba) {
|
||||
if (((_specified & S_aux_rgba)==0) || (other._aux_rgba > _aux_rgba)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (other._specified & S_aux_hrgba) {
|
||||
if (((_specified & S_aux_hrgba)==0) || (other._aux_hrgba > _aux_hrgba)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (other._specified & S_aux_float) {
|
||||
if (((_specified & S_aux_float)==0) || (other._aux_float > _aux_float)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (other._specified & S_frame_buffer_mode) {
|
||||
if ((_specified & S_frame_buffer_mode)==0) {
|
||||
return false;
|
||||
}
|
||||
if (other._frame_buffer_mode & (~_frame_buffer_mode)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,6 +122,7 @@ subsumes(const FrameBufferProperties &other) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
FrameBufferProperties FrameBufferProperties::
|
||||
get_default() {
|
||||
|
||||
FrameBufferProperties props;
|
||||
|
||||
int mode = 0;
|
||||
@ -149,6 +198,9 @@ get_default() {
|
||||
if (framebuffer_stereo) {
|
||||
mode |= FM_stereo;
|
||||
}
|
||||
if ((mode & FM_hardware) && (mode & FM_software)) {
|
||||
mode = mode & ~(FM_hardware | FM_software);
|
||||
}
|
||||
|
||||
props.set_frame_buffer_mode(mode);
|
||||
props.set_depth_bits(depth_bits);
|
||||
|
@ -45,7 +45,7 @@ PUBLISHED:
|
||||
FM_index = 0x0001,
|
||||
FM_single_buffer = 0x0000,
|
||||
FM_double_buffer = 0x0002,
|
||||
FM_triple_buffer = 0x0004,
|
||||
FM_triple_buffer = 0x0006,
|
||||
FM_buffer = 0x0006, // == (FM_single_buffer | FM_double_buffer | FM_triple_buffer)
|
||||
FM_accum = 0x0008,
|
||||
FM_alpha = 0x0010,
|
||||
@ -57,15 +57,33 @@ PUBLISHED:
|
||||
FM_software = 0x0200,
|
||||
FM_hardware = 0x0400,
|
||||
};
|
||||
|
||||
// This bitmask indicates which of the parameters in the properties
|
||||
// structure have been filled in by the user, and which remain
|
||||
// unspecified.
|
||||
enum Specified {
|
||||
S_frame_buffer_mode = 0x0001,
|
||||
S_depth_bits = 0x0002,
|
||||
S_color_bits = 0x0004,
|
||||
S_alpha_bits = 0x0008,
|
||||
S_stencil_bits = 0x0010,
|
||||
S_multisamples = 0x0020,
|
||||
S_aux_rgba = 0x0040,
|
||||
S_aux_hrgba = 0x0080,
|
||||
S_aux_float = 0x0100,
|
||||
S_ALL_SPECIFIED = 0x01FF,
|
||||
};
|
||||
|
||||
void clear();
|
||||
INLINE void set_specified();
|
||||
INLINE int get_specified() const;
|
||||
INLINE int get_buffer_mask() const;
|
||||
INLINE bool is_any_specified() const;
|
||||
INLINE bool specifies_mode(int bit) const;
|
||||
INLINE bool is_single_buffered() const;
|
||||
INLINE bool is_stereo() const;
|
||||
|
||||
INLINE bool is_basic() const;
|
||||
|
||||
bool subsumes(const FrameBufferProperties &prop) const;
|
||||
|
||||
INLINE void set_frame_buffer_mode(int frameBuffer_mode);
|
||||
@ -124,21 +142,6 @@ private:
|
||||
void recalc_buffer_mask();
|
||||
|
||||
private:
|
||||
// This bitmask indicates which of the parameters in the properties
|
||||
// structure have been filled in by the user, and which remain
|
||||
// unspecified.
|
||||
enum Specified {
|
||||
S_frame_buffer_mode = 0x0001,
|
||||
S_depth_bits = 0x0002,
|
||||
S_color_bits = 0x0004,
|
||||
S_alpha_bits = 0x0008,
|
||||
S_stencil_bits = 0x0010,
|
||||
S_multisamples = 0x0020,
|
||||
S_aux_rgba = 0x0040,
|
||||
S_aux_hrgba = 0x0080,
|
||||
S_aux_float = 0x0100,
|
||||
S_ALL_SPECIFIED = 0x01FF,
|
||||
};
|
||||
|
||||
int _specified;
|
||||
int _flags;
|
||||
|
@ -126,7 +126,8 @@ make_window(GraphicsStateGuardian *gsg, const string &name, int sort) {
|
||||
// The hardwired size here is never used.
|
||||
GraphicsOutput *result = make_output(gsg->get_pipe(), name, sort,
|
||||
gsg->get_default_properties(), 50, 50,
|
||||
GraphicsPipe::BF_require_window,
|
||||
GraphicsPipe::BF_require_window |
|
||||
GraphicsPipe::BF_fb_props_optional,
|
||||
gsg, NULL);
|
||||
return DCAST(GraphicsWindow, result);
|
||||
}
|
||||
@ -150,7 +151,8 @@ make_buffer(GraphicsStateGuardian *gsg, const string &name,
|
||||
props.set_frame_buffer_mode(props.get_frame_buffer_mode() & (~clear));
|
||||
GraphicsOutput *result = make_output(gsg->get_pipe(), name, sort,
|
||||
gsg->get_default_properties(), x_size, y_size,
|
||||
GraphicsPipe::BF_refuse_window,
|
||||
GraphicsPipe::BF_refuse_window |
|
||||
GraphicsPipe::BF_fb_props_optional,
|
||||
gsg, NULL);
|
||||
return result;
|
||||
}
|
||||
@ -166,7 +168,8 @@ make_parasite(GraphicsOutput *host, const string &name,
|
||||
FrameBufferProperties props;
|
||||
GraphicsOutput *result = make_output(host->get_pipe(), name, sort,
|
||||
props, x_size, y_size,
|
||||
GraphicsPipe::BF_require_parasite,
|
||||
GraphicsPipe::BF_require_parasite |
|
||||
GraphicsPipe::BF_fb_props_optional,
|
||||
host->get_gsg(), host);
|
||||
return result;
|
||||
}
|
||||
|
@ -332,6 +332,23 @@ make_output(GraphicsPipe *pipe,
|
||||
gsg = make_gsg(pipe, prop);
|
||||
}
|
||||
|
||||
// If there is a host window, and it is not yet initialized,
|
||||
// then call open_windows to get the host ready. If that
|
||||
// fails, give up on using the host window.
|
||||
|
||||
if (host != (GraphicsOutput *)NULL) {
|
||||
if ((!host->is_valid())||
|
||||
(!host->get_gsg()->is_valid())||
|
||||
(host->get_gsg()->needs_reset())) {
|
||||
open_windows();
|
||||
}
|
||||
if ((!host->is_valid())||
|
||||
(!host->get_gsg()->is_valid())||
|
||||
(host->get_gsg()->needs_reset())) {
|
||||
host = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if a parasite buffer meets the user's specs.
|
||||
|
||||
bool can_use_parasite = false;
|
||||
@ -340,24 +357,23 @@ make_output(GraphicsPipe *pipe,
|
||||
((flags&GraphicsPipe::BF_refuse_parasite)==0)&&
|
||||
((flags&GraphicsPipe::BF_can_bind_color)==0)&&
|
||||
((flags&GraphicsPipe::BF_can_bind_every)==0)&&
|
||||
((flags&GraphicsPipe::BF_rtt_cumulative)==0)&&
|
||||
(prop.specifies_mode(FrameBufferProperties::FM_index)==false)&&
|
||||
(prop.specifies_mode(FrameBufferProperties::FM_buffer)==false)&&
|
||||
(prop.specifies_mode(FrameBufferProperties::FM_accum)==false)&&
|
||||
(prop.specifies_mode(FrameBufferProperties::FM_stencil)==false)&&
|
||||
(prop.specifies_mode(FrameBufferProperties::FM_multisample)==false)&&
|
||||
(prop.get_aux_rgba() == 0)&&
|
||||
(prop.get_aux_hrgba() == 0)&&
|
||||
(prop.get_aux_float() == 0)) {
|
||||
can_use_parasite = true;
|
||||
((flags&GraphicsPipe::BF_rtt_cumulative)==0)) {
|
||||
if ((flags&GraphicsPipe::BF_fb_props_optional) ||
|
||||
(host->get_fb_properties().subsumes(prop))) {
|
||||
can_use_parasite = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If parasite buffers are preferred, then try a parasite first.
|
||||
// Even if prefer-parasite-buffer is set, parasites are not preferred
|
||||
// if the host window is too small, or if the host window does not
|
||||
// have the requested properties.
|
||||
|
||||
if ((prefer_parasite_buffer) &&
|
||||
(can_use_parasite) &&
|
||||
(x_size <= host->get_x_size())&&
|
||||
(y_size <= host->get_y_size())) {
|
||||
(y_size <= host->get_y_size())&&
|
||||
(host->get_fb_properties().subsumes(prop))) {
|
||||
ParasiteBuffer *buffer = new ParasiteBuffer(host, name, x_size, y_size, flags);
|
||||
buffer->_sort = sort;
|
||||
do_add_window(buffer, gsg, threading_model);
|
||||
@ -378,7 +394,14 @@ make_output(GraphicsPipe *pipe,
|
||||
}
|
||||
open_windows();
|
||||
if (window->is_valid()) {
|
||||
return window;
|
||||
if (window->get_fb_properties().subsumes(prop)) {
|
||||
return window;
|
||||
} else {
|
||||
if (flags & GraphicsPipe::BF_fb_props_optional) {
|
||||
display_cat.warning() << "FrameBufferProperties available less than requested.\n";
|
||||
return window;
|
||||
}
|
||||
}
|
||||
}
|
||||
// No good; delete the window and keep trying.
|
||||
bool removed = remove_window(window);
|
||||
|
@ -89,6 +89,7 @@ PUBLISHED:
|
||||
BF_can_bind_every = 0x0080, // Need capability: bind all bitplanes to a tex.
|
||||
BF_size_track_host = 0x0100, // Buffer should track the host size.
|
||||
BF_rtt_cumulative = 0x0200, // Buffer supports cumulative render-to-texture.
|
||||
BF_fb_props_optional = 0x0400, // FrameBufferProperties can be ignored.
|
||||
};
|
||||
|
||||
INLINE bool is_valid() const;
|
||||
|
@ -158,12 +158,16 @@ make_output(const string &name,
|
||||
((flags&BF_size_track_host)!=0)||
|
||||
((flags&BF_rtt_cumulative)!=0)||
|
||||
((flags&BF_can_bind_color)!=0)||
|
||||
((flags&BF_can_bind_every)!=0)||
|
||||
(properties.get_aux_rgba() > 0)||
|
||||
(properties.get_aux_hrgba() > 0)||
|
||||
(properties.get_aux_float() > 0)) {
|
||||
((flags&BF_can_bind_every)!=0)) {
|
||||
return NULL;
|
||||
}
|
||||
if ((flags & BF_fb_props_optional)==0) {
|
||||
if ((properties.get_aux_rgba() > 0)||
|
||||
(properties.get_aux_hrgba() > 0)||
|
||||
(properties.get_aux_float() > 0)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return new wglGraphicsWindow(this, name, properties,
|
||||
x_size, y_size, flags, gsg, host);
|
||||
}
|
||||
@ -175,19 +179,28 @@ make_output(const string &name,
|
||||
(!gl_support_fbo)||
|
||||
(host==0)||
|
||||
((flags&BF_require_parasite)!=0)||
|
||||
((flags&BF_require_window)!=0)||
|
||||
(properties.specifies_mode(FrameBufferProperties::FM_index))||
|
||||
(properties.specifies_mode(FrameBufferProperties::FM_buffer))||
|
||||
(properties.specifies_mode(FrameBufferProperties::FM_accum))||
|
||||
(properties.specifies_mode(FrameBufferProperties::FM_stencil))||
|
||||
(properties.specifies_mode(FrameBufferProperties::FM_multisample))) {
|
||||
((flags&BF_require_window)!=0)) {
|
||||
return NULL;
|
||||
}
|
||||
// Early failure - if we are sure that this buffer WONT
|
||||
// meet specs, we can bail out early.
|
||||
if ((flags & BF_fb_props_optional)==0) {
|
||||
if ((properties.has_mode(FrameBufferProperties::FM_index))||
|
||||
(properties.has_mode(FrameBufferProperties::FM_buffer))||
|
||||
(properties.has_mode(FrameBufferProperties::FM_accum))||
|
||||
(properties.has_mode(FrameBufferProperties::FM_stencil))||
|
||||
(properties.has_mode(FrameBufferProperties::FM_multisample))) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
// Early success - if we are sure that this buffer WILL
|
||||
// meet specs, we can precertify it.
|
||||
if ((wglgsg != 0) &&
|
||||
(wglgsg->is_valid()) &&
|
||||
(!wglgsg->needs_reset()) &&
|
||||
(wglgsg->_supports_framebuffer_object) &&
|
||||
(wglgsg->_glDrawBuffers != 0)) {
|
||||
(wglgsg->_glDrawBuffers != 0)&&
|
||||
(properties.is_basic())) {
|
||||
precertify = true;
|
||||
}
|
||||
return new GLGraphicsBuffer(this, name, properties,
|
||||
@ -202,16 +215,25 @@ make_output(const string &name,
|
||||
((flags&BF_require_window)!=0)||
|
||||
((flags&BF_size_track_host)!=0)||
|
||||
((flags&BF_rtt_cumulative)!=0)||
|
||||
((flags&BF_can_bind_every)!=0)||
|
||||
(properties.get_aux_rgba() > 0)||
|
||||
(properties.get_aux_hrgba() > 0)||
|
||||
(properties.get_aux_float() > 0)) {
|
||||
((flags&BF_can_bind_every)!=0)) {
|
||||
return NULL;
|
||||
}
|
||||
// Early failure - if we are sure that this buffer WONT
|
||||
// meet specs, we can bail out early.
|
||||
if ((flags & BF_fb_props_optional) == 0) {
|
||||
if ((properties.get_aux_rgba() > 0)||
|
||||
(properties.get_aux_hrgba() > 0)||
|
||||
(properties.get_aux_float() > 0)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
// Early success - if we are sure that this buffer WILL
|
||||
// meet specs, we can precertify the window.
|
||||
if ((wglgsg != 0) &&
|
||||
(wglgsg->is_valid()) &&
|
||||
(!wglgsg->needs_reset()) &&
|
||||
(wglgsg->_supports_pbuffer)) {
|
||||
(wglgsg->_supports_pbuffer) &&
|
||||
(properties.is_basic())) {
|
||||
precertify = true;
|
||||
}
|
||||
return new wglGraphicsBuffer(this, name, properties,
|
||||
@ -525,7 +547,7 @@ get_properties(FrameBufferProperties &properties, HDC hdc,
|
||||
} else {
|
||||
mode |= FrameBufferProperties::FM_hardware;
|
||||
}
|
||||
|
||||
|
||||
if (pfd.cColorBits != 0) {
|
||||
mode |= FrameBufferProperties::FM_rgb;
|
||||
properties.set_color_bits(pfd.cColorBits);
|
||||
|
Loading…
x
Reference in New Issue
Block a user