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 Lockstep · Sep 14, 2012 at 12:10 AM · audiocrashdebugfreeze

Editor freezes while playing audio loop.

Hi there. Recenty my unity editor started crashing. It freezes kompletely and I need to use the task manager to terminate it. It happens during testing my scene at random points and more frequent when I quit testing. I dug up the log in AppData\Local\Unity\Editor but nothing related to the crash appears there.

The problem occured first after I added background audio loops and never appeared when the corresponding gameobject was deactivated (so far). The audio loops are in the it format and the preview shows: 32bit, 48000Hz, stereo, unlimited, 167,7 kb (it). The script which manages the audio clips works as intended (see below).

I have no idea what causes those crashes. Any help is appreciated.

BackgroundMusic.js :

 var clips : AudioClip[];
 private var _audio : AudioSource;
 
 function Start () {
     _audio = GetComponent(AudioSource);
     if(clips.Length == 0) Debug.Log("No AudioClip assigned!");
     _audio.loop = true;
     PickRandom();
     _audio.Play();
 }
 
 function Update () {
     if(Input.GetKeyDown(KeyCode.M)){
         _audio.mute = !_audio.mute;
     }
     if(Input.GetKeyDown(KeyCode.N)){
         PickNext();
     }
 }
 
 function PickRandom() : void {
     var rand : int = Random.Range(0, clips.length);
     _audio.clip = clips[rand];
     Debug.Log("currently playing " + _audio.clip.name);
     _audio.Play();
 }
 function GetIndex() : int {
     for(var j : int = 0; j < clips.length ; j++){
         if(_audio.clip.name == clips[j].name){
             return j + 1 ;
         }
     }
     Debug.Log("BackgroundMusic: GetIndex() failed. return 0");
     return 0;
 }
 function PickNext() : void {
     var index = GetIndex();
     if(index == clips.Length) index = 0;
     _audio.clip = clips[index];
     Debug.Log("currently playing " + _audio.clip.name);
     _audio.Play();
 }
 
 @script RequireComponent(AudioSource)
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 Lockstep · Sep 19, 2012 at 08:13 AM 0
Share

I've been experimenting with this issue a bit and seems like unity does not like the it format, even though the docs state it is supported. I converted a track to .wav and used the builtin compression format Ogg Vorbis. Afterwards the crash did not occur anylonger (until now).

avatar image code-blep · Sep 19, 2012 at 12:25 PM 1
Share

Hey Lockstep,

I have had Unity crash out before when dealing with some of the higher bit / freq files. I generally convert them to 44.1khz 16bit Stereo when importing WAVS. Besides, the extra 'sound quality' on files that are 48khz or 96khz, and the extra work Unity has to do just isn't worth it in my opinion, especially when they get converted to OGG. Also when converting 48khz/96khz files to OGG, you can find that sometimes the audio gets 'distorted' and cause all sorts of headaches. Sorry I don't have an answer as such, but hopefully it may give further insight leading to one.

Paul

avatar image Lockstep · Sep 19, 2012 at 12:49 PM 1
Share

Thank you for your comment. It was bretty much what i was hoping for. Expecting a 100% explanation for such a vague problem would kinda illusive.

The wav i have tested crash free was 16bit 8khz which fits your statement. I'll have a closer eye on the sample rate when konverting/importing audio from now.

avatar image code-blep · Sep 24, 2012 at 12:07 PM 0
Share

Upvoted comment as you made sure the question was updated and marked as answered ;)

1 Reply

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

Answer by code-blep · Sep 23, 2012 at 09:53 PM

Hey Lockstep,

I have had Unity crash out before when dealing with some of the higher bit / freq files. I generally convert them to 44.1khz 16bit Stereo when importing WAVS. Besides, the extra 'sound quality' on files that are 48khz or 96khz, and the extra work Unity has to do just isn't worth it in my opinion, especially when they get converted to OGG. Also when converting 48khz/96khz files to OGG, you can find that sometimes the audio gets 'distorted' and cause all sorts of headaches. Sorry I don't have an answer as such, but hopefully it may give further insight leading to one.

Paul

Comment
Add comment · Show 1 · 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 code-blep · Sep 23, 2012 at 09:54 PM 0
Share

Sorry I should have posted it as an answer. $$anonymous$$y bad Lockstep! ;)

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

10 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

Related Questions

How can I find editor log file? 5 Answers

Unity build freezing after same number of Debug.Logs 0 Answers

Xbox UWP Game Crashing Upon Loading 0 Answers

Filing and debuging web plugin crashes 1 Answer

Unity crashing when I hit the Play button. 0 Answers


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