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
2
Question by danivdwerf · Sep 04, 2016 at 05:43 PM · c#audioaudiosourcemicrophonefrequency

Get the frequency from an AudioSource

Hey!

I am trying to make a game where I use my guitar as controller. (I know unity isn't the best for this) I figured out some stuff and now I can use my guitar as Input. But is there a way to get the input frequency from a mic or from a Audiosource? (for the people that ask why I would want the frequency, I want to use it to check if I hit a certain note).

Thanks :)

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 doublemax · Sep 04, 2016 at 07:34 PM 2
Share

http://answers.unity3d.com/questions/1113690/microphone-input-in-unity-5x.html

This seems to show how to get realtime input from the microphone. Figuring out the frequency through FFT will be your job though :)

avatar image danivdwerf doublemax · Sep 05, 2016 at 06:37 AM 0
Share

Well, as I wrote in my question, I already have something to get realtime input. I just can't figure out how to find out the frequency

avatar image doublemax danivdwerf · Sep 05, 2016 at 08:13 AM 0
Share

I just found this in the docu. $$anonymous$$aybe it does what you need? https://docs.unity3d.com/ScriptReference/AudioSource.GetSpectrumData.html

avatar image AlucardJay · Sep 05, 2016 at 08:40 AM 1
Share

Here are some posts I have bookmarked. Not sure how much editing you'll have to do to be compatible with Unity5, but at least its a starting point.

Frequency :

http://answers.unity3d.com/questions/175173/audio-analysis-pass-filter.html

http://forum.unity3d.com/threads/unity-3-audio-spectrum-analysis.58769/#post-409103

https://www.youtube.com/watch?v=V_8JSWVT36k

http://gamedevelopment.tutsplus.com/tutorials/how-to-use-sound-to-make-3d-geometry-in-unity--cms-20456

Amplitude :

http://answers.unity3d.com/questions/157940/getoutputdata-and-getspectrumdata-they-represent-t.html

http://answers.unity3d.com/questions/165729/editing-height-relative-to-audio-levels.html

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by jkeogh1413 · Mar 08, 2018 at 03:06 AM

@danivdwerf I've had some luck with this by using AudioSource.GetSpectrumData. It transforms the most recently played audio samples from the time domain to the frequency domain, so what you get is an array populated with bins of frequency values from 0Hz - the sampling rate (which can be retrieved from AudioSettings.outputSampleRate) / 2, split by the length of the array you provide. So if you provided an array with a length of 1024, and your sample rate was 48000Hz, your maximum returned frequency would be 24000Hz and each index of the array would represent a frequency chunk of ~23Hz.

If you're running your live microphone input into an AudioSource like so: https://docs.unity3d.com/ScriptReference/Microphone.Start.html

This method should work well for you.

I have a more in-depth article where I go through more examples and provide a bit more clarity, but this short description should get you on the right track. If you want to check out the article it's here: https://medium.com/giant-scam/algorithmic-beat-mapping-in-unity-intro-d4c2c25d2f27

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

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

Related Questions

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

Audio Record Limit? 1 Answer

Problem with audio 1 Answer

Audio/c#/unity Can i control the duration by time ? 1 Answer

Trying to monitor the incoming audio from external usb interface 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