wiki.sine.space | sinespace

Scripting/SAudioSource

From wiki.sine.space
Revision as of 15:35, 19 July 2017 by Kay T Burnett (Talk | contribs) (Created the page; added Enabled, Loop, DopplerLevel)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The SAudioSource class deals with the Audio Source component, which allows the object to play sounds in the scene.

Properties

Enabled

bool Enabled {get;set;}

Is the Audio Source component enabled?

hostObject = Space.Host.ExecutingObject;

function audioOnOff ()

hostObject.Audio.Enabled = not hostObject.Audio.Enabled;
Space.Log(hostObject.Audio.Enabled);

end

hostObject.SubscribeToEvents();
hostObject.OnMouseDown(audioOnOff);
-- When the host object is clicked, the Audio Source component gets enabled, if it was disabled,

-- or disabled, if it was enabled, and its new state is printed to the console.


Loop

bool Loop {get;set;}

Is looping of the sound clip enabled?

hostObject = Space.Host.ExecutingObject;

Space.Log(hostObject.Audio.Loop);
-- False by default.

if not hostObject.Audio.Loop then

hostObject.Audio.Loop = true;

end

-- Now it is looping.


DopplerLevel

float DopplerLevel {get;set;}

The Doppler level for the Audio Source. (See: Doppler Effect)

hostObject = Space.Host.ExecutingObject;

Space.Log(hostObject.Audio.DopplerLevel);
-- 1 by default
hostObject.Audio.DopplerLevel = 5;

-- The highest possible value