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.setPlaybackRate()

The Audio.setPlaybackRate() method is a function in the Three.js library that allows you to adjust the playback speed of an audio object.

Syntax

audio.setPlaybackRate(rate);

Parameters

  • rate - A number value that specifies the playback rate. The default value is 1.

Description

The Audio.setPlaybackRate() function changes the playback speed of an audio object. The value of rate parameter determines the speed of the audio, with a default value of 1. A rate value of 2.0 would play the audio twice as fast as the original, while a value of 0.5 would play the audio at half the speed.

Example

// create a new audio object
var audio = new THREE.Audio( listener );

// set the audio source
var audioLoader = new THREE.AudioLoader();
audioLoader.load( 'path/to/your/audio/file.mp3', function( buffer ) {

  audio.setBuffer( buffer );

  // set the playback rate to 0.5 (half the speed)
  audio.setPlaybackRate(0.5);

  audio.play();

});

In this example, we create a new audio object and set the audio source using THREE.AudioLoader(). We then set the playback rate to 0.5 using Audio.setPlaybackRate() before playing the audio.

Notes

  • The setPlaybackRate() method can be useful for slowing down or speeding up audio depending on the context of the scene being rendered.
  • A value of 2 or higher will produce a chipmunk-like effect on spoken words.
  • A value of 0 or lower will produce no sound.
  • Values between 0 and 1 will produce a slower playback speed.
  • Values greater than 1 will produce a faster playback speed.
  • It is also possible to adjust the playback rate of an audio object by changing the value of the playbackRate property.