Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 creative72 · Jun 11, 2011 at 04:06 PM · soundpitchfrequency

getting pitch

so i have an audio file that goes from 100Hz and goes down to 1Hz. i want to be able to get the pitch or frequency of the changing sound but i cant find a way to do it through unity. when i run this code.

   var getfre : float;
     var getpitch : float;
     function Update () {
     if(Input.GetButtonDown("k"){
     getfre = audio.clip.frequency;
     getpitch = audio.pitch;
     Debug.Log(audio.clip.frequency); 
     }
     }
 i get an unchanging pitch of 1 and an unchanging frequency of 44100 everytime i hit "k". is there anyway to get the actual pitch or frequency throughout?
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dju4ic · Jun 11, 2011 at 04:25 PM

Coming from an audio engeineering and production background, I believe this is the reason why:

Pitch - You are playing back the sound at a 1:1 ratio - meaning 1 pitch, if you played it back at half speed it would be .5, double would be 2 etc. Unity can not monitor the output pitch as far as i know of.

Frequency - This is the frequency the sound file is encoded in, usually would be 44100, 44800, 96000 etc.. all depending on what it is encoded in. The higher the frequency i9t is encoded, the more information per sample is stored in the sound file.

I havent looked into what FFT functions are available, but if this is for audio/visual work my best advice is to go with a workflow of vvvv (from vvvv.org - windows only though) - and OSC controls to unity. They do play very well together and vvvv is very versatile for FFT/Audio monitoring and control as well ad directX and Video..

Unfortunately you would not be able to build down including the vvvv application that I know of.. If there is a way, I am very intrigued.

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 aldonaletto · Jun 11, 2011 at 05:23 PM 0
Share

It's correct. Unity's $$anonymous$$ch is intended to vary the sound pitch, not to show which is its real pitch. Finding the real pitch of an audio signal is very tricky, and involves FFT. It can be estimated using the function audio.GetSpectrumData. I didn't test this function yet, and the docs seem incomplete (they mention numSamples, but this parameter can't be found in the function arguments).

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Read the pitch frequency of a audio clip 2 Answers

Custom simulation of Doppler effect 0 Answers

How do I get the fundamental frequency pitch for audio input? 0 Answers

How does AudioSource.pitch changes pitch? 1 Answer

How to use Mathf.SmoothDamp for audio ? 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