• 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 replayleif · Nov 29, 2015 at 09:53 AM · audiosourceaudioclipmissingcomponentexception

MissingComponentException: no AudioClip even if i add it

so i was trying to use the beat detector by allanpichardo:

https://github.com/allanpichardo/Unity-Beat-Detection

I wanted to understand what the program was doing, so i didnt simply copy-paste everything. I typed everything myself, and came across something with an audio Object. The following lines will show you what he wrote and what i had to write instead ( i guess ):

 AudioProcessor, line 81:
 Him: samplingRate = audio.clip.frequency;
 Me:   samplingRate = GetComponent<AudioClip>().frequency;

 AudioProcessor, line 122:
 Him: if (audio.isPlaying) ...
 Me:   if (GetComponent<AudioSource>().isPlaying) ...

 AudioProcessor, line 125:
 ​​​​​​​​​​Him: audio.GetSpectrumData(spectrum, 0, FFTWindow.BlackmanHarris);
 Me:  GetComponent<AudioSource>().GetSpectrumData(spectrum, 0, FFTWindow.BlackmanHarris);

I thought this must be the new way to write it ( had the same problem with a tutorial on the internet few weeks ago with "rigidbody", untill i read you have to use GetComponent() now ). It makes sense to me. So i added a AudioSource to my Main Camera, draged and droped my audiofile into the "AudioClip"-field and added the "Example"-script to an Object.

Running the program throws 2 different Exceptions. Iam going to focus in the first one. The second one is probably caused by the first one, so iam not taking this any further.

MissingComponentException: There is no 'AudioClip' attached to the "Main Camera" game object, but a script is trying to access it.

Why cant the program find my AudioClip and how do i fix this issue?

Thanks for the effort,

replayleif

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 saschandroid · Nov 30, 2015 at 07:53 AM 0
Share

I guess the problem is in

 samplingRate = GetComponent<AudioClip>().frequency;

The $$anonymous$$ain Camera has no AudioClip component. So it has to be something like

 samplingRate = GetComponent<AudioSource>().clip.frequency;


1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sankalp22 · Nov 30, 2015 at 06:35 PM

Try with youraudioSource.clip to get audio clip.

Thanks.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

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

Related Questions

AudioSource and AudioClip. Stop and play drops an error. 1 Answer

How to play multiple sounds simultaneously 2 Answers

Ambisonic Audio Support for PS4 0 Answers

Audio playing not in right time when calling from script 1 Answer

I have a shooting script. I have a problem: when firing bursts, my sound of a shot breaks. How to make the sound produced to the end. 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