The underlying concept for this project was a swarm of fireflies whose glow intensifies with the music. So I started by creating a 100x100 blank image in GIMP and dropping a gradient flare in the middle. I set saturation to 0 to make it grayscale and exported it.
To start coding, I used build 16 as a blank template. I then switched minim to use LineIn instead of a file and changed mic settings in the OS to treat system sound as the mic input.
The next step was to create an HDrawablePool of HImage objects and set size down, alpha down, and color to a yellow-green. Also each HDrawable would select one of the first 11 bands in the audio range. 16 were used in linAverages so that the back end could be discarded. Then I created an HSwarm above and attached it in the onCreate callback.
At this point I had a random swarm of green lights and music input. The next step after this was to use the audio data to set the size of all the swarm members according to their chosen band.
Satisfied so far I added 3 more goals to the swarm so that instead of the center the lights would move to 1/3 and 2/3 from top and left at 4 points, occasionally jumping from one to another. I then tied swarm.twitch to the audiodata, calling max() on it so that whichever band was the highest at any moment would determine the twitch. The louder the music, the higher the twitch, with the max divided by a preset calm value.
I then decided that I wanted a streaking effect whenever a note is held, so I came up with a naive heuristic for this using an HTimer which would run through the same way as myAudioDataUpdate() but instead of collecting tempIndexCon it would check it against a threshold and either increment a value in that array for that band, or reset that value to zero if it was below the threshold. I used a separate indexamp variable to avoid potential race conditions between draw() calling myAudioDataUpdate() and the timer.
Back in draw, I set H.autoClear to max(beltingCheck) < 5. So if a given band tested above the threshold for 5 or more consecutive ticks then autoclear would be disabled. Of course for particularly loud songs this proved troublesome. So I added in an HCanvas, put the pool on the canvas, and then changed the H.autoClear line to:
c1.fade((int)constrain((10/max(beltingCheck)), 2, 20));
Now when max tick count is 0, fade is 20, 10 for 1, 5 for 2, 2 otherwise. It could probably use some adjustment to increase the number of in-between values, but it looks decent enough for now.
To finish things up I decided to find a nice background, which I found at https://frybrix.newgrounds.com/, and then I changed to 3 swarm goals at 1/4, 1/2, and 3/4 from the left; 3/4, 17/24, and 2/3 from the top.
The whole thing still needs a bit more tweaking but it's decent so far for a couple hours' tinkering around.