Love2D APISourceOn this pageSource Description: A Source represents audio you can play back. type Type: Function. Description: Gets the type of the object as a string. Signature: type: function(self: Source): string Returns: Return TypeDescriptionstringThe type as a string. Of Type: Function. Description: Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true. Signature: typeOf: function(self: Source, type_name: string): boolean Parameters: ParameterTypeDescriptiontype_namestringThe name of the type to check for. Returns: Return TypeDescriptionbooleanTrue if the object is of the specified type, false otherwise. release Type: Function. Description: Destroys the object's Lua reference. The object will be completely deleted if it's not referenced by any other LÖVE object or thread. This method can be used to immediately clean up resources without waiting for Lua's garbage collector. Signature: release: function(self: Source): boolean Returns: Return TypeDescriptionbooleanTrue if the object was released by this call, false if it had been previously released. clone Type: Function. Description: Creates an identical copy of the Source in the stopped state. Static Sources will use significantly less memory and take much less time to be created if Source:clone is used to create them instead of love.audio.newSource, so this method should be preferred when making multiple Sources which play the same sound. Overload details: Cloned Sources inherit all the set-able state of the original Source, but they are initialized stopped. Signature: clone: function(self: Source): Source Returns: Return TypeDescriptionSourceThe new identical copy of this Source. play Type: Function. Description: Starts playing the Source. Signature: play: function(self: Source): boolean Returns: Return TypeDescriptionbooleanWhether the Source was able to successfully start playing. pause Type: Function. Description: Pauses the Source. Signature: pause: function(self: Source) stop Type: Function. Description: Stops a Source. Signature: stop: function(self: Source) isPlaying Type: Function. Description: Returns whether the Source is playing. Signature: isPlaying: function(self: Source): boolean Returns: Return TypeDescriptionbooleanTrue if the Source is playing, false otherwise. isStopped Type: Function. Description: Returns whether this Source is stopped. Deprecated compatibility alias which is true only when the Source is neither playing nor paused. Signature: isStopped: function(self: Source): boolean isPaused: function(self: Source): boolean setLooping Type: Function. Description: Sets whether the Source should loop. Signature: setLooping: function(self: Source, looping: boolean) Parameters: ParameterTypeDescriptionloopingbooleanTrue if the source should loop, false otherwise. isLooping Type: Function. Description: Returns whether the Source will loop. Signature: isLooping: function(self: Source): boolean Returns: Return TypeDescriptionbooleanTrue if the Source will loop, false otherwise. setVolume Type: Function. Description: Sets the current volume of the Source. Signature: setVolume: function(self: Source, volume: number) Parameters: ParameterTypeDescriptionvolumenumberThe volume for a Source, where 1.0 is normal volume. Volume cannot be raised above 1.0. getVolume Type: Function. Description: Gets the current volume of the Source. Signature: getVolume: function(self: Source): number Returns: Return TypeDescriptionnumberThe volume of the Source, where 1.0 is normal volume. setPitch Type: Function. Description: Sets the pitch of the Source. Signature: setPitch: function(self: Source, pitch: number) Parameters: ParameterTypeDescriptionpitchnumberCalculated with regard to 1 being the base pitch. Each reduction by 50 percent equals a pitch shift of -12 semitones (one octave reduction). Each doubling equals a pitch shift of 12 semitones (one octave increase). Zero is not a legal value. getPitch Type: Function. Description: Gets the current pitch of the Source. Signature: getPitch: function(self: Source): number Returns: Return TypeDescriptionnumberThe pitch, where 1.0 is normal. seek Type: Function. Description: Sets the currently playing position of the Source. Signature: seek: function(self: Source, offset: number, unit?: string) Parameters: ParameterTypeDescriptionoffsetnumberThe position to seek to.unitstringThe unit of the position value. (Default: 'seconds'.) tell Type: Function. Description: Gets the currently playing position of the Source. Signature: tell: function(self: Source, unit?: string): number Parameters: ParameterTypeDescriptionunitstringThe type of unit for the return value. (Default: 'seconds'.) Returns: Return TypeDescriptionnumberThe currently playing position of the Source. getDuration Type: Function. Description: Gets the duration of the Source. For streaming Sources it may not always be sample-accurate, and may return -1 if the duration cannot be determined at all. Signature: getDuration: function(self: Source, unit?: string): number Parameters: ParameterTypeDescriptionunitstringThe time unit for the return value. (Default: 'seconds'.) Returns: Return TypeDescriptionnumberThe duration of the Source, or -1 if it cannot be determined. getChannelCount Type: Function. Description: Gets the number of channels in the Source. Only 1-channel (mono) Sources can use directional and positional effects. Signature: getChannelCount: function(self: Source): integer getChannels: function(self: Source): integer Returns: Return TypeDescriptioninteger1 for mono, 2 for stereo. getFreeBufferCount Type: Function. Description: Gets the number of free buffer slots in a queueable Source. If the queueable Source is playing, this value will increase up to the amount the Source was created with. If the queueable Source is stopped, it will process all of its internal buffers first, in which case this function will always return the amount it was created with. Signature: getFreeBufferCount: function(self: Source): integer Returns: Return TypeDescriptionintegerHow many more SoundData objects can be queued up. queue Type: Function. Description: Queues SoundData for playback in a queueable Source. -- This method requires the Source to be created via love.audio.newQueueableSource. Signature: queue: function(self: Source, data: SoundData, length?: number): boolean Parameters: ParameterTypeDescriptiondataSoundDataThe data to queue. The SoundData's sample rate, bit depth, and channel count must match the Source's.lengthnumberThe number of bytes to queue. (Default: all remaining data.) Returns: Return TypeDescriptionbooleansuccess — True if the data was successfully queued for playback, false if there were no available buffers to use for queueing. queue Type: Function. Description: Queues SoundData for playback in a queueable Source. -- This method requires the Source to be created via love.audio.newQueueableSource. Signature: queue: function(self: Source, data: SoundData, offset: number, length: number): boolean Parameters: ParameterTypeDescriptiondataSoundDataThe data to queue. The SoundData's sample rate, bit depth, and channel count must match the Source's.offsetnumberThe byte offset at which to start queueing data.lengthnumberThe number of bytes to queue. Returns: Return TypeDescriptionbooleansuccess — True if the data was successfully queued for playback, false if there were no available buffers to use for queueing. setPosition Type: Function. Description: Sets the position of the Source. Please note that this only works for mono (i.e. non-stereo) sound files! Signature: setPosition: function(self: Source, x: number, y: number, z?: number) Parameters: ParameterTypeDescriptionxnumberThe X position of the Source.ynumberThe Y position of the Source.znumberThe Z position of the Source. getPosition Type: Function. Description: Gets the position of the Source. Signature: getPosition: function(self: Source): number, number, number Returns: Return TypeDescriptionnumberThe X position of the Source.numberThe Y position of the Source.numberThe Z position of the Source. setVelocity Type: Function. Description: Sets the velocity of the Source. This does '''not''' change the position of the Source, but lets the application know how it has to calculate the doppler effect. Signature: setVelocity: function(self: Source, x: number, y: number, z?: number) Parameters: ParameterTypeDescriptionxnumberThe X part of the velocity vector.ynumberThe Y part of the velocity vector.znumberThe Z part of the velocity vector. getVelocity Type: Function. Description: Gets the velocity of the Source. Signature: getVelocity: function(self: Source): number, number, number Returns: Return TypeDescriptionnumberThe X part of the velocity vector.numberThe Y part of the velocity vector.numberThe Z part of the velocity vector. setDirection Type: Function. Description: Sets the direction vector of the Source. A zero vector makes the source non-directional. Signature: setDirection: function(self: Source, x: number, y: number, z?: number) Parameters: ParameterTypeDescriptionxnumberThe X part of the direction vector.ynumberThe Y part of the direction vector.znumberThe Z part of the direction vector. getDirection Type: Function. Description: Gets the direction of the Source. Signature: getDirection: function(self: Source): number, number, number Returns: Return TypeDescriptionnumberThe X part of the direction vector.numberThe Y part of the direction vector.numberThe Z part of the direction vector. setCone Type: Function. Description: Sets the Source's directional volume cones. Together with Source:setDirection, the cone angles allow for the Source's volume to vary depending on its direction. Signature: setCone: function(self: Source, inner_angle: number, outer_angle: number, outer_volume?: number, outer_high_gain?: number) Parameters: ParameterTypeDescriptioninner_anglenumberThe inner angle from the Source's direction, in radians. The Source will play at normal volume if the listener is inside the cone defined by this angle.outer_anglenumberThe outer angle from the Source's direction, in radians. The Source will play at a volume between the normal and outer volumes, if the listener is in between the cones defined by the inner and outer angles.outer_volumenumberThe Source's volume when the listener is outside both the inner and outer cone angles. (Default: 0.)outer_high_gainnumberThe outer_high_gain parameter. getCone Type: Function. Description: Gets the Source's directional volume cones. Together with Source:setDirection, the cone angles allow for the Source's volume to vary depending on its direction. Signature: getCone: function(self: Source): number, number, number, number Returns: Return TypeDescriptionnumberThe inner angle from the Source's direction, in radians. The Source will play at normal volume if the listener is inside the cone defined by this angle.numberThe outer angle from the Source's direction, in radians. The Source will play at a volume between the normal and outer volumes, if the listener is in between the cones defined by the inner and outer angles.numberThe Source's volume when the listener is outside both the inner and outer cone angles. setAirAbsorption Type: Function. Description: Sets the amount of air absorption applied to the Source. By default the value is set to 0 which means that air absorption effects are disabled. A value of 1 will apply high frequency attenuation to the Source at a rate of 0.05 dB per meter. Air absorption can simulate sound transmission through foggy air, dry air, smoky atmosphere, etc. It can be used to simulate different atmospheric conditions within different locations in an area. Overload details: Audio air absorption functionality is not supported on iOS. Signature: setAirAbsorption: function(self: Source, factor: number) Parameters: ParameterTypeDescriptionfactornumberThe amount of air absorption applied to the Source. Must be between 0 and 10. getAirAbsorption Type: Function. Description: Gets the amount of air absorption applied to the Source. By default the value is set to 0 which means that air absorption effects are disabled. A value of 1 will apply high frequency attenuation to the Source at a rate of 0.05 dB per meter. Overload details: Audio air absorption functionality is not supported on iOS. Signature: getAirAbsorption: function(self: Source): number Returns: Return TypeDescriptionnumberThe amount of air absorption applied to the Source. setVolumeLimits Type: Function. Description: Sets the volume limits of the source. The limits have to be numbers from 0 to 1. Signature: setVolumeLimits: function(self: Source, min_volume: number, max_volume: number) Parameters: ParameterTypeDescriptionmin_volumenumberThe minimum volume.max_volumenumberThe maximum volume. getVolumeLimits Type: Function. Description: Returns the volume limits of the source. Signature: getVolumeLimits: function(self: Source): number, number Returns: Return TypeDescriptionnumberThe minimum volume.numberThe maximum volume. setRelative Type: Function. Description: Sets whether the Source's position, velocity, direction, and cone angles are relative to the listener, or absolute. By default, all sources are absolute and therefore relative to the origin of love's coordinate system 0, 0. Only absolute sources are affected by the position of the listener. Please note that positional audio only works for mono (i.e. non-stereo) sources. Signature: setRelative: function(self: Source, relative: boolean) Parameters: ParameterTypeDescriptionrelativebooleanTrue to make the position, velocity, direction and cone angles relative to the listener, false to make them absolute. (Default: false.) isRelative Type: Function. Description: Gets whether the Source's position, velocity, direction, and cone angles are relative to the listener. Signature: isRelative: function(self: Source): boolean Returns: Return TypeDescriptionbooleanTrue if the position, velocity, direction and cone angles are relative to the listener, false if they're absolute. setAttenuationDistances Type: Function. Description: Sets the reference and maximum attenuation distances of the Source. The parameters, combined with the current DistanceModel, affect how the Source's volume attenuates based on distance. Distance attenuation is only applicable to Sources based on mono (rather than stereo) audio. Signature: setAttenuationDistances: function(self: Source, reference_distance: number, max_distance: number) Parameters: ParameterTypeDescriptionreference_distancenumberThe new reference attenuation distance. If the current DistanceModel is clamped, this is the minimum attenuation distance.max_distancenumberThe new maximum attenuation distance. getAttenuationDistances Type: Function. Description: Gets the reference and maximum attenuation distances of the Source. The values, combined with the current DistanceModel, affect how the Source's volume attenuates based on distance from the listener. Signature: getAttenuationDistances: function(self: Source): number, number Returns: Return TypeDescriptionnumberThe current reference attenuation distance. If the current DistanceModel is clamped, this is the minimum distance before the Source is no longer attenuated.numberThe current maximum attenuation distance. setRolloff Type: Function. Description: Sets the rolloff factor which affects the strength of the used distance attenuation. Extended information and detailed formulas can be found in the chapter '3.4. Attenuation By Distance' of OpenAL 1.1 specification. Signature: setRolloff: function(self: Source, rolloff: number) Parameters: ParameterTypeDescriptionrolloffnumberThe new rolloff factor. getRolloff Type: Function. Description: Returns the rolloff factor of the source. Signature: getRolloff: function(self: Source): number Returns: Return TypeDescriptionnumberThe rolloff factor. setFilter Type: Function. Description: Sets a low-pass, high-pass, or band-pass filter to apply when playing the Source. Signature: setFilter: function(self: Source): boolean Returns: Return TypeDescriptionbooleansuccess — Whether the filter was successfully applied to the Source. setFilter Type: Function. Description: Sets a low-pass, high-pass, or band-pass filter to apply when playing the Source. Signature: setFilter: function(self: Source, filter: AudioFilterSettings): boolean Parameters: ParameterTypeDescriptionfilterAudioFilterSettingsThe filter settings to use for this Source, with the following fields: Returns: Return TypeDescriptionbooleansuccess — Whether the filter was successfully applied to the Source. getFilter Type: Function. Description: Gets the filter settings currently applied to the Source. Signature: getFilter: function(self: Source, target?: AudioFilterSettings): AudioFilterSettings | nil Parameters: ParameterTypeDescriptiontargetAudioFilterSettingsThe target parameter. Returns: Return TypeDescriptionAudioFilterSettings or nilThe filter settings to use for this Source, or nil if the Source has no active filter. The table has the following fields: setEffect Type: Function. Description: Applies an audio effect to the Source. -- The effect must have been previously defined using love.audio.setEffect. Signature: setEffect: function(self: Source, name: string): boolean Parameters: ParameterTypeDescriptionnamestringThe name of the effect previously set up with love.audio.setEffect. Returns: Return TypeDescriptionbooleansuccess — Whether the effect was successfully applied to this Source. setEffect Type: Function. Description: Applies an audio effect to the Source. -- The effect must have been previously defined using love.audio.setEffect. Signature: setEffect: function(self: Source, name: string, enabled: boolean): boolean Parameters: ParameterTypeDescriptionnamestringThe name of the effect previously set up with love.audio.setEffect.enabledbooleanWhether the effect should be enabled. Pass false to disable an active effect. (Default: true.) Returns: Return TypeDescriptionbooleansuccess — Whether the effect was successfully applied to this Source. setEffect Type: Function. Description: Applies an audio effect to the Source. -- The effect must have been previously defined using love.audio.setEffect. Signature: setEffect: function(self: Source, name: string, enabled: AudioFilterSettings): boolean Parameters: ParameterTypeDescriptionnamestringThe name of the effect previously set up with love.audio.setEffect.enabledAudioFilterSettingsThe filter settings to apply prior to the effect, with the following fields: Returns: Return TypeDescriptionbooleanWhether the effect and filter were successfully applied to this Source. getEffect Type: Function. Description: Gets the filter settings associated to a specific effect. This function returns nil if the effect was applied with no filter settings associated to it. Signature: getEffect: function(self: Source, name: string, target?: AudioFilterSettings): boolean, AudioFilterSettings | nil Parameters: ParameterTypeDescriptionnamestringThe name of the effect.targetAudioFilterSettingsAn optional empty table that will be filled with the filter settings. (Default: {}.) Returns: Return TypeDescriptionbooleanThe settings for the filter associated to this effect, or nil if the effect is not present in this Source or has no filter associated. The table has the following fields: getActiveEffects Type: Function. Description: Gets a list of the Source's active effect names. Signature: getActiveEffects: function(self: Source): {string} Returns: Return TypeDescription{string}A list of the source's active effect names. getType Type: Function. Description: Gets the type of the Source. Signature: getType: function(self: Source): string Returns: Return TypeDescriptionstringThe type of the source.