user: Describe Aud from the Blender manual or Python API, including usage steps and snippets.

assistant: g the constant value. position_start ( int ) – The start position in frames. position_end ( int ) – The end position in frames. animated ¶ Whether the property is animated. count ¶ The count of floats for a property. class aud. Device ¶ Device objects represent an audio output backend like OpenAL or SDL, but might also represent a file output or RAM buffer output. lock ( ) ¶ Locks the device so that it’s guaranteed, that no samples are read from the streams until unlock() is called. This is useful if you want to do start/stop/pause/resume some sounds at the same time. Note The device has to be unlocked as often as locked to be able to continue playback. Warning Make sure the time between locking and unlocking is as short as possible to avoid clicks. play ( sound , keep = False ) ¶ Plays a sound. Parameters : sound ( Sound ) – The sound to play. keep ( bool ) – See Handle.keep . Returns : The playback handle with which playback can be controlled with. Return type : Handle stopAll ( ) ¶ Stops all playing and paused sounds. unlock ( ) ¶ Unlocks the device after a lock call, see lock() for details. channels ¶ The channel count of the device. distance_model ¶ The distance model of the device. See also OpenAL Documentation doppler_factor ¶ The doppler factor of the device. This factor is a scaling factor for the velocity vectors in doppler calculation. So a value bigger than 1 will exaggerate the effect as it raises the velocity. format ¶ The native sample format of the device. listener_location ¶ The listeners’s location in 3D space, a 3D tuple of floats. listener_orientation ¶ The listener’s orientation in 3D space as quaternion, a 4 float tuple. listener_velocity ¶ The listener’s velocity in 3D space, a 3D tuple of floats. rate ¶ The sampling rate of the device in Hz. speed_of_sound ¶ The speed of sound of the device. The speed of sound in air is typically 343.3 m/s. volume ¶ The overall volume of the device. class aud. DynamicMusic ¶ The DynamicMusic object allows to play music depending on a current scene, scene changes are managed by the class, with the possibility of custom transitions. The default transition is a crossfade effect, and the default scene is silent and has id 0 addScene ( scene ) ¶ Adds a new scene. Parameters : scene ( Sound ) – The scene sound. Returns : The new scene id. Return type : int addTransition ( ini , end , transition ) ¶ Adds a new scene. Parameters : ini ( int ) – the initial scene foor the transition. end ( int ) – The final scene for the transition. transition ( Sound ) – The transition sound. Returns : false if the ini or end scenes don’t exist, true otherwise. Return type : bool pause ( ) ¶ Pauses playback of the scene. Returns : Whether the action succeeded. Return type : bool resume ( ) ¶ Resumes playback of the scene. Returns : Whether the action succeeded. Return type : bool stop ( ) ¶ Stops playback of the scene. Returns : Whether the action succeeded. Return type : bool fadeTime ¶ The length in seconds of the crossfade transition position ¶ The playback position of the scene in seconds. scene ¶ The current scene status ¶ Whether the scene is playing, paused or stopped (=invalid). volume ¶ The volume of the scene. class aud. HRTF ¶ An HRTF object represents a set of head related transfer functions as impulse responses. It’s used for binaural sound loadLeftHrtfSet ( extension , directory ) ¶ Loads all HRTFs from a directory. Parameters : extension ( string ) – The file extension of the hrtfs. directory – The path to where the HRTF files are located. Returns : The loaded HRTF object. Return type : HRTF loadRightHrtfSet ( extension , directory ) ¶ Loads all HRTFs from a directory. Parameters : extension ( string ) – The file extension of the hrtfs. directory – The path to where the HRTF files are located. Returns : The loaded HRTF object. Return type : HRTF addImpulseResponseFromSound ( sound , azimuth , elevation ) ¶ Adds a new hrtf to the HRTF object Parameters : sound ( Sound ) – The sound that contains the hrtf. azimuth ( float ) – The azimuth angle of the hrtf. elevation ( float ) – The elevation angle of the hrtf. Returns : Whether the action succeeded. Return type : bool class aud. Handle ¶ Handle objects are playback handles that can be used to control playback of a sound. If a sound is played back multiple times then there are as many handles. pause ( ) ¶ Pauses playback. Returns : Whether the action succeeded. Return type : bool resume ( ) ¶ Resumes playback. Returns : Whether the action succeeded. Return type : bool stop ( ) ¶ Stops playback. Returns : Whether the action succeeded. Return type : bool Note This makes the handle invalid. attenuation ¶ This factor is used for distance based attenuation of the source. See also Device.distance_model cone_angle_inner ¶ The opening angle of the inner cone of the source. If the cone values of a source are set there are two (audible) cones with the apex at the location of the source and with infinite height, heading in the direction of the source’s orientation . In the inner cone the volume is normal. Outside the outer cone the volume will be cone_volume_outer and in the area between the volume will be interpolated linearly. cone_angle_outer ¶ The opening angle of the outer cone of the source. See also cone_angle_inner cone_volume_outer ¶ The volume outside the outer cone of the source. See also cone_angle_inner distance_maximum ¶ The maximum distance of the source. If the listener is further away the source volume will be 0. See also Device.distance_model distance_reference ¶ The reference distance of the source. At this distance the volume will be exactly volume . See also Device.distance_model keep ¶ Whether the sound should be kept paused in the device when its end is reached. This can be used to seek the sound to some position and start playback again. Warning If this is set to true and you forget stopping this equals a memory leak as the handle exists until the device is destroyed. location ¶ The source’s location in 3D space, a 3D tuple of floats. loop_count ¶ The (remaining) loop count of the sound. A negative value indicates infinity. orientation ¶ The source’s orientation in 3D space as quaternion, a 4 float tuple. pitch ¶ The pitch of the sound. position ¶ The playback position of the sound in seconds. relative ¶ Whether the source’s location, velocity and orientation is relative or absolute to the listener. status ¶ Whether the sound is playing, paused or stopped (=invalid). velocity ¶ The source’s velocity in 3D space, a 3D tuple of floats. volume ¶ The volume of the sound. volume_maximum ¶ The maximum volume of the source. See also Device.distance_model volume_minimum ¶ The minimum volume of the source. See also Device.distance_model class aud. ImpulseResponse ¶ An ImpulseResponse object represents a filter with which to convolve a sound. class aud. PlaybackManager ¶ A PlabackManager object allows to easily control groups os sounds organized in categories. addCategory ( volume ) ¶ Adds a category with a custom volume. Parameters : volume ( float ) – The volume for ther new category. Returns : The key of the new category. Return type : int clean ( ) ¶ Cleans all the invalid and finished sound from the playback manager. getVolume ( catKey ) ¶ Retrieves the volume of a category. Parameters : catKey ( int ) – the key of the category. Returns : The volume of the category. Return type : float pause ( catKey ) ¶ Pauses playback of the category. Parameters : catKey ( int ) – the key of the category. Returns : Whether the action succeeded. Return type : bool play ( sound , catKey ) ¶ Plays a sound through the playback manager and assigns it to a category. Parameters : sound ( Sound ) – The sound to play. catKey ( int ) – the key of the category in which the sound will be added, if it doesn’t exist, a new one will be created. Returns : The playback handle with which playback can be controlled with. Return type : Handle resume ( catKey ) ¶ Resumes playback of the catgory. Parameters : catKey ( int ) – the key of the category. Returns : Whether the action succeeded. Return type : bool setVolume ( volume , catKey ) ¶ Changes the volume of a category. Parameters : volume ( float ) – the new volume value. catKey ( int ) – the key of the category. Returns : Whether the action succeeded. Return type : int stop ( catKey ) ¶ Stops playback of the category. Parameters : catKey ( int ) – the key of the category. Returns : Whether the action succeeded. Return type : bool class aud. Sequence ¶ This sound represents sequenced entries to play a sound sequence. add ( ) ¶ Adds a new entry to the sequence. Parameters : sound ( Sound ) – The sound this entry should play. begin ( double ) – The start time. end ( double ) – The end time or a negative value if determined by the sound. skip ( double ) – How much seconds should be skipped at the beginning. Returns : The entry added. Return type : SequenceEntry remove ( ) ¶ Removes an entry from the sequence. Parameters : entry ( SequenceEntry ) – The entry to remove. setAnimationData ( ) ¶ Writes animation data to a sequence. Parameters : type ( int ) – The type of animation data. frame ( int ) – The frame this data is for. data ( sequence of float ) – The data to write. animated ( bool ) – Whether the attribute is animated. channels ¶ The channel count of the sequence. distance_model ¶ The distance model of the sequence. See also OpenAL Documentation doppler_factor ¶ The doppler factor of the sequence. This factor is a scaling factor for the velocity vectors in doppler calculation. So a value bigger than 1 will exaggerate the effect as it raises the velocity. fps ¶ The listeners’s location in 3D space, a 3D tuple of floats. muted ¶ Whether the whole sequence is muted. rate ¶ The sampling rate of the sequence in Hz. speed_of_sound ¶ The speed of sound of the sequence. The speed of sound in air is typically 343.3 m/s. class aud. SequenceEntry ¶ SequenceEntry objects represent an entry of a sequenced sound. move ( ) ¶ Moves the entry. Parameters : begin ( double ) – The new start time. end ( double ) – The new end time or a negative value if unknown. skip ( double ) – How many seconds to skip at the beginning. setAnimationData ( ) ¶ Writes animation data to a sequenced entry. Parameters : type ( int ) – The type of animation data. frame ( int ) – The frame this data is for. data ( sequence of float ) – The data to write. animated ( bool ) – Whether the attribute is animated. attenuation ¶ This factor is used for distance based attenuation of the source. See also Device.distance_model cone_angle_inner ¶ The opening angle of the inner cone of the source. If the cone values of a source are set there are two (audible) cones with the apex at the location of the source and with infinite height, heading in the direction of the source’s orientation . In the inner cone the volume is normal. Outside the outer cone the volume will be cone_volume_outer and in the area between the volume will be interpolated linearly. cone_angle_outer ¶ The opening angle of the outer cone of the source. See also cone_angle_inner cone_volume_outer ¶ The volume outside the outer cone of the source. See also cone_angle_inner distance_maximum ¶ The maximum distance of the source. If the listener is further away the source volume will be 0. See also Device.distance_model distance_reference ¶ The reference distance of the source. At this distance the volume will be exactly volume . See also Device.distance_model muted ¶ Whether the entry is muted. relative ¶ Whether the source’s location, velocity and orientation is relative or absolute to the listener. sound ¶ The sound the entry is representing and will be played in the sequence. volume_maximum ¶ The maximum volume of the source. See also Device.distance_model volume_minimum ¶ The minimum volume of the source. See also Device.distance_model class aud. Sound ¶ Sound objects are immutable and represent a sound that can be played simultaneously multiple times. They are called factories because they create reader objects internally that are used for playback. classmethod buffer ( data , rate ) ¶ Creates a sound from a data buffer. Parameters : data ( numpy.ndarray ) – The data as two dimensional numpy array. rate ( double ) – The sample rate. Returns : The created Sound object. Return type : Sound classmethod file ( filename ) ¶ Creates a sound object of a sound file. Parameters : filename ( string ) – Path of the file. Returns : The created Sound object. Return type : Sound Warning If the file doesn’t exist or can’t be read you will not get an exception immediately, but when you try to start playback of that sound. classmethod list ( ) ¶ Creates an empty sound list that can contain several sounds. Parameters : random ( int ) – whether the playback will be random or not. Returns : The created Sound object. Return type : Sound classmethod sawtooth ( frequency , rate = 48000 ) ¶ Creates a sawtooth sound which plays a sawtooth wave. Parameters : frequency ( float ) – The frequency of the sawtooth wave in Hz. rate ( int ) – The sampling rate in Hz. It’s recommended to set this value to the playback device’s sampling rate to avoid resampling. Returns : The created Sound object. Return type : Sound classmethod silence ( rate = 48000 ) ¶ Creates a silence sound which plays simple silence. Parameters : rate ( int ) – The sampling rate in Hz. It’s recommended to set this value to the playback device’s sampling rate to avoid resampling. Returns : The created Sound object. Return type : Sound classmethod sine ( frequency , rate = 48000 ) ¶ Creates a sine sound which plays a sine wave. Parameters : frequency ( float ) – The frequency of the sine wave in Hz. rate ( int ) – The sampling rate in Hz. It’s recommended to set this value to the playback device’s sampling rate to avoid resampling. Returns : The created Sound object. Return type : Sound classmethod square ( frequency , rate = 48000 ) ¶ Creates a square sound which plays a square wave. Parameters : frequency ( float ) – The frequency of the square wave in Hz. rate ( int ) – The sampling rate in Hz. It’s recommended to set this value to the playback device’s sampling rate to avoid resampling. Returns : The created Sound object. Return type : Sound classmethod triangle ( frequency , rate = 48000 ) ¶ Creates a triangle sound which plays a triangle wave. Parameters : frequency ( float ) – The frequency of the triangle wave in Hz. rate ( int ) – The sampling rate in Hz. It’s recommended to set this value to the playback device’s sampling rate to avoid resampling. Returns : The created Sound object. Return type : Sound ADSR ( attack , decay , sustain , release ) ¶ Attack-Decay-Sustain-Release envelopes the volume of a sound. Note: there is currently no way to trigger the release with this API. Parameters : attack ( float ) – The attack time in seconds. decay ( float ) – The decay time in seconds. sustain ( float ) – The sustain level. release ( float ) – The release level. Returns : The created Sound object. Return type : Sound accumulate ( additive = False ) ¶ Accumulates a sound by summing over positive input differences thus generating a monotonic sigal. If additivity is set to true negative input differences get added too, but positive ones with a factor of two. Note that with additivity the signal is not monotonic anymore. Parameters : additive – Whether the accumulation should be additive or not. Returns : The created Sound object. Return type : Sound addSound ( sound ) ¶ Adds a new sound to a sound list. Parameters : sound ( Sound ) – The sound that will be added to the list. Note You can only add a sound to a sound list. animateableTimeStretchPitchScale ( fps [ , time_stretch , pitch_scale , quality , preserve_formant ] ) ¶ Applies time-stretching and pitch-scaling to the sound. Parameters : fps ( float ) – The FPS of the animation system. time_stretch (float or AnimateablePropertyP ) – The factor by which to stretch or compress time. pitch_scale (float or AnimateablePropertyP :arg quality: Rubberband stretcher quality (STRETCHER_QUALITY_*).) – The factor by which to adjust the pitch. preserve_formant ( bool ) – Whether to preserve the vocal formants during pitch-shifting. Returns : The created Sound object. Return type : Sound binaural ( ) ¶ Creates a binaural sound using another sound as source. The original sound must be mono Parameters : hrtfs – An HRTF set. source ( Source ) – An object representing the source position of the sound. threadPool ( ThreadPool ) – A thread pool used to parallelize convolution. Returns : The created Sound object. Return type : Sound cache ( ) ¶ Caches a sound into RAM. This saves CPU usage needed for decoding and file access if the underlying sound reads from a file on the harddisk, but it consumes a lot of memory. Returns : The created Sound object. Return type : Sound Note Only known-length factories can be buffered. Warning Raw PCM data needs a lot of space, only buffer short factories. convolver ( ) ¶ Creates a sound that will apply convolution to another sound. Parameters : impulseResponse ( ImpulseResponse ) – The filter with which convolve the sound. threadPool ( ThreadPool ) – A thread pool used to parallelize convolution. Returns : The created Sound object. Return type : Sound data ( ) ¶ Retrieves the data of the sound as numpy array. Returns : A two dimensional numpy float array. Return type : numpy.ndarray Note Best efficiency with cached sounds. delay ( time ) ¶ Delays by playing adding silence in front of the other sound’s data. Parameters : time ( float ) – How many seconds of silence should be added before the sound. Returns : The created Sound object. Return type : Sound envelope ( attack , release , threshold , arthreshold ) ¶ Delays by playing adding silence in front of the other sound’s data. Parameters : attack ( float ) – The attack factor. release ( float ) – The release factor. threshold ( float ) – The general threshold