Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by eviltenchi_84 · Sep 18, 2012 at 08:45 PM · c#iosaudiowww

Speed of WWW

I was using something like this to load a dynamically created audio file on ios.

 WWW AudioToLoadPath = new WWW("file://" + Application.persistentDataPath+"/audio.wav");
 Camera.main.audio.clip = AudioToLoadPath.audioClip;
 Camera.main.audio.Play();

However, there seems to be a noticeable delay from the time that the audio file is created to the time when it is played. The audio file is created very quickly so I know that is not the problem. I think the issue must be with WWW. Is WWW very slow and if so, is there a faster way to load the file?

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Sep 18, 2012 at 08:48 PM 0
Share

Is the audio file set to decompress or play in a streamed fashion?

avatar image eviltenchi_84 · Sep 18, 2012 at 08:55 PM 0
Share

Do you mean the setting Load Type is on or something else?

avatar image whydoidoit · Sep 18, 2012 at 08:58 PM 0
Share

Yeah that is what I was thinking - but on reflection that probably isn't possible on just a file being loaded by WWW. Not sure but was thinking that this might have a delay while it was prepared.

avatar image eviltenchi_84 · Sep 19, 2012 at 01:52 PM 0
Share

I could see if I can change the file's import settings to see if WWW loads faster. Not sure if it makes a difference though.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Dreamora · Sep 18, 2012 at 09:52 PM

You can alter the thread priority of the WWW object.

But likely the only way to approach your problem is a pro license and asset bundles so you can control compression settings and when / how its meant to be decompressed etc

Comment
Add comment · Show 9 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image eviltenchi_84 · Sep 19, 2012 at 01:49 PM 0
Share

I have a pro license but I thought asset bundles have to be created beforehand in order to work (correct me if I am wrong). I have only one audio file being created and loaded but the information in the file is being changed via script so the audio file is overwritten whenever a change occurs (it changes a lot). Therefore, I would run my above code whenever a change occurs. Creating the file is a really quick process but there is considerable lag when I try to look for the new file on the device and play it.

avatar image Dreamora · Sep 19, 2012 at 01:54 PM 0
Share

That is correct, it needs to be editor generated. But you could host a headless editor that generates it for you.

though if it changes a lot you will basically not be able to avoid the hit from using it directly but you can 'overcome' it by loading the audio already beforehand and store the audioclip in a global manager to use it once its required (and after its loaded) as the problem is the www.audio access at which point the byte data is converted into actual audio data and prepared for usage

avatar image eviltenchi_84 · Sep 19, 2012 at 02:02 PM 0
Share

While the audio does exist on the device, it $$anonymous$$UST be reloaded by WWW every time a change occurs which is extremely often. Unless I am misunderstanding you, there is no way to load it beforehand because it is almost always changing and reloading (Audio is created via c# script and its contents change based on settings changed in unity). Unless what you meant is make an audio file beforehand and copy the data from my audio file to the one already created?

avatar image Dreamora · Sep 19, 2012 at 02:32 PM 0
Share

Doing the WWW call and assigning www.audio to a audioclip reference and after that send out notifications 'on it being updated' is 'loading it beforehand' actually and would be the way to go if you do want unity to handle it for you, loading it from a web location, ...

You naturally also can use SetData on the AudioClip class ( http://docs.unity3d.com/Documentation/ScriptReference/AudioClip.html ) but to what degree thats gonna make you happy or even do what you want is a thing you will have to find out.

avatar image eviltenchi_84 · Sep 19, 2012 at 03:35 PM 0
Share

I tried something like that before but it ended with the same noticeable lag on the iphone. I should also note that the audio is only about 1-2 milliseconds long and the creation and playing of the audio happens in a coroutine.

WWW AudioToLoadPath = new WWW("file://" + Application.persistentDataPath+"/audio.wav"); yield return AudioToLoadPath; AudioClip TestClip = AudioToLoadPath.GetAudioClip(false); Camera.main.audio.clip = TestClip; Camera.main.audio.Play();

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Read audio/music currently playing on speakers? 0 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Audio: how do I immediately play a new audioclip without delay(code included)? 2 Answers

UnityWebRequest hangs on isDone but not always 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges