(Created the page; added Enabled, Loop, DopplerLevel) |
(Added Volume, Pitch, Time, IsPlaying) |
||
Line 23: | Line 23: | ||
''-- Now it is looping.''}} | ''-- Now it is looping.''}} | ||
− | {{ScriptFunction|float|DopplerLevel|{get;set;}|The Doppler level | + | {{ScriptFunction|float|DopplerLevel|{get;set;}|The Doppler level of the Audio Source. (See: Doppler Effect)|5= |
hostObject = Space.Host.ExecutingObject;<br><br> | hostObject = Space.Host.ExecutingObject;<br><br> | ||
Space.Log(hostObject.Audio.DopplerLevel);<br> | Space.Log(hostObject.Audio.DopplerLevel);<br> | ||
Line 29: | Line 29: | ||
hostObject.Audio.DopplerLevel = 5;<br> | hostObject.Audio.DopplerLevel = 5;<br> | ||
''-- The highest possible value''}} | ''-- The highest possible value''}} | ||
+ | |||
+ | {{ScriptFunction|float|Volume|{get;set;}|The Volume level of the Audio Source. |5= | ||
+ | hostObject = Space.Host.ExecutingObject;<br> | ||
+ | Space.Log(hostObject.Audio.Volume);<br> | ||
+ | ''-- 1 by default''<br><br> | ||
+ | function audioVolumeDecr ()<br> | ||
+ | :if hostObject.Audio.Volume > 0 then<br> | ||
+ | ::hostObject.Audio.Volume = hostObject.Audio.Volume - 0.2;<br> | ||
+ | :end<br> | ||
+ | :Space.Log(hostObject.Audio.Volume);<br> | ||
+ | end<br><br> | ||
+ | hostObject.SubscribeToEvents();<br> | ||
+ | hostObject.OnMouseDown(audioVolumeDecr);<br> | ||
+ | ''-- Now, every time we click this object, the Volume level is decreased by 0.2, until it reaches 0.''}} | ||
+ | |||
+ | {{ScriptFunction|float|Pitch|{get;set;}|The Pitch level for the Audio Source. |5= | ||
+ | hostObject = Space.Host.ExecutingObject;<br> | ||
+ | Space.Log(hostObject.Audio.Pitch);<br> | ||
+ | ''-- 1 by default''<br><br> | ||
+ | function audioPitchChange ()<br> | ||
+ | :if hostObject.Audio.Pitch < 3 then<br> | ||
+ | ::hostObject.Audio.Pitch = hostObject.Audio.Pitch + 0.5;<br> | ||
+ | :end<br> | ||
+ | :Space.Log(hostObject.Audio.Pitch);<br> | ||
+ | end<br><br> | ||
+ | hostObject.SubscribeToEvents();<br> | ||
+ | hostObject.OnMouseDown(audioPitchChange);<br> | ||
+ | ''-- Now, every time we click this object, the Pitch level is increased by 0.5, until it reaches 3.''}} | ||
+ | |||
+ | {{ScriptFunction|float|Time|{get;set;}|Playback position in seconds. |5= | ||
+ | hostObject = Space.Host.ExecutingObject;<br><br> | ||
+ | Space.Log(hostObject.Audio.Time);<br> | ||
+ | ''-- 0 by default (the beginning of the sound clip)''<br> | ||
+ | hostObject.Audio.Time = 15;<br> | ||
+ | ''-- jumps to the 0:15 position of the sound clip''<br> | ||
+ | hostObject.Audio.Time = 75;<br> | ||
+ | ''-- jumps to the 1:15 position of the sound clip''}} | ||
+ | |||
+ | {{ScriptFunction|bool|IsPlaying|{get;}|Is the sound clip playing right now? |5= | ||
+ | hostObject = Space.Host.ExecutingObject;<br><br> | ||
+ | Space.Log(hostObject.Audio.IsPlaying);<br> | ||
+ | ''-- prints True (by default), if the sound clip is playing, or False, if it doesn't, to the console''}} |
The SAudioSource class deals with the Audio Source component, which allows the object to play sounds in the scene.
Is the Audio Source component enabled?
function audioOnOff ()
end
hostObject.SubscribeToEvents();
hostObject.OnMouseDown(audioOnOff);
-- When the host object is clicked, the Audio Source component gets enabled, if it was disabled,
Is looping of the sound clip enabled?
Space.Log(hostObject.Audio.Loop);
-- False by default.
if not hostObject.Audio.Loop then
end
The Doppler level of the Audio Source. (See: Doppler Effect)
Space.Log(hostObject.Audio.DopplerLevel);
-- 1 by default
hostObject.Audio.DopplerLevel = 5;
The Volume level of the Audio Source.
Space.Log(hostObject.Audio.Volume);
-- 1 by default
function audioVolumeDecr ()
end
hostObject.SubscribeToEvents();
hostObject.OnMouseDown(audioVolumeDecr);
The Pitch level for the Audio Source.
Space.Log(hostObject.Audio.Pitch);
-- 1 by default
function audioPitchChange ()
end
hostObject.SubscribeToEvents();
hostObject.OnMouseDown(audioPitchChange);
Playback position in seconds.
Space.Log(hostObject.Audio.Time);
-- 0 by default (the beginning of the sound clip)
hostObject.Audio.Time = 15;
-- jumps to the 0:15 position of the sound clip
hostObject.Audio.Time = 75;
Is the sound clip playing right now?
Space.Log(hostObject.Audio.IsPlaying);