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 sharpshot124 · Jun 22, 2012 at 09:57 AM · soundpitchfrequencyaudio clip

Read the pitch frequency of a audio clip

i need to be able to read the pitch of a song at runtime in unity, and to avoid confusion i dont mean audioClip.pitch or audioClip.frequency, because frequency is the same through out and pitch just changes the pitch of the clip not tell me the actual frequency, any help would be greatly appreciated

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by maturasek · Jun 26, 2012 at 01:11 PM

Pitch detection is not a trivial problem, since every polyphonic audio data has a whole spectrum of frequencies. The actual "pitch" is just the most significant frequency in it for the human mind.

This spectrum can be extracted with the FFT algoritms, which is a widely discussed and reasearched topic. Unity also has FFT solution, which I found fast enough for some real time work. You can simply use AudioSource.GetSpectrumData, but, as FadeToBlack mentioned, the spectral data will only give you the source material for actual pich detection algorithms (findign the fundamental frequency, etc) If you need some more info on the topic, please refer to the article on this page

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 FadeToBlack · Jun 26, 2012 at 11:25 AM

to get actual pitch of sound playing at current time, you need to get sound data currently playing (using something like AudioSource.GetOutputData), then you need to learn what is Fast Fourier Transform, find & download some ready solutions around this. using FFT you can detect pitch of your sound (or even detect a note), but it also need to do some hard work. i think simply you need to find some ready solutions for sound analyzing for realtime. if you will not found ready solutions, then you can do some experiments with FFT. it gives you spectrum of your sound, you need to found maximum amplitude, it tells you approximated frequency.

Comment
Add comment · Show 2 · 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 FadeToBlack · Jun 26, 2012 at 01:38 PM 0
Share

AudioSource.GetSpectrumData - wow ) even so.. a long time ago i have try to make guitar tuner, but also stuck on frequency detection, but i was needed in best precision. detect which note playing or approx frequency is quite simple.

avatar image maturasek · Jun 26, 2012 at 01:47 PM 0
Share

Yeah, you are right, in a guitar tuner, pitch detection is quite simple and precision is a bigger importance. When I wrote my answer I had my music information retrieval project (kind of a genre detection problem) in my $$anonymous$$d, and in my case it was quite hard to extract pitch data from a complex music piece. Well, I guess I have to relax a bit :)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

getting pitch 1 Answer

How to use Mathf.SmoothDamp for audio ? 1 Answer

constant audio sounds? 1 Answer

Audio signal plug-in? 1 Answer

Code to measure sound waves 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