BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

Audio.getFilters()

Audio.getFilters()是Three.js中Audio类的一个成员函数,它返回连接到音频源的Web Audio API高通、低通、带通和带阻滤波器的数组。

语法

Audio.getFilters(): AudioFilter[]

返回值

该函数返回一个AudioFilter类型的数组,其中包含连接到音频源的不同类型的滤波器。AudioFilter对象是Three.js的内置类型之一,表示一个Web Audio API滤波器节点。可以使用该节点对音频进行过滤和处理。

示例

以下示例演示如何使用Audio.getFilters()方法获取音频源的滤波器数组:

const listener = new THREE.AudioListener();
const audio = new THREE.Audio(listener);

audio.setMediaElementSource(document.getElementById('audio-element'));

const filters = audio.getFilters();

// 遍历滤波器数组,并向其中添加带通滤波器
for(let i = 0, l = filters.length; i < l; i++){
    const filter = filters[i];
    const type = filter.type;

    if(type === 'bandpass'){
        filter.frequency.value = 220;
        filter.Q.value = 1;
    }
}

注意事项

如果尚未创建滤波器节点,则该方法将创建包括默认低通滤波器的新数组,并返回该数组。通过调用返回的AudioFilter对象的属性和方法,可以更改这些节点的设置。

参考

  • Audio
  • AudioFilter
  • Web Audio API滤波器文档