importauddevice=aud.device()# load sound file (it can be a video file with audio)factory=aud.Factory('music.ogg')# play the audio, this return a handle to control play/pausehandle=device.play(factory)# if the audio is not too big and will be used often you can buffer itfactory_buffered=aud.Factory.buffer(factory)handle_buffered=device.play(factory_buffered)# stop the sounds (otherwise they play until their ends)handle.stop()handle_buffered.stop()

Factory 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.

After the fade this factory plays silence, so that the length of the factory is not altered.

filter(b, a = (1))

Filters a factory with the supplied IIR filter coefficients.
Without the second parameter you’ll get a FIR filter.
If the first value of the a sequence is 0 it will be set to 1 automatically.
If the first value of the a sequence is neither 0 nor 1, all filter coefficients will be scaled by this value so that it is 1 in the end, you don’t have to scale yourself.

The factory has to have a finite length and has to be seekable. It’s recommended to use this only with factories with fast and accurate seeking, which is not true for encoded audio files, such ones should be buffered using buffer() before being played reversed.

Warning

If seeking is not accurate in the underlying factory you’ll likely hear skips/jumps/cracks.

square(threshold = 0)

Makes a square wave out of an audio wave by setting all samples with a amplitude >= threshold to 1, all <= -threshold to -1 and all between to 0.

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.