How many frames to write. If nil, writes as many as possible.
dstOffset
number
0
A frame offset to apply when writing the frames.
srcOffset
number
0
A frame, byte, or index offset to apply when reading frames from the source.
Returns
Name
Type
Description
count
number
The number of frames written.
Example
Generate a sine wave.
function lovr.load()
local length = 1
local rate = 48000
local frames = length * rate
local frequency = 440
local volume = 1.0
sound = lovr.data.newSound(frames, 'f32', 'stereo', rate)
local data = {}
for i = 1, frames do
local amplitude = math.sin((i - 1) * frequency / rate * (2 * math.pi)) * volume
data[2 * i - 1] = amplitude
data[2 * i - 0] = amplitude
end
sound:setFrames(data)
source = lovr.audio.newSource(sound)
source:setLooping(true)
source:play()
end