Skip to content

Commit

Permalink
Docs & Getter
Browse files Browse the repository at this point in the history
Add getters for 3denabled
  • Loading branch information
Vurv78 committed May 7, 2022
1 parent 49c215a commit b3a4e0a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,8 @@ Returns the file name of the webaudio stream. Usually but not always returns the
``number webaudio:getLooping()``
Returns if the stream is looping, set by setLooping

``number webaudio:get3DEnabled()``
Returns if the webaudio is in 3D mode. This is true by default.

``array webaudio:getFFT()``
Returns an array of 64 FFT values from 0-255.
22 changes: 14 additions & 8 deletions lua/autorun/webaudio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,50 +215,56 @@ function WebAudio:GetTimeElapsed()
end

--- Returns the volume of the object set by SetVolume
---- @return number # # Volume from 0-1
--- @return number # Volume from 0-1
function WebAudio:GetVolume()
return self.volume
end

--- Returns the position of the WebAudio object.
---- @return GVector? # # Position of the stream or nil if not set.
--- @return GVector? # Position of the stream or nil if not set.
function WebAudio:GetPos()
return self.pos
end

--- Returns the radius of the stream set by SetRadius
---- @return number # # Radius
--- @return number # Radius
function WebAudio:GetRadius()
return self.radius
end

--- Returns the playtime length of a WebAudio object.
---- @return number # # Playtime Length
--- @return number # Playtime Length
function WebAudio:GetLength()
return self.length
end

--- Returns the file name of the WebAudio object. Not necessarily always the URL.
---- @return string # # File name
--- @return string # File name
function WebAudio:GetFileName()
return self.filename
end

--- Returns the state of the WebAudio object
---- @return number # # State, See STOPWATCH_* Enums
--- @return number # State, See STOPWATCH_* Enums
function WebAudio:GetState()
if self:IsDestroyed() then return STOPWATCH_STOPPED end
return self.stopwatch:GetState()
end

--- Returns whether the webaudio stream is looping (Set by SetLooping.)
---- @return boolean # # Looping
--- @return boolean # Looping
function WebAudio:GetLooping()
return self.looping
end

--- Returns whether the webaudio stream is 3D enabled (Set by Set3DEnabled.)
--- @return boolean # 3D Enabled
function WebAudio:Get3DEnabled()
return self.mode == WebAudio.MODE_3D
end

--- Returns whether the stream is parented or not. If it is parented, you won't be able to set it's position.
---- @return boolean # # Whether it's parented
--- @return boolean # # Whether it's parented
function WebAudio:IsParented()
return self.parented
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ desc("setParent(xwa:e)", "Parents the stream position to e, local to the entity.
desc("setParent(xwa:)", "Unparents the stream")
desc("setRadius(xwa:n)", "Sets the radius in which to the stream will be heard in. Default is 200 and (default) max is 1500.")
desc("setLooping(xwa:n)", "If n is not 0, sets the stream to loop. Else stops looping.")
desc("set3DEnabled(xwa:n)", "If n is not 0, sets the stream to be 3D. By default streams are 3D. Else, sets the audio to play directly on clients (mono audio).")

-- is* Getters
desc("isValid(xwa:)", "Returns 1 or 0 for whether the webaudio object is valid (If it is not destroyed & Not invalid from quota)")
Expand All @@ -43,6 +44,7 @@ desc("getPos(xwa:)", "Returns the current position of the WebAudio object. This
desc("getVolume(xwa:)", "Returns the volume of the WebAudio object set by setVolume")
desc("getRadius(xwa:)", "Returns the radius of the WebAudio object set by setRadius")
desc("getLooping(xwa:)", "Returns if the stream is looping, set by setLooping")
desc("get3DEnabled(xwa:)", "Returns if the stream's 3D is enabled, set by set3DEnabled")

-- Replicated Clientside behavior on server
desc("getTime(xwa:)", "Returns the playback time of the stream in seconds.")
Expand Down
4 changes: 4 additions & 0 deletions lua/entities/gmod_wire_expression2/core/custom/webaudio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ e2function number webaudio:getLooping()
return this:GetLooping() and 1 or 0
end

e2function number webaudio:get3DEnabled()
return this:Get3DEnabled() and 1 or 0
end

__e2setcost(800)
e2function array webaudio:getFFT()
return this:GetFFT(true, 0.08) or {}
Expand Down

0 comments on commit b3a4e0a

Please sign in to comment.