- Home /
Music Visualizer?
Does anyone have any ideas on how I can make some function react to music, like an audio visualizer (ex: there is a sudden jump in the music, so I use a particle animator color script to change the color to red or something like that)? I have looked into this
But there is not much info on it.
What is a "jump in the music"? A volume change? A frequency change? The addition of a new frequency? The AudioSource.GetOutputData returns a bunch of audio samples and if you want more information on that, feel free to ask, however UnityAnswers is for questions about Unity. Teaching the ins and outs of digital audio signal analysis is beyond the scope of UnityAnswers. If you have Unity Pro for desktop or mobile, you may consider leveraging an external library (like Clam (clam-project.org)) through a plug-in, but otherwise you must roll your own solution if you cannot find one built for Unity.
Answer by jonas-echterhoff · Dec 14, 2010 at 05:37 PM
You don't need to do any heavy calculations to get spectrum data in Unity - at least not yourself. Just use AudioSource.GetSpectrumData. That gives you all the values, you just need to render it somehow.
Ok, I found a script using that, that prints several values in the console...what do they mean? The frequency, the amplitude...there are many values, are they taken every few seconds from the song?
What GetSpectrumData does is it gives you an array of floats representing the volumes of different frequencies currently playing. So, the lower indices of the array represent low frequencies. If you see high values there, you have a lot of bass. The higher indices represent high frequencies. Like a spectrum analyzer in some consumer electronics.
Is it calculating new values every frame? How do I access these values in another function? Can I calcculate things like BP$$anonymous$$ and audio pikes (as BerggreenD$$anonymous$$ said), using the GetSpectrumData or GetOutputData? Tyler 0 secs ago
Answer by miketucker · Oct 03, 2011 at 12:12 PM
I wrote a fairly long tutorial on how to do music visualization in Unity: http://www.creativeapplications.net/mac/visuals-for-sonar-festival-vdmx-to-unity3d-tutorials/
Answer by BerggreenDK · Dec 09, 2010 at 07:44 AM
I guess you want to build some kinda spectrum analyzer like Winamp visualizations or MediaPlayer screens?
What I've learned from examining this kinda task, is that you have certain heavy calculations to perform each frame if you want a realistic reaction on the sound.
The reason is that music comes with "beats" so there would be some "pikes" in the volume where the drums etc. hits. But there is also a frequence of the waveform you need to put into the equation to get these data out.
My answer would be, go look for a c# example on how to detect BPM on an MP3/OGG and then grab the parts from those.
Its pretty hardcore math to build yourself, I've heard. Sorry that I cant provide you with the actual codesolution, but I havent found it myself. So if you do, please post it to the community as many people might find this very interesting too. Including me. :-)
Answer by rook · Apr 10, 2011 at 03:07 PM
if your interested in beat-detection you can download the source for the processing library, minim (http://code.compartmental.net/minim/distro/minim-2.0.2-full.zip) and look at BeatDetect.java ; perhaps you could port the code to work with Unity3d. hope this helps, -rook
Answer by AlteredReality · Sep 12, 2011 at 07:16 PM
I recently released a Unity Scripting Package for music visualization, called Visualizer Studio. It should help you out quite a bit! :-)
[Link removed by mod]
Umm which moderator approved this? Its a spoofed link to an asset store on a foreign domain.
I added the link to Visualizer Studio in the asset store. It was simply the URL that I got when getting the external link from the asset store page. Not sure what the problem was with the link...
Your answer
Follow this Question
Related Questions
Major Latency on Android when using Microphone 1 Answer
Audio volume change? 1 Answer
Lorenz Attractor Music Visualizer 0 Answers
C sharp cant play Audio 2 Answers
Sound effect doesn't play correctly 1 Answer