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 BazLevelUp · Sep 28, 2012 at 01:55 PM · soundaudioclipwav0

AudioClip.GetData returns only 0s

Hi everyone!

I'm trying to do a GetData() on a AudioClip but it only returns me 0s :( To be clear, my float tab is populated only by 0

I'm using a WAV file that said to be in Inspector : 16 Bits, 44100 Hz, Stereo, 02:57.803, 29.9 MB (WAV)

 public AudioClip clip ;
 
 void Start()
 {
     myData = new float[clip.samples * clip.channels] ;
     clip.GetData(myData, 0) ;
     for (int i = 0 ; i < myData.Length ; ++i)
     {
         Debug.Log(i+"  -> "+myData[i].ToString()) ;    
     }    
 }



Can you please help me ?

Comment
Add comment · Show 3
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 Khalos · Oct 17, 2012 at 05:56 PM 0
Share

Did you ever solve this problem? I'm having the same issue. I've found several people having the same issue but never a solution.

avatar image gregzo · Oct 17, 2012 at 06:52 PM 0
Share

If said audioclip is retrieved using WWW.GetAudioClip, there's nothing to do: the bug has been around since 3.5 beta, and apparently s solved in 4.0 (see my Audio Bugs thread in the forums).

If it is just a wav you imported in your project, then you are buggy, not Unity. Or you discovered a new, unknown to me, species of audio bug : would be a nice addition to my thread, post details.

Let me know,

Gregzo

http://forum.unity3d.com/threads/147834-A-list-of-audio-bugs-(iOS-mostly)

avatar image BazLevelUp · Oct 18, 2012 at 07:37 AM 0
Share

gregzo is right, if you use WWW.GetAudioClip, there is no solution except buying Unity 4. For the normal file, the first one was returning me only 0s. I changed file to test and with another .wav it did worked! ;)

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by gregzo · Sep 28, 2012 at 05:50 PM

Hi baz,

Your code should work. Check your clip's import settings. If it's a 3d clip, no need for it to be stereo. Load type should be load into memory.

Also, check your data's length (Debug myData.length). Then, to check all these floats and make sure they are not all null, don't debug all of them! That's 44100*2*177 Debug.Log calls, ouch! Instead, use a bool allFloatsAreZero variable in the loop, will prevent crashes.

Let me know!

Gregzo

Comment
Add comment · 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
0

Answer by ceo1207 · May 09, 2016 at 05:01 PM

maybe,it is because that the file you import into clip is compressed file. you can try some file of wav format,you can GetDate easily,but if you import mp3 or some else compressed file,you can not get the value of samples through GetData.

Comment
Add comment · 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
0

Answer by SharkmanSam · May 30, 2016 at 05:22 AM

Im also having problems with GetData... It works fine in the editor on PC... Wont work in the build...

I see 5.4 beta seems to address GetData not working in START() but ive tested on other threads and no luck. Using oGG

Comment
Add comment · 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

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

13 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 avatar image avatar image

Related Questions

Is there a way to create a random Audiosource loop? 2 Answers

"Cannot get/set data from streamed sample" from audioclip 1 Answer

Is OnAudioFilterRead Still the Preferred Method for Procedural Audio? 0 Answers

Synch clips with BPM 2 Answers

how to make multiple sound augmented reality in 1 scene UNITY? 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