Can i make objects move or change size to music

Is it possible to sync objects to bpm from a music file. IE make a ball pulsate to a beat.

If you know the exact BPM, you could use a simple maths function, eg:

float scale = 1 + Mathf.Cos(Time.time * (bpm / 60) * Mathf.PI * 2);
transform.localScale = new Vector3(scale, scale, scale);

In the above, I'm dividing the BPM by 60 to get beats per second, then multiplying by PI*2, which gives us a value equal to one full circular rotation in radians, per beat. We then use 'Cos' to get a value which fluctuates between 1 and -1 based on this circular cycle.

You'll probably need to offset the pulsing by adding some fixed amount to Time.time depending on when you start your music, and how far into your track the first actual beat is.

(..and yes optimization geeks, you could cancel out the /60 and *2) or even pre-calculate the time multiplication factor down to a single value - I left these values in for clarity)

If you want more control over your animation, or if your music has pauses or variations in the BPM, you could go for a code-free approach and use Unity's Animation Editor to directly animate the scale values instead.

I dont know if its possible to gain access to the actual bitstream of sound. I guess you are asking because you have seen other musicplayers doing this already? I know the Flash API allows it, so perhaps this might come in Unity3D (if not already available) as its a matter of calculations.

Another approach would be to generate your own "movement animation file" pr. music and then load this along with the music. From this "timeline" you could code your own animations. Ofcause it would need some manual work pr. tune, but I dont know if you want to stream everything or just 10 music pieces in total.

Perhaps you could even "automate" the generation of these files, by using external tools for analyzing the BPM and "pitches" so you get a rough timeline for further editing?