natiny.clip.reload

Lua
natiny.clip.reload(clip, ogg)

Replaces the samples inside an existing clip. The handle does not change.

Parameters

Name Type Description
clip number Live clip handle from natiny.clip.load
ogg number Resource handle containing Ogg Vorbis data

Example

Lua
local clip   = natiny.clip.load(resource)
local source = natiny.audio.source_create(clip)
local replacement = natiny.resource.load("sounds/rain.ogg")

-- every source on this clip picks up the new sound
natiny.clip.reload(clip, replacement)
natiny.resource.destroy(replacement)

Notes

  • Raises an error if clip is not live or ogg cannot be decoded as Ogg Vorbis. A failure leaves the old samples unchanged.
  • The resource bytes are consumed during the call and may be destroyed after a successful reload.