Hacker News new | past | comments | ask | show | jobs | submit login

Reminds me to revisit displacement mapping — probably not going to be a replacement for the problem that author is trying to solve but simpler and kind of fun.

I wrote a kind of cool music visualizer for SoundJam perhaps 25 years ago I called "Eclipse". Input data was an array of levels (probably integers) across some range of audible frequencies — a left and right channel.

Think of the eclipsed sun with corona ejections — that was what I was going for. The music data was the "ejections". The frequency of the data determined where around the disc of the sun it would appear.

Over time the ejecta moved away from the sun and soon disappeared as they "cooled" to black — the initial color of the ejecta being white for the strongest signals — yellow, orange, red, brown when weaker. (Think of the black body curve.)

I had to keep a circular buffer of the sound data values (an array of arrays) large enough to represent how much time the ejecta would "live" before disappearing to black.

In any event, the whole display of the "eclipse", ejecta, was just a displacement map. I had pre-calculated a bitmap where the value for each "pixel" was an offset into the buffer of sound level values. "pixels" close to the surface of the sun would have offsets to the new data coming in, pixels further out would have offsets into the tail of the buffer that was about to expire. With the circular, radial aspect of the ejecta, there was some math involved in generating the displacement values in order to map from essentially a radial space to a cartesian one.

With that established as described, the main loop simply pulled in new sound values, over-wrote the oldest values in the circular buffer with the new and then iterated row and column-wise over the displacement map, grabbing the corresponding sound data value, mapped it to a color in a fixed palette and pushed that color into display buffer.

Although not as "flashy" as other visualizers, there was I thought a calm beauty to it. And it very much represented the music data (you know, as opposed to later visualizers where, even when presented with silence, they seemed to be unable to settle down).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: