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
This is an addon for garrysmod that adds a serverside [b]WebAudio[/b] class which can be used to interact with clientside [b]IGmodAudioChannels[/b] asynchronously.
This addon adds a serverside [b]WebAudio[/b] class which can be used to interact with clientside [b]IGmodAudioChannels[/b] asynchronously.
3
4
It also adds an extension for Expression2 to interact with these in a safe manner.
4
-
This is essentially a safe and more robust replacement for the popular Streamcore addon, since it is much more secure and customisable.
5
5
6
+
[i]This is essentially a safe and more robust replacement for the popular Streamcore addon, since it is [b]much[/b] more secure and customizable.[/i]
7
+
8
+
[h2]Why use this instead of Streamcore?[/h2]
9
+
[h3]Streamcore is a dangerous addon.[/h3]
10
+
It has no whitelist, meaning [b] anyone can force everyone on the server to download ILLEGAL CONTENT or grab everyone's IP Addresses through links like grabify.[/b]
11
+
Server owners aren't safe either, streamcore easily allows you to crash everyone on it through spamming net messages.
12
+
13
+
[b][i]In fact, this addon was made out of frustration over how low effort / terrible streamcore is and how the author does not care about the security of people's games whatsoever after years of reports over these vulnerabilities.[/i][/b]
14
+
15
+
[i]WebAudio easily solves this through a whitelist, active development and flexible but strong limits.[/i]
16
+
17
+
[h3] WebAudio has much more features. [/h3]
18
+
Have you ever wanted to pause a stream while it was playing?
19
+
Maybe turn up the volume higher because it was too quiet?
20
+
Maybe even getting the current playback time or FFT values of the stream?
21
+
[url=https://github.com/Vurv78/WebAudio/wiki/Features]You can easily do all of this + much more with WebAudio.[/url]
6
22
7
23
[h2]Features[/h2]
8
24
[list]
9
25
[*] Client and Serverside URL whitelists, both are customizable with simple patterns or more advanced lua patterns.
10
26
[*] The [b]WebAudio[/b] type in Expression 2 that adds the ability to change sounds in a 3D space, or change it's volume, position and time whilst the music is playing.
11
27
[*] Easy to use Lua api that tries to mirror the [b]IGModAudioChannel[/b] type.[/list]
28
+
[*] Find the rest here https://github.com/Vurv78/WebAudio/wiki/Features
29
+
[/list]
30
+
31
+
[h2]I want to contribute![/h2]
32
+
Then use the Github page! [url=https://github.com/Vurv78/WebAudio]https://github.com/Vurv78/WebAudio[/url]
33
+
Pull request anything you like, just make sure to see [b]CONTRIBUTING.md[/b]
12
34
13
-
[h2]Console Variables[/h2]
14
-
This is a list of console variables that you can change to configure the addon to your liking.
35
+
[h2]I've found a bug![/h2]
36
+
You can report bugs by either posting a report on the [url=https://github.com/Vurv78/WebAudio]Github page[/url], or by starting a new conversation on this page.
37
+
Make sure to be [u]detailed and concise[/u] in your bug reports, so that they can be serviced easier!
15
38
39
+
[h2]ConVars[/h2]
40
+
This is a list of [b]ConVars[/b] that you can change to configure the addon to your liking.
16
41
[table]
17
42
[tr]
18
-
[th]ConVar Name[/th]
19
-
[th]Description[/th]
20
43
[th]Realm[/th]
44
+
[th]Name[/th]
45
+
[th]Default Value[/th]
46
+
[th]Description[/th]
21
47
[/tr]
22
48
[tr]
49
+
[td]SHARED[/td]
23
50
[td]wa_enable[/td]
51
+
[td]1[/td]
24
52
[td]Shared convar that allows you to disable WebAudio for the server or yourself depending on whether it is executed in the client or server console[/td]
25
-
[td]SHARED[/td]
26
53
[/tr]
27
54
[tr]
55
+
[td]SERVER[/td]
28
56
[td]wa_admin_only[/td]
57
+
[td]0[/td]
29
58
[td]Allows you to set WebAudio E2 access to only Admins or Only Super Admins. (0 for Everyone, 1 for Admins, 2 for Super Admins).[/td]
30
-
[td]SERVER[/td]
31
59
[/tr]
32
60
[tr]
61
+
[td]SHARED[/td]
33
62
[td]wa_volume_max[/td]
63
+
[td]300[/td]
34
64
[td]
35
65
Shared convar that allows you to set the maximum volume a WebAudio stream can play at.
36
66
100 is 100%, 50 is 50% and so on.
37
67
Helps to prevent nasty earrape music being played too loudly
38
68
[/td]
39
-
[td]SHARED[/td]
40
69
[/tr]
41
70
[tr]
71
+
[td]SERVER[/td]
42
72
[td]wa_stream_max[/td]
73
+
[td]5[/td]
43
74
[td]Serverside convar that allows you to set the max amount of streams a player can have at once[/td]
44
-
[td]SERVER[/td]
45
75
[/tr]
46
76
[tr]
77
+
[td]SHARED[/td]
47
78
[td]wa_radius_max[/td]
79
+
[td]10000[/td]
48
80
[td]Allows you to set the maximum distance a stream can be heard from. Works on your client.[/td]
81
+
[/tr]
82
+
[tr]
49
83
[td]SHARED[/td]
84
+
[td]wa_fft_enable[/td]
85
+
[td]1[/td]
86
+
[td]Whether FFT data is enabled for the server / your client. You shouldn't need to disable it as it is very lightweight[/td]
87
+
[/tr]
88
+
[tr]
89
+
[td]CLIENT[/td]
90
+
[td]wa_verbosity[/td]
91
+
[td]1[/td]
92
+
[td]Verbosity of console notifications. 2 => URL/Logging + Extra Info, 1 => Only warnings/errors, 0 => Nothing (Avoid this)[/td]
50
93
[/tr]
51
94
[/table]
52
95
@@ -55,198 +98,31 @@ This is a list of Concommands to use with this addon as a server owner and a use
55
98
56
99
[table]
57
100
[tr]
58
-
[th]ConCommand Name[/th]
59
-
[th]Description[/th]
60
101
[th]Realm[/th]
102
+
[th]Name[/th]
103
+
[th]Description[/th]
61
104
[/tr]
62
105
[tr]
106
+
[td]CLIENT[/td]
63
107
[td]wa_purge[/td]
64
108
[td]Purges all currently running streams and makes sure you don't get any useless net messages from them.[/td]
65
-
[td]CLIENT[/td]
66
109
[/tr]
67
110
[tr]
111
+
[td]SHARED[/td]
68
112
[td]wa_reload_whitelist[/td]
69
113
[td]Reloads your whitelist at data/webaudio_whitelist.txt[/td]
70
-
[td]SHARED[/td]
71
-
[/tr]
72
-
[/table]
73
-
74
-
[h2]E2 Functions[/h2]
75
-
76
-
[table]
77
-
[tr]
78
-
[th]Function name[/th]
79
-
[th]Description[/th]
80
-
[/tr]
81
-
[tr]
82
-
[td]webaudio webAudio(string url)[/td]
83
-
[td]Returns a WebAudio object of that URL as long as it is whitelisted by the server. Has a 150 ms cooldown between calls to prevent spam.[/td]
84
-
[/tr]
85
-
[tr]
86
-
[td]number webAudiosLeft()[/td]
87
-
[td]Returns how many WebAudios you can create.[/td]
88
-
[/tr]
89
-
[tr]
90
-
[td]number webAudioCanCreate()[/td]
91
-
[td]Returns whether you can call the webAudio function without getting an error from the cooldown.[/td]
92
-
[/tr]
93
-
[tr]
94
-
[td]number webAudioCanCreate(string url)[/td]
95
-
[td]Overload of webAudioCanCreate(), that also checks if the url is whitelisted so you don't error on webAudio(s) calls[/td]
96
-
[/tr]
97
-
[tr]
98
-
[td]number webAudioEnabled()[/td]
99
-
[td]Returns whether webAudio is enabled for use on the server.[/td]
100
-
[/tr]
101
-
[tr]
102
-
[td]number webAudioAdminOnly()[/td]
103
-
[td]
104
-
Returns 0 if webAudio is available to everyone, 1 if only admins, 2 if only Super Admins.
105
-
Basically replicates the value of the wa_admin_only convar
106
-
[/td]
107
-
[/tr]
108
-
[/table]
109
-
110
-
111
-
[h1]WebAudio Type Methods[/h1]
112
-
113
-
[table]
114
-
[tr]
115
-
[th]Type name[/th]
116
-
[th]Description[/th]
117
-
[th]Updates the Object[/th]
118
-
[/tr]
119
-
[tr]
120
-
[td]void webaudio:setDirection(vector dir)[/td]
121
-
[td] Sets the direction in which the WebAudio stream is playing towards. [/td]
122
-
[td] ❌ [/td]
123
-
[/tr]
124
-
[tr]
125
-
[td]void webaudio:setPos(vector pos)[/td]
126
-
[td]
127
-
Sets the 3D Position of the WebAudio stream without updating it.
128
-
[/td]
129
-
[td] ❌ [/td]
130
-
[/tr]
131
-
[tr]
132
-
[td]void webaudio:setVolume(number volume)[/td]
133
-
[td]
134
-
Sets the volume of the WebAudio stream, in percent format. 200 is 2x as loud as normal, 100 is default. Will error if it is past wa_volume_max.
135
-
[/td]
136
-
[td] ❌ [/td]
137
-
[/tr]
138
-
[tr]
139
-
[td]void webaudio:setTime(number time)[/td]
140
-
[td]
141
-
Sets the time in which the WebAudio stream should seek to in playing the URL.
Sets the playback speed of a webaudio stream. 2 is twice as fast, 0.5 being half, etc.
149
-
[/td]
150
-
[td] ❌ [/td]
151
-
[/tr]
152
-
[tr]
153
-
[td]number webaudio:pause()[/td]
154
-
[td]
155
-
Pauses the stream where it is currently playing.
156
-
Returns 1 or 0 if could successfully do so, because of quota.
157
-
[/td]
158
-
[td] ✅ [/td]
159
-
[/tr]
160
-
[tr]
161
-
[td]number webaudio:play()[/td]
162
-
[td]
163
-
Starts the stream or continues where it left off after pausing.
164
-
Returns 1 or 0 if could successfully do so, because of quota.
165
-
[/td]
166
-
[td] ✅ [/td]
167
-
[/tr]
168
-
[tr]
169
-
[td]void webaudio:destroy()[/td]
170
-
[td]
171
-
Destroys the WebAudio object, rendering it useless. It will silently fail when trying to use it from here on!
172
-
This gives you another slot to make a WebAudio object. Use isValid to see if an object isn't destroyed
173
-
[/td]
174
-
[td] ✅ [/td]
175
-
[/tr]
176
-
[tr]
177
-
[td]number webaudio:update()[/td]
178
-
[td]
179
-
Sends all of the information of the object given by functions like setPos and setTime to the client.
180
-
You need to call this after running functions without running :play() or :pause() on them since those do update the object.
181
-
Returns 1 if could update, 0 if hit transmission quota
182
-
[/td]
183
-
[td] ✅ [/td]
184
114
[/tr]
185
115
[tr]
186
-
[td]number webaudio:isValid()[/td]
187
-
[td]Returns 1 or 0 for whether the webaudio object is valid and not destroyed[/td]
188
-
[td] N/A [/td]
189
-
[/tr]
190
-
[tr]
191
-
[td]void webaudio:setParent(entity e)[/td]
192
-
[td]
193
-
[b]e[/b] is optional, If left blank, unparents the stream.
194
-
195
-
Parents the stream position to e, local to the entity.
196
-
If you've never set the position before, will be parented to the center of the prop.
197
-
Returns 1 if successfully parented or 0 if prop wasn't valid.
198
-
199
-
[/td]
200
-
[td] ❌ [/td]
201
-
[/tr]
202
-
[tr]
203
-
[td]void webaudio:parentTo(entity e)[/td]
204
-
[td]
205
-
[b]Alias[/b] of webaudio:setParent(entity e)
206
-
[/td]
207
-
[td] ❌ [/td]
208
-
[/tr]
209
-
[tr]
210
-
[td]void webaudio:unparent()[/td]
211
-
[td]
212
-
[b]Alias[/b] of webaudio:setParent() when the entity field is left blank.
213
-
[/td]
214
-
[td] ❌ [/td]
215
-
[/tr]
216
-
[tr]
217
-
[td]void webaudio:setRadius(number radius)[/td]
218
-
[td]
219
-
Sets the radius in which to the stream will be heard in.
220
-
Default is 200 and (default) max is 1500.
221
-
222
-
This isn't perfect, people can still play somewhat loud sounds and go past the radius!
223
-
If this is the case, use the convar [b]wa_radius_max[/b] to change it for your client.
224
-
[/td]
225
-
[td] ❌ [/td]
116
+
[td]SHARED[/td]
117
+
[td]wa_list[/td]
118
+
[td]Prints a list of currently playing WebAudio streams (As long as their owner IsValid) with their url, id & owner[/td]
226
119
[/tr]
227
120
[tr]
228
-
[td]void webaudio:setLooping(number looping)[/td]
229
-
[td]
230
-
If looping is not 0, sets the stream to loop. Else stops it from looping.
231
-
[/td]
232
-
[td] ❌ [/td]
121
+
[td]SHARED[/td]
122
+
[td]wa_help[/td]
123
+
[td]Prints the link to the github to your console[/td]
233
124
[/tr]
234
125
[/table]
235
126
236
-
237
-
[h1]Questions you may ask:[/h1]
238
-
239
-
[h2]Why use this instead of Streamcore?[/h2]
240
-
If you do not know already, [b]Streamcore is a dangerous addon[/b] in several ways. If someone makes an E2 code with a malicious URL in it, such as an illegal file, then [b]that file will be downloaded [u]to your PC[/u][/b], and there is [b]no way[/b] of stopping it on Streamcore enabled servers.
241
-
Also, due to the nature of the code, the addon can crash servers very easily.
242
-
243
-
WebAudio aims to easily solve these issues by having [b]efficient and safe code[/b] as well as having a customizable whitelist (alongside a standard default whitelist that is flexible and won't allow many common nasties to happen). It also contains features that Streamcore doesn't, such as the ability to play from certain points in a stream, and allows for far more flexibility than StreamCore does. It's also being actively developed, so should play better with newer Garry's Mod versions in future.
244
-
245
-
[h2]I want to contribute to the addon![/h2]
246
-
Then use the Github page! [url=https://github.com/Vurv78/WebAudio]https://github.com/Vurv78/WebAudio[/url]
247
-
Pull request anything you like, just make sure you're ready to change things so that the code will remain efficient and in a similar style to the rest of the codebase.
248
-
You will also need to make sure you fix all linting errors.
249
-
250
-
[h2]I've found a bug![/h2]
251
-
That's alright! This addon is in its early days, and as such bugs are going to be a fact of life.
252
-
You can report bugs by either posting a report on the [url=https://github.com/Vurv78/WebAudio]Github page[/url], or starting a new conversation on this page. Make sure to be [u]detailed and concise[/u] in your bug reports, so that they can be serviced easier!
127
+
[h2]Function Docs[/h2]
128
+
Function documentation has moved to only be on [url=https://github.com/Vurv78/WebAudio]Github[/url].
0 commit comments