From f46ca14f2595cc13a64b67f9d8a114673d5ae358 Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Wed, 22 Aug 2007 17:27:44 +0000 Subject: [PATCH] Redesigned DSP control interface --- panda/src/audio/Sources.pp | 17 +-- panda/src/audio/audio.h | 2 +- panda/src/audio/audioDSP.cxx | 195 --------------------------- panda/src/audio/audioDSP.h | 80 ----------- panda/src/audio/audioManager.I | 18 +++ panda/src/audio/audioManager.cxx | 58 +++----- panda/src/audio/audioManager.h | 41 +----- panda/src/audio/audioSound.I | 18 +++ panda/src/audio/audioSound.cxx | 44 +++--- panda/src/audio/audioSound.h | 12 +- panda/src/audio/audio_composite1.cxx | 3 +- panda/src/audio/config_audio.cxx | 5 +- panda/src/audio/nullAudioDSP.cxx | 187 ------------------------- panda/src/audio/nullAudioDSP.h | 80 ----------- 14 files changed, 99 insertions(+), 661 deletions(-) delete mode 100644 panda/src/audio/audioDSP.cxx delete mode 100644 panda/src/audio/audioDSP.h create mode 100644 panda/src/audio/audioManager.I create mode 100644 panda/src/audio/audioSound.I delete mode 100644 panda/src/audio/nullAudioDSP.cxx delete mode 100644 panda/src/audio/nullAudioDSP.h diff --git a/panda/src/audio/Sources.pp b/panda/src/audio/Sources.pp index 21de967d03..1408983308 100644 --- a/panda/src/audio/Sources.pp +++ b/panda/src/audio/Sources.pp @@ -10,31 +10,28 @@ #define SOURCES \ config_audio.h \ - audioDSP.h \ + filterProperties.h filterProperties.I\ audioLoadRequest.h audioLoadRequest.I \ - audioManager.h \ - audioSound.h \ - nullAudioDSP.h \ + audioManager.h audioManager.I\ + audioSound.h audioSound.I\ nullAudioManager.h \ nullAudioSound.h #define INCLUDED_SOURCES \ config_audio.cxx \ - audioDSP.cxx \ + filterProperties.cxx \ audioLoadRequest.cxx \ audioManager.cxx \ audioSound.cxx \ - nullAudioDSP.cxx \ nullAudioManager.cxx \ nullAudioSound.cxx #define INSTALL_HEADERS \ config_audio.h \ - audioDSP.h \ + filterProperties.h filterProperties.I\ audioLoadRequest.h audioLoadRequest.I \ - audioManager.h \ - audioSound.h \ - nullAudioDSP.h \ + audioManager.h audioManager.I\ + audioSound.h audioSound.I\ nullAudioManager.h \ nullAudioSound.h diff --git a/panda/src/audio/audio.h b/panda/src/audio/audio.h index 1bebf78b01..afa2f3e00d 100644 --- a/panda/src/audio/audio.h +++ b/panda/src/audio/audio.h @@ -19,8 +19,8 @@ #ifndef __AUDIO_H__ #define __AUDIO_H__ +#include "filterProperties.h" #include "audioSound.h" -#include "audioDSP.h" #include "audioManager.h" #endif /* __AUDIO_H__ */ diff --git a/panda/src/audio/audioDSP.cxx b/panda/src/audio/audioDSP.cxx deleted file mode 100644 index f0996a43c2..0000000000 --- a/panda/src/audio/audioDSP.cxx +++ /dev/null @@ -1,195 +0,0 @@ -// 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; iget_config(); + if (conf.empty()) { + return true; + } else { + return false; + } +} + //////////////////////////////////////////////////////////////////// // Function: AudioManager::update() // Access: Published, Virtual diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index 52c121ee15..483d63e7ee 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -22,7 +22,7 @@ #include "config_audio.h" #include "audioSound.h" -#include "audioDSP.h" +#include "filterProperties.h" typedef PT(AudioManager) Create_AudioManager_proc(); @@ -30,36 +30,6 @@ typedef PT(AudioManager) Create_AudioManager_proc(); class EXPCL_PANDA_AUDIO 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 SpeakerModeCategory { // These enumerants line up one-to-one // with the FMOD SPEAKERMODE enumerants. @@ -88,15 +58,10 @@ PUBLISHED: SPK_sideright, SPK_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(SpeakerModeCategory cat); + virtual bool configure_filters(FilterProperties *config); // Create an AudioManager for each category of sounds you have. // E.g. @@ -260,4 +225,6 @@ operator << (ostream &out, const AudioManager &mgr) { return out; } +#include "audioManager.I" + #endif /* __AUDIO_MANAGER_H__ */ diff --git a/panda/src/audio/audioSound.I b/panda/src/audio/audioSound.I new file mode 100644 index 0000000000..e35dfa6008 --- /dev/null +++ b/panda/src/audio/audioSound.I @@ -0,0 +1,18 @@ +// Filename: audioSound.I +// Created by: jyelon (01Aug2007) +// +//////////////////////////////////////////////////////////////////// +// +// 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 . +// +//////////////////////////////////////////////////////////////////// + diff --git a/panda/src/audio/audioSound.cxx b/panda/src/audio/audioSound.cxx index e979ad0324..6eb496a471 100644 --- a/panda/src/audio/audioSound.cxx +++ b/panda/src/audio/audioSound.cxx @@ -73,29 +73,6 @@ get_3d_max_distance() const { return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::add_dsp -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -bool AudioSound:: -add_dsp(PT(AudioDSP) x) { - // intentionally blank - return false; -} - -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::remove_dsp -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -bool AudioSound:: -remove_dsp(PT(AudioDSP) x) { - // intentionally blank - return false; -} - - //////////////////////////////////////////////////////////////////// // Function: AudioSound::getSpeakerMix // Access: Published @@ -118,6 +95,27 @@ set_speaker_mix(float frontleft, float frontright, float center, float sub, floa ; } +//////////////////////////////////////////////////////////////////// +// Function: AudioSound::configure_filters +// Access: Published +// Description: Configure the local DSP filter chain. +// +// There is no guarantee that any given configuration +// will be supported by the implementation. The only +// way to find out what's supported is to call +// configure_filters. If it returns true, the +// configuration is supported. +//////////////////////////////////////////////////////////////////// +bool AudioSound:: +configure_filters(FilterProperties *config) { + const FilterProperties::ConfigVector &conf = config->get_config(); + if (conf.empty()) { + return true; + } else { + return false; + } +} + //////////////////////////////////////////////////////////////////// // Function: AudioSound::get_priority // Access: Published diff --git a/panda/src/audio/audioSound.h b/panda/src/audio/audioSound.h index 21b62b7940..3d6fc645db 100644 --- a/panda/src/audio/audioSound.h +++ b/panda/src/audio/audioSound.h @@ -23,15 +23,14 @@ #include "config_audio.h" #include "typedReferenceCount.h" #include "pointerTo.h" - -#include "audioDSP.h" +#include "filterProperties.h" class AudioManager; class EXPCL_PANDA_AUDIO 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 @@ -125,15 +124,14 @@ PUBLISHED: virtual void set_3d_max_distance(float dist); virtual float get_3d_max_distance() const; - virtual bool add_dsp(PT(AudioDSP) x); - virtual bool remove_dsp(PT(AudioDSP) x); - 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); virtual int get_priority(); virtual void set_priority(int priority); + virtual bool configure_filters(FilterProperties *config); + enum SoundStatus { BAD, READY, PLAYING }; virtual SoundStatus status() const = 0; @@ -169,6 +167,8 @@ operator << (ostream &out, const AudioSound &sound) { return out; } +#include "audioSound.I" + EXPCL_PANDA_AUDIO ostream & operator << (ostream &out, AudioSound::SoundStatus status); diff --git a/panda/src/audio/audio_composite1.cxx b/panda/src/audio/audio_composite1.cxx index a7018753ae..e8c37e5bda 100644 --- a/panda/src/audio/audio_composite1.cxx +++ b/panda/src/audio/audio_composite1.cxx @@ -1,9 +1,8 @@ #include "config_audio.cxx" +#include "filterProperties.cxx" #include "audioLoadRequest.cxx" #include "audioManager.cxx" #include "audioSound.cxx" -#include "audioDSP.cxx" -#include "nullAudioDSP.cxx" #include "nullAudioManager.cxx" #include "nullAudioSound.cxx" diff --git a/panda/src/audio/config_audio.cxx b/panda/src/audio/config_audio.cxx index ee96c953fe..5eaabbbc7c 100644 --- a/panda/src/audio/config_audio.cxx +++ b/panda/src/audio/config_audio.cxx @@ -18,10 +18,10 @@ #include "config_audio.h" #include "dconfig.h" +#include "filterProperties.h" #include "audioLoadRequest.h" #include "audioManager.h" #include "audioSound.h" -#include "nullAudioDSP.h" #include "nullAudioManager.h" #include "nullAudioSound.h" @@ -114,11 +114,10 @@ ConfigVariableInt audio_output_channels ConfigureFn(config_audio) { + FilterProperties::init_type(); AudioLoadRequest::init_type(); AudioManager::init_type(); AudioSound::init_type(); - AudioDSP::init_type(); - nullAudioDSP::init_type(); NullAudioManager::init_type(); NullAudioSound::init_type(); } diff --git a/panda/src/audio/nullAudioDSP.cxx b/panda/src/audio/nullAudioDSP.cxx deleted file mode 100644 index a5b8418a39..0000000000 --- a/panda/src/audio/nullAudioDSP.cxx +++ /dev/null @@ -1,187 +0,0 @@ -// 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() { -} - diff --git a/panda/src/audio/nullAudioDSP.h b/panda/src/audio/nullAudioDSP.h deleted file mode 100644 index 7ee69228bf..0000000000 --- a/panda/src/audio/nullAudioDSP.h +++ /dev/null @@ -1,80 +0,0 @@ -// 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_AUDIO 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__ */