- Home /
Audio clip.GetData not working
I want to have objects spawn based on the amplitude of the audio clip as it plays, I have trouble getting the amplitude. I tried GetData to get the value, but somehow GetData doesn't seem to be working. It just GetData function and the for loop. I tried to debug by printing a line of text, the text showed in my console window, so the update function is working correctly.
I set the load type to Decompress on load.
The following is the code I tried. THX for the help!
public AudioClip iMusic;
AudioSource mySource;
float[] myMusicSample=new float[iMusic.samples];
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
iMusic.GetData(myMusicSample,0);
for(int i = 0; i> myMusicSample.Length; i++){
print(myMusicSample[i]);
}

Your answer
Follow this Question
Related Questions
Audio clip not playing 1 Answer
WWW Audio and PlayOneShot: Playing the same AudioClip Twice Cuts off First Instance 1 Answer
It is possible to start a streaming AudioClip not from the beginning ? 1 Answer
Audio loops too early 2 Answers
How to create an audio manager script with input from triggers? 2 Answers