sone
Functions
amplify (sound, gain)
copy (sound, copyOverData)
Makes a copy of a SoundData. **Example** ```lua copy = sone.copy(sound) ```
Arguments
SoundData sound
The sound to copy.
boolean copyOverData
(optional) If false, only a new SoundData will be created with the same sample count, sample rate, bit depth, and channels. The actual signal data will not be copied.
Returns
SoundData
The copied sound.
fadeIn (sound, seconds, fadeType)
Fades in a sound to full volume over a number of seconds. **Example** ```lua -- Fade in sound linearly over 3 seconds. sone.fadeIn(sound, 3) -- Fade in sound exponentially over 10 seconds. sone.fadeIn(sound, 10, "inOutExpo") ```
Arguments
SoundData sound
number seconds
How long the fade will take.
FadeType fadeType
(optional) Which fade curve to use. Default is linear.
Returns
SoundData
fadeInOut (sound, seconds, fadeType)
Fades a sound at the beginning and at the end. The first N seconds will be faded in, and the last N seconds will be faded out. **Example** ```lua -- Fade the first 5 seconds and last 5 seconds of a sound. sone.fadeInOut(sound, 5) ```
Arguments
SoundData sound
number seconds
How long the fade will take.
FadeType fadeType
(optional) Which fade curve to use. Default is linear.
Returns
SoundData
fadeOut (sound, seconds, fadeType)
Fades out a sound to zero volume over a number of seconds. **Example** ```lua -- Fade out sound linearly over 3 seconds. sone.fadeOut(sound, 3) -- Fade out sound exponentially over 10 seconds. sone.fadeOut(sound, 10, "inOutExpo") ```
Arguments
SoundData sound
number seconds
How long the fade will take.
FadeType fadeType
(optional) Which fade curve to use. Default is linear.
Returns
SoundData
filter (sound, parameters)
Filters a sound with different filters and settings. **Example** ```lua -- Filter out all sounds below 1000Hz. sone.filter(sound, { type = "highpass", frequency = 1000, }) ```
Arguments
SoundData sound
FilterParameters parameters
Returns
SoundData
pan (sound, pan)
Pans a sound to either the left or right channel. Only works for stereo sounds. **Example** ```lua -- Play sound 85% in the right channel, 15% in the left channel. sone.pan(sound, 0.85) ```
Arguments
SoundData sound
number pan
How to pan the input (range: -1.0 to 1.0), where -1.0 is far left, 1.0 is far right, and 0.0 is dead center.
Returns
SoundData
Contexts
Using sone for sound processing
Examples of using sone to process a sound. ```lua sone = require 'sone' sound = love.sound.newSoundData(...) -- NOTE: All sone functions will alter the sound data directly. -- Filter out all sounds above 150Hz. sone.filter(sound, { type = "lowpass", frequency = 150, }) -- Boost sound at 1000Hz sone.filter(sound, { type = "peakeq", frequency = 1000, gain = 9, }) -- Boost everything below 150Hz by 6dB sone.filter(sound, { type = "lowshelf", frequency = 150, gain = 6, }) -- Amplify sound by 3dB sone.amplify(sound, 3) -- Pan sound to the left ear sone.pan(sound, -1) -- Fade in sound over 5 seconds sone.fadeIn(sound, 5) -- Fade in sound over 5 seconds, and also fade out the last 5 seconds sone.fadeInOut(sound, 5) -- Play the sound data love.audio.newSource(sound):play() ```
Types
FadeType
Fields
string inCirc
string inCubic
string inExpo
string inOutCirc
string inOutCubic
string inOutExpo
string inOutQuad
string inOutQuart
string inOutQuint
string inOutSine
string inQuad
string inQuart
string inQuint
string inSine
string linear
string outCirc
string outCubic
string outExpo
string outInCirc
string outInCubic
string outInExpo
string outInQuad
string outInQuart
string outInQuint
string outInSine
string outQuad
string outQuart
string outQuint
string outSine
FilterParameters
A table of the possible parameters for the filter function.
Fields
number Q
(optional) The quality factor to use. Ranges from 0 to 100. Default: 1.
number finish
(optional) The time (in seconds) for the finish of the filtered section. Default: the duration of the sound.
number finishSample
(optional) The finish (in samples) of the filtered section. Default: the number of samples in the sound.
number frequency
**REQUIRED** The center/target frequency (in Hz). Ranges from 0Hz to (Sampling rate) / 2 Hz.
number gain
(optional) The gain (in dB) to use for EQ filters. Ranges from -60dB to 60dB. Default: 0dB.
number start
(optional) The time (in seconds) for the start of the filtered section. Default: 0 seconds.
number startSample
(optional) The start (in samples) of the filtered section. Default: 0.
FilterType type
**REQUIRED** The type of filter to use.
FilterType
Filters that are able to be used with the filter function. (`sone.filter`)
Fields
string allpass
string bandpass
string highpass
string highshelf
string lowpass
string lowshelf
string notch
string peakeq
SoundData
A SoundData object from LOVE. https://www.love2d.org/wiki/SoundData