I want to create a music visualizer, and to do this I want to build an array which safes instructions in order of occurrence in the music. I then want to build a function that parses through the array at a set speed and performs the instructions.
So for example I have an array with {a,b,a,b,a} and for every a the screen turns red for every b the screen turns black.
I tried using Threads and the sleep() function but it wouldn't wake up again. I'm frankly at a loss as to what to do next.
You could use the
modulo
operator along with theframeCount
variable to do something everyX
frames.Here's a little example that changes the background every
60
frames, or once per second:This uses hard-coded
60
to change the background once per second, but you could get that number from an array instead.