Vurv78 / WebAudio

A safe, efficient and powerful replacement for Streamcore that adds playing & manipulating URL streams through IGmodAudioChannel/BASS
https://steamcommunity.com/sharedfiles/filedetails/?id=2466875474
MIT License
18 stars 3 forks source link

WebAudio:getFFT() errors - "table index is nil" #30

Closed ghost closed 2 years ago

ghost commented 3 years ago

Upon testing the WebAudio:getFFT() function, it simply errors out with the following:

sv: Expression 2 (ChatURL Radio - Version A3a Alpha | 27.04.21): entities/gmod_wire_expression2/core/array.lua:100: table index is nil

The code I am using is FFTArray = WebAudio:getFFT(), which causes the E2 to halt and error with the above. Not sure if this is an error within the addon or Wiremod itself, though.

Vurv78 commented 3 years ago

This only happened to me when the webaudio / the expression2 core was reloaded incorrectly, reload the autorun/webaudio.lua file

ghost commented 3 years ago

This only happened to me when the webaudio / the expression2 core was reloaded incorrectly, reload the autorun/webaudio.lua file

This error occurs every time I start up a singleplayer game, load a map and try to use the function. Reloading the script does not help, the E2 still errors with the same message.

Vurv78 commented 3 years ago

Works for me on singleplayer using the latest workshop build, try workshop or make sure the repo is the latest version

ghost commented 3 years ago

Works for me on singleplayer using the latest workshop build, try workshop or make sure the repo is the latest version

I have tried both the Workshop and Github versions, and both produce exactly the same error. My Wiremod version is up to date. Windows client. Both the x86-64 beta and regular build of Garry's Mod exhibit the same issue, and no addons are conflicting (I loaded just Wiremod and WebAudio, and the same issue cropped up), so it shouldn't just be my end.

Vurv78 commented 3 years ago

Found the issue, I forgot to put a check if the stream was valid inside of GetFFT. Should be fixed for null streams, try it out

ghost commented 3 years ago

Found the issue, I forgot to put a check if the stream was valid inside of GetFFT. Should be fixed for null streams, try it out

That fixed it, however I don't understand why the particular files I use with the code never seem to be able to retrieve the FFT data from the stream.

Vurv78 commented 3 years ago

Were the streams functioning in every other aspect besides fft? Because I'm pretty sure this was just from an invalid stream.

If you check your console, webaudio should tell you if it errored from an invalid id, unwhitelisted URL for yourself or if the stream is block streamed or not able to support 3d.

I recently made it also network to the server to make the object invalid if this is the case in the same commit to fix it.

Vurv78 commented 3 years ago

For example the ytdl api I recently whitelisted doesn't support 3d streams AND is block streamed so webaudio wouldn't be able to support it in its current state since we want to allow for setTime, setLooping & setPos, setDirection etc..

ghost commented 3 years ago

Were the streams functioning in every other aspect besides fft? Because I'm pretty sure this was just from an invalid stream.

Yes, everything else works just fine. I can play, pause, change the speed, volume, etc. with no issues.

If you check your console, webaudio should tell you if it errored from an invalid id, unwhitelisted URL for yourself or if the stream is block streamed or not able to support 3D

No errors appear in the console when initiating the stream, and everything else seems to work just fine.

I do use a Youtube to MP3 converter (Gaerisson's), however it downloads the full song requested and offers up a plain MP3 file to be streamed, so should be no different from a regular MP3 file.

Gaerisson commented 3 years ago

Hello, I own the YTDL API, I answer directly here, @RanchTheDeer is right, the MP3 file is pretty basic, no specific audio codec, so it should work with FFT normally.

Format: MP2/3 (MPEG audio layer 2/3)

Mime Type: audio/mpeg Mpeg Audio Version: 1 Sample Rate: 48000 Channel Mode: Stereo

(Quality 3 of Youtube-DL)

image

If I can help you, don't hesitate :)

Vurv78 commented 3 years ago

I tested it with static files here http://ytmp3.gaerisson-softs.fr/[dQw4w9WgXcQ]_Rick_Astley_-_Never_Gonna_Give_You_Up_Official_Music_Video.mp3 and everything was fine assuming the api serves these

Also it shouldn't be possible to get an error from getFFT anymore. If there's no error in your console and everything else works not sure what to say..

Gaerisson commented 3 years ago

Yes, there is also an autoclear system on my API to not to exceed the disk space, it is every 1st of the month but according to the error it happened on 27.04. Also, I had a problem a few weeks ago with my dedicated server, there was some downtime so maybe it was during this period and the file was suddenly no longer accessible.

Vurv78 commented 2 years ago

Closing as wasn't able to reproduce, let me know if this should be re-opened