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 dhendrix · Jan 04, 2012 at 05:14 PM · audioaudio sourceunity3.5

Audiosurf style audio analysis (unity 3.5)

I want to be able to analyze music before actually playing it similarly to what the game Audiosurf does. This is necessary in order to build levels and such based on the music data. To my knowledge this makes AudioScource.GetOutputData() and AudioSource.GetSpectrumData() useless as it provides up to 1024 audio samples as the music is playing.

Now, it seems as of Unity3.5(correct me if I'm wrong), we have AudioClip.GetData() which gives 44100(or whatever the sample rate is) samples per second; the entire song's sample data. Now to my understanding these samples provided by GetData() coincide with the ones provided by GetOutputData(), as in they are the songs amplitudes.

But it seems like GetSpectrumData() does not have a sister function to provide the entire song's samples (which in GetSpectrumData's case appear to be the frequencies?). Won't I need the frequencies for Fast Fourier Transform analysis (which I believe Audiosurf does)?

I realize I'm a bit in over my head here but I know I'm not the only one looking for this info in Unity and any information that could be provided here would be most appreciated.

Comment
Add comment · Show 1
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 BazLevelUp · Oct 25, 2012 at 12:59 PM 0
Share

I'm currently trying to achieve the same, could you please tell me if you have succeeded in calling AudioClip.GetData() on the clip you retrieve from WWW? I can't get it working :( The call is successfull but the float[] returned is filled only with 0 :(

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by luizgpa · Jan 04, 2012 at 06:19 PM

I don't have Unity 3.5, but if there's a way to get all the samples from an audio clip, you could use some FFT implementation to transform the data to frequency domain and analyze it.

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
1

Answer by jkeogh1413 · Mar 05, 2018 at 10:58 PM

I'm late to the game here, but I had the exact same question about a month ago. It took a lot of searching around and a lot of testing, but I landed on a pretty solid solution.

Using GetData, I retrieved the interleaved stereo samples of a clip and then averaged each pair of stereo samples together to get something similar to GetOutputData's Channel 0.

For the FFT it took some minor conversion but I used DSPLib (https://www.codeproject.com/Articles/1107480/DSPLib-FFT-DFT-Fourier-Transform-Library-for-NET).

I explain in detail in this blog series: https://medium.com/giant-scam/algorithmic-beat-mapping-in-unity-intro-d4c2c25d2f27

After you get the initial context, you're probably most interested in the "Preprocessed Audio Analysis" post. I also include a link in the Outro to a public Github repo with the working source.

Hope this helps you (6 years later) and anyone else that stumbles upon this post looking for a way to do preprocessed audio analysis in Unity!

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 d_vizigin · Jun 07, 2014 at 09:45 AM

Hi, Maybe this plugin can help: http://u3d.as/content/live-typing/3d-audio-road-generator

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

8 People are following this question.

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

Related Questions

Does the number of simultaneous playing audio sources matter? 0 Answers

How to make Audio Source broadcast audio in all directions? [2D] 0 Answers

How to AudioSource.GetSpectrumData while muted? 1 Answer

Real time audio synthesis 1 Answer

Increase the volume of sound source past limit? 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