If you don't want to use sound spatialization, just ignore this property
Sound.velocity read/write property
Get or set the sound current velocity (speed and direction)
This property expects a 3D vector, a table with the fields x
, y
, z
set, representing the coordinates in space where the sound is at a given time
For example, the velocity { x = 0, y = 0, z = 0 }
means the sound didn't moved (the default velocity)
Example
local audio = require "audio"
local console = require "console"
local sound = audio.Sound("music.mp3")
local function printvector(v)
-- Fancy Formatting
console.writecolor("brightwhite", "Sound "..v..(#v < 7 and ":\t\t" or " :\t"))
local value = "{ "
for axis, val in pairs(sound[v]) do
value = value..axis.." = "..val..", "
end
value = value:gsub(", $", " }")
console.writecolor("cyan", value.."\n")
end
-- Get default listener position, direction, veolocity, worldup and cone
printvector("position")
printvector("direction")
printvector("velocity")
printvector("cone")