so i was trying to use the beat detector by allanpichardo:
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