#On what exactly I dont even know what to
1 messages · Page 1 of 1 (latest)
what about this do you not understand
void Start ()
{
//AudioClip selectedClip = clips [Random.Range (0, clips.Length)];
WWW audioLoader = new WWW ("file://" + musicDir + "//clip.wav");
AudioClip selectedClip = audioLoader.GetAudioClip (false, false, AudioType.WAV);
source.clip = selectedClip;
Debug.Log (source.clip.name);
}
for example, why do we need to import networking?
because you need to use the WWW class and that is in networking
what does WWW do specifically?
if I'd try to google that itd just say world wide web
because music files are very difficult to load from raw bytes
hmmm
this was from the first example on the link I sent you. It uses the WWW class which is now outdated.
you would be better looking at the second example which uses the UnityWebRequest class as that is the current way of doing things.
btw you could also use this to load your image files
The image files are loaded in flawlessly with your system so I will not change that
But yeah I never did anything like this before
So you need to google UnityWebRequest and read it and follow the links in the documentation
This one?
yes, it's very simple really
It looks simple
But for some reason my brain is failing to process how I should add this to my AudioManager
thats what an all nighter does to a man
Firstly I would forget the async stuff in there for now
So try to make the LoadClip method then show me what you have done
I am not going to spoon feed you so dont expect it
And I dont want you to do that
says the man who does not know how to google
dude its not that i dont know how to google
i dont know how to understand code from google
If I was one of those people I'd just instantly paste the first result into my script
But I am trying to actually understand how it works
Thats what learning is about
In that code block
UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.WAV)
is the important bit so that is the documentation you should be reading
Just UnityWebRequest?
Also sorry im not responding too fast, I am just focusing on quickly fixing my UI
and the bit after the =
UnityWebRequestMultimedia.GetAudioClip
doesn't that sound interesting considering you want to read an audio file?
you should not be responding fast, you should be reading what I type and directly going to find the relevant unity documentation
It sounds pretty straight forward, but I'll look into that as well
read the docs, it will show you not only what you want to do now but also what you may want to do in the future
this is where docs are better than tutorials
Should I make a different script for this or should I write it in my AudioManager simply?
normal programs run synchronously, that is line by line
asynchronous methods run as a separate thing, like a coroutine, they do their work without blocking the main synchronous thread. It is a way of getting slow work done (like loading files) without affecting the performance as far as the user is concerned
I see. Thank you
Also, what do I need to import for Task<>
Networking isnt enough
task is part of async, you dont need it
So just async LoadClip()
An audioclip
so what goes in front of LoadClip?
But then what do I need to import?
Simply UnityEngine.Audio?
cant be it
what did you want back again?
An Audio Clip.....
so how do you write that in code?
I have to think about this hold on
I dont even know my imports bruh
this is embarrassing as all hell
it's there for you
async Task<AudioClip> LoadClip(string path)
what is left if you remove async and Task<>
ffs
no read carefully what I wrote
AudioClip LoadClip(string path)
finally
havent even written the WebRequest part yet
show what you have
probably
Alright, so
1 error, 2 warnings after I effectively copied in the code
await can obviously only be used in an async method
and warnings about logging the errors
yes, like yield in a coroutine
Also, does this mean that I'll only be able to check for .WAV files?
so if you look at this
while (!uwr.isDone) await Task.Delay(5);
what needs to be removed ?
the entire thing?
I just dont know how
this is where you go and check the documentation on the isDone bool
await Task.Delay() needs to be removed
I know that it returns true once it finishes communicating with the server
And that we need the program to halt until it finishes
so what should your while do if the request is not finished?
halt the program?
you do not want to halt, you want to just wait
How exactly?
time.DeltaTime?
nah thats dumb
I dont know what method to use in that case
It mat be easier for you to implement the example from here
https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequestMultimedia.GetAudioClip.html
This is using a coroutine
Ah yeah I was about to say
So we just start a coroutine?
also quick question
will this need the user to be connected to the internet?
no
because the url you will use will be file:///
you do know what a url is dont you
and you know you can load a local file into a web browser?
then why the stupid fucking question?
I was just confused about the download part, is all
no need to get angry
its just phrased in a way that I didnt get at first
sorry, but you are being really dense
sadly you're not making it easier on me either when you respond like that
But I understand
I appreciate you helping
if you know wat a url is and you know the file:/// protocol then why ask if an internet connection is required
Because of the Create a UnityWebRequest to download an audio clip via HTTP GET and create an AudioClip based on the retrieved data. part
and ?
It wasnt obvious at first
HTTP get works with file:/// protocol
ive heard way too many methods of doing this using a server domain
I dont wanna get jumbled up in those
And have to pay for a server just to make pong use funny sounds.
So I'm just trying to make sure that everything is solid
you have so much to learn, thank god you are not targeting Android or WebGL
That's... why I'm here, yknow.
To learn
This thing is one of the most niche things that you can do
But I thought itd be a fun project
instead its just becoming this
I have to say you do not make it easy on us when we try to help you
If it's hard for you to handle "stupid questions" then yes, its not easy
trust me, I have very shitty patience too when it comes to things I'm experienced with
Anyway back to the problem at hand
Delete your loadclip method and replace it with the GetAudioClip method from the example
#1015682014273351775 message
this one
Just completely replace it?
The url is gonna be the path so I will just type Path.Combine etc...
yes, replace it, we will come to the path shortly
somethings not right
I dont think that the AudioManager is the right script to write this in
why not?
"clip does not exist in the current context" in AudioClip s.clip = DownloadHandlerAudioClip.GetContent;
wtf did that come from
I have
IEnumerator GetAudioClip()
{
using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip("https://www.my-server.com/audio.ogg", AudioType.OGGVORBIS))
{
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ConnectionError)
{
Debug.Log(www.error);
}
else
{
AudioClip myClip = DownloadHandlerAudioClip.GetContent(www);
}
}
}
from that documentation page
My bad
Thought I have to replace it
Okay soo
Now
I actually have no clue what to do next
so now, are you getting a file name from the user, are you getting an extension as will or are you using a fixed file type
id want any extension
I dont see the reason in limiting it only to one specific type
sowav only, mp3 what?
you need to if you dont get the file type
Fair I suppose
this is the point when you google 'Unity AudioType'
I actually dont know the difference between mp3 and wav and all the types besides compression, but it doesnt matter anyway rn
oh yes it does
Or just use the snippets at VS Community
you need to tell Unity what type of file it is dealing with
Well yes ofc
NO!!!!!!!!!!!!!!!!!
this is why you are not learning, you are always looking for the easy way out
no I'm not??
What
If I was looking for the easy way out I would be done with it already
But I am trying to fucking understand
So I have to worry about this less if I ever have to do it again
Which I probably wont
Did you google Unity AudioType? and look at the doc page
Yes I am doing that rn
There is literally no difference between that and what VS Community is telling me though.
I beg to differ
They say the exact same things in the descriptions for me
I am looking at them one to one
Not a single letter differs
It is the easy way out in the sense that I dont have to wait 10 minutes for chrome to boot up so I can check the exact same thing, thats 100% correct
Or can you please explain the difference
Because the docs give a link you can click through. VS does not do that
How impactful.
A lot of the time that gives additional information and examples (not in this case) but very often
Exactly
Other times I use the documentation obviously
But in this case its literally 3 words
with no explanation
Doesn't matter, what does matter is you need to know the file type you are trying to load
Other times I only use the VS snippets when I'm trying to find something that COULD help
Can I allow it to be able to load more than 1 type of file?
So like MPEG and WAV?
of course, if you program it that way
i just dont know how to honestly
lets just stick to MPEG for now, you can always expand this later
i was thinking of saying it like AudioType.MPEG || AudioType.WAV
its a bool, so yknow
i think that makes sense
where do you get the idea its a bool?
Oh hold on
I was looking at stream
Whoops.
That was a different docs site
well anyhow
im gonna have to call it here
Look dude
Thank you so much for the help
But if I really do trigger you with "stupid questions", please dont stress yourself about it
While I do appreciate someone helping
I also dont want you to waste more energy on me than you expect
I have been doing this for 45 years, I think I can handle the stress
I am quite sure we've met before
Like a year ago or so
I was even more stupid back then
Trying to bruteforce a game
By copying every single docs site ive seen
Also, obviously you can, but are you handling it the way you should?
Stress is my middle name, where to do think the SSS comes from
There are multiple ways of handling it, some better, some worse, some easier, some harder
Hell if I know. At one point I resorted to masochism
Heh.
Yeah, just keep your guard up
Anyway, do what you need to do and ping me tomorrow then we can continue the master class
I know that my shitty personality can fuck with people's expectations
I dont think there is anything wrong with your personality, but you do seem to have serious learning problems
Well, that's just beating around the bush
I can go from understanding 4D objects to not knowing how to rotate a rectangle in 2D
I learn things which I think I will need
Instead of trying to be streamlined
I just jump to whatever seems to be the most important
Of course, that can lead to me missing 1 or 2 less advanced stuff
but thats me
Anyhow, thanks for the help again
Sorry for the trouble
I didnt get to test to see if it works
But tommorow I'll try to code it in
it wont work, it is far from ready to work
and a file type
And things like that yep
you can
Main thing is
I have 5 sound effects
That need to be customizable
And they are stored inside an array
Instead of being hard coded
say I have a file
mysound.mp3
and I rename it
mysound.steve
is it still an mp3?
So tommorow I'll just look into thag
nope.
yes it is
I mean
You can convert the extension back
But with the wrong extension it wont do anything
The info inside doesnt change
Only the way the system interprets it
Correct?
of course it can.
I think you need a course on Windows file management as well
._.
cant blame me for having my teachers teach me a c++ c# sql html python hybrid shit instead of actual code also
and actual logic
sure its a pseudocode
but it doesnt help matters
Out of 26 people I was the only person in my class who knew how to write actual code that can be compiled
Pretty sad, seeing that im majoring in maths and informatics
but what can ya do
I don't care about being called stupid as long as I can help people become smart
That is a very sad state for your education system t0 be in
Yep. The teacher was literally critisizing me because I wrote correct syntax due to muscle memory
Like using == instead of = in an if statement
Jeez this was a long thread for loading up an audio file 
Because its a comparation and not a declaration
Aw yep
What specifically were you trying to do again?
you want to take over, feel free
I do not I just was surprised to see this thread active still
Make it so the player can upload their own audio file for the game to use as sound effect
we are having some conceptual problems
Ohhh right
I can see why that would require "networking" in that you need to use a certain class for file management
even though, in this case it is not 'networking'
Yeah I didnt understand why it required networking when converting an image file to a sprite didnt
I like to know the specifics
I get told that im a fucking moron a lot for it
But I like to know all parts of everything
Audio is weird, unlike a picture that can just be an array of rgb values, audio files are all weird frequencies that go back and forth with multiple channels, it can get wacky!
you are neither a 'moron' nor 'stupid', you do seem to have a problem grasping concepts which is a completely different problem
Yeah that's what I mean by putting networking in quotes, you just need to use some of the stuff in that class in order to work with audio stuff
exactly
A teacher of mine told me that I am a very incompetent child just because I asked where the quadratic formula came from
Like how it was made
Made me have to learn the entire thing
Cried that day
What the heck? Sounds like a bad teacher! Whatta bully
Tell me about it, I was told I was a complete waste of space until the day I graduated summa cum laude
Thank fuck I never have to see that dude gaain
Made my passion for math weaken so bad
I was considering if I should even try majoring in maths and informatics
Now I have a better teacher
If I miss a lecture for some reason she literally just allows me to have a personal class with her after class hours are over
And just explain the things
So at least things are better now
(besides the fact that the entire school is in a different language than my native, so I have to learn it if I want to understand)
Anyhow
Gotta go
See y'all later!
And thanks again