You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Added WebAudio:Set3DEnabled, to make sound "flat" inside of the radius where it will play on the client and 3D functions won't do anything.
* Added webaudio:set3DEnabled for E2
* Nerfed wa_radius_max to 4,000 units by default. 10k was fine with volume scaling but will definitely be an issue without it.
* Make streams default play on the chip if never used with setPos(), so you can now just do webAudio("Sound"):play().
* Make 3D Audio not fizzle out after such a short distance (with magic numbers)
* Use DistToSqr instead of Distance in volume calculation as an optimization
Copy file name to clipboardExpand all lines: lua/autorun/webaudio.lua
+17-3Lines changed: 17 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -16,8 +16,9 @@ local Modify = {
16
16
parented=64,
17
17
radius=128,
18
18
looping=256,
19
+
mode=512,
19
20
20
-
destroyed=512
21
+
destroyed=1024
21
22
}
22
23
23
24
localfunctionhasModifyFlag(first, ...)
@@ -44,7 +45,7 @@ local WAMaxStreamsPerUser = CreateConVar("wa_stream_max", "5", FCVAR_REPLICATED,
44
45
-- SHARED
45
46
localWAEnabled=CreateConVar("wa_enable", "1", FCVAR_ARCHIVE+FCVAR_USERINFO, "Whether webaudio should be enabled to play on your client/server or not.", 0, 1)
46
47
localWAMaxVolume=CreateConVar("wa_volume_max", "300", FCVAR_ARCHIVE, "Highest volume a webaudio sound can be played at, in percentage. 200 is 200%. SHARED Convar", 0, 100000)
47
-
localWAMaxRadius=CreateConVar("wa_radius_max", "10000", FCVAR_ARCHIVE, "Farthest distance a WebAudio stream can be heard from. Will clamp to this value. SHARED Convar", 0, 1000000)
48
+
localWAMaxRadius=CreateConVar("wa_radius_max", "3000", FCVAR_ARCHIVE, "Farthest distance a WebAudio stream can be heard from. Will clamp to this value. SHARED Convar", 0, 1000000)
48
49
localWAFFTEnabled=CreateConVar("wa_fft_enable", "1", FCVAR_ARCHIVE, "Whether FFT data is enabled for the server / your client. You shouldn't need to disable it as it is very lightweight.", 0, 1)
49
50
50
51
-- CLIENT
@@ -86,6 +87,7 @@ end
86
87
---@classWebAudio
87
88
---@fieldstopwatchStopwatch # SERVER
88
89
---@fieldradiusnumber # SHARED
90
+
---@fieldradius_sqrnumber # SHARED
89
91
---@fieldloopingboolean # SHARED
90
92
---@fieldparentGEntity # SHARED
91
93
---@fieldparentedboolean # SHARED
@@ -99,9 +101,17 @@ end
99
101
---@fieldposGVector # SERVER. Position of stream
100
102
---@fieldidinteger # Custom ID for webaudio stream allocated between 0-MAX
101
103
---@fieldignoredGCRecipientFilter # Players to ignore when sending net messages.
104
+
---@fieldmodeWebAudioMode
102
105
_G.WebAudio= {}
103
106
WebAudio.__index=WebAudio
104
107
108
+
---@aliasWebAudioMode 0|1
109
+
110
+
---@typeWebAudioMode
111
+
WebAudio.MODE_2D=0
112
+
---@typeWebAudioMode
113
+
WebAudio.MODE_3D=1
114
+
105
115
localWebAudioCounter=0
106
116
localWebAudios= {} -- TODO: See why weak kv doesn't work clientside for this
107
117
@@ -266,7 +276,7 @@ end
266
276
267
277
-- Bit lengths
268
278
localID_LEN=10
269
-
localMODIFY_LEN=10
279
+
localMODIFY_LEN=11
270
280
localFFTSAMP_LEN=8
271
281
272
282
WebAudio.ID_LEN=ID_LEN
@@ -309,6 +319,7 @@ function WebAudioStatic.writeModify(modify)
309
319
net.WriteUInt(modify, MODIFY_LEN)
310
320
end
311
321
322
+
---@returnWebAudio
312
323
functionWebAudioStatic.getFromID(id)
313
324
returnWebAudios[id]
314
325
end
@@ -372,6 +383,7 @@ local function createWebAudio(_, url, owner, bassobj, id)
372
383
373
384
self.url=url
374
385
self.owner=owner
386
+
self.mode=WebAudio.MODE_3D
375
387
376
388
-- Mutable --
377
389
self.playing=false
@@ -385,7 +397,9 @@ local function createWebAudio(_, url, owner, bassobj, id)
0 commit comments