mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 11:28:17 -04:00
New files for DSP filter config
This commit is contained in:
parent
40879d8def
commit
7778159b30
151
panda/src/audio/filterProperties.I
Normal file
151
panda/src/audio/filterProperties.I
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
// Filename: filterProperties.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 .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::clear
|
||||||
|
// Access: Published
|
||||||
|
// Description: Removes all DSP postprocessing.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
clear() {
|
||||||
|
_config.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::apply_lowpass
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a lowpass filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_lowpass(float cutoff_freq, float resonance_q) {
|
||||||
|
add_filter(FT_lowpass, cutoff_freq, resonance_q);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_highpass
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a highpass filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_highpass(float cutoff_freq, float resonance_q) {
|
||||||
|
add_filter(FT_highpass, cutoff_freq, resonance_q);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_echo
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a echo filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_echo(float drymix, float wetmix, float delay, float decayratio) {
|
||||||
|
add_filter(FT_echo, drymix, wetmix, delay, decayratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_flange
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a flange filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_flange(float drymix, float wetmix, float depth, float rate) {
|
||||||
|
add_filter(FT_flange, drymix, wetmix, depth, rate);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_distort
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a distort filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_distort(float level) {
|
||||||
|
add_filter(FT_distort, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_normalize
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a normalize filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_normalize(float fadetime, float threshold, float maxamp) {
|
||||||
|
add_filter(FT_normalize, fadetime, threshold, maxamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_parameq
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a parameq filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_parameq(float center_freq, float bandwidth, float gain) {
|
||||||
|
add_filter(FT_parameq, center_freq, bandwidth, gain);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_pitchshift
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a pitchshift filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_pitchshift(float pitch, float fftsize, float overlap) {
|
||||||
|
add_filter(FT_pitchshift, pitch, fftsize, overlap);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_chorus
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a chorus filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_chorus(float drymix, float wet1, float wet2, float wet3, float delay, float rate, float depth, float feedback) {
|
||||||
|
add_filter(FT_chorus, drymix, wet1, wet2, wet3, delay, rate, depth, feedback);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_reverb
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a reverb filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_reverb(float drymix, float wetmix, float roomsize, float damp, float width) {
|
||||||
|
add_filter(FT_reverb, drymix, wetmix, roomsize, damp, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_compress
|
||||||
|
// Access: Published
|
||||||
|
// Description: Add a compress filter to the end of the DSP chain.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void FilterProperties::
|
||||||
|
add_compress(float threshold, float attack, float release, float gainmakeup) {
|
||||||
|
add_filter(FT_compress, threshold, attack, release, gainmakeup);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::get_config
|
||||||
|
// Access: Published
|
||||||
|
// Description: Intended for use by AudioManager and AudioSound
|
||||||
|
// implementations: allows access to the config vector.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE const FilterProperties::ConfigVector &FilterProperties::
|
||||||
|
get_config() {
|
||||||
|
return _config;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
61
panda/src/audio/filterProperties.cxx
Normal file
61
panda/src/audio/filterProperties.cxx
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// Filename: filterProperties.cxx
|
||||||
|
// 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 .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "filterProperties.h"
|
||||||
|
|
||||||
|
TypeHandle FilterProperties::_type_handle;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::Constructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
FilterProperties::
|
||||||
|
FilterProperties()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::Destructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
FilterProperties::
|
||||||
|
~FilterProperties() {
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: FilterProperties::add_filter
|
||||||
|
// Access: Private
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void FilterProperties::
|
||||||
|
add_filter(FilterType t, float a, float b, float c, float d, float e, float f, float g, float h) {
|
||||||
|
FilterConfig conf;
|
||||||
|
conf._type = t;
|
||||||
|
conf._a = a;
|
||||||
|
conf._b = b;
|
||||||
|
conf._c = c;
|
||||||
|
conf._d = d;
|
||||||
|
conf._e = e;
|
||||||
|
conf._f = f;
|
||||||
|
conf._g = g;
|
||||||
|
conf._h = h;
|
||||||
|
_config.push_back(conf);
|
||||||
|
}
|
||||||
|
|
98
panda/src/audio/filterProperties.h
Normal file
98
panda/src/audio/filterProperties.h
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
// Filename: filterProperties.h
|
||||||
|
// 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 .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef FILTERPROPERTIES_H
|
||||||
|
#define FILTERPROPERTIES_H
|
||||||
|
|
||||||
|
#include "config_audio.h"
|
||||||
|
#include "typedReferenceCount.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : FilterProperties
|
||||||
|
// Description : Stores a configuration for a set of audio DSP filters.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class EXPCL_PANDA_AUDIO FilterProperties : public TypedReferenceCount {
|
||||||
|
PUBLISHED:
|
||||||
|
FilterProperties();
|
||||||
|
~FilterProperties();
|
||||||
|
INLINE void clear();
|
||||||
|
INLINE void add_lowpass(float cutoff_freq, float resonance_q);
|
||||||
|
INLINE void add_highpass(float cutoff_freq, float resonance_q);
|
||||||
|
INLINE void add_echo(float drymix, float wetmix, float delay, float decayratio);
|
||||||
|
INLINE void add_flange(float drymix, float wetmix, float depth, float rate);
|
||||||
|
INLINE void add_distort(float level);
|
||||||
|
INLINE void add_normalize(float fadetime, float threshold, float maxamp);
|
||||||
|
INLINE void add_parameq(float center_freq, float bandwidth, float gain);
|
||||||
|
INLINE void add_pitchshift(float pitch, float fftsize, float overlap);
|
||||||
|
INLINE void add_chorus(float drymix, float wet1, float wet2, float wet3, float delay, float rate, float depth, float feedback);
|
||||||
|
INLINE void add_reverb(float drymix, float wetmix, float roomsize, float damp, float width);
|
||||||
|
INLINE void add_compress(float threshold, float attack, float release, float gainmakeup);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum FilterType {
|
||||||
|
FT_lowpass,
|
||||||
|
FT_highpass,
|
||||||
|
FT_echo,
|
||||||
|
FT_flange,
|
||||||
|
FT_distort,
|
||||||
|
FT_normalize,
|
||||||
|
FT_parameq,
|
||||||
|
FT_pitchshift,
|
||||||
|
FT_chorus,
|
||||||
|
FT_reverb,
|
||||||
|
FT_compress,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FilterConfig {
|
||||||
|
FilterType _type;
|
||||||
|
float _a,_b,_c,_d;
|
||||||
|
float _e,_f,_g,_h;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef pvector<FilterConfig> ConfigVector;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void add_filter(FilterType t, float a=0, float b=0, float c=0, float d=0, float e=0, float f=0, float g=0, float h=0);
|
||||||
|
ConfigVector _config;
|
||||||
|
|
||||||
|
public:
|
||||||
|
INLINE const ConfigVector &get_config();
|
||||||
|
|
||||||
|
public:
|
||||||
|
static TypeHandle get_class_type() {
|
||||||
|
return _type_handle;
|
||||||
|
}
|
||||||
|
static void init_type() {
|
||||||
|
TypedReferenceCount::init_type();
|
||||||
|
register_type(_type_handle, "FilterProperties",
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "filterProperties.I"
|
||||||
|
|
||||||
|
#endif // FILTERPROPERTIES_H
|
Loading…
x
Reference in New Issue
Block a user