Alright - so here's my story. I have this game called ShiftOS, and one of the parts of the game is the ability to fight with various networks in a Hacker Battle. In the background of the Hacker Battle, I have some royalty-free EDM/House music playing through a WMPLib.WindowsMediaPlayer object and it all works fine.
Now, because the music is kinda meant for dance, it should be easy to make flashy colors, right? Well, that's what I'm doing. At certain parts of each song I have different "visualizers" set, and each visualizer can either be a "Pulse", where the color values go from 0 to 255, and back, in a fast loop, or "BuildUp", where the color gets brighter throughout the section, or "CalmDown", where the color gets darker throughout the section. Cool. This works perfectly as I can get the current position of the song and what visualizer should happen at the current point.
The plan is to set the background color of a WinForms panel to the proper color of the visualizer, and for Pulses, I have that working perfectly. As for BuildUps and CalmDowns, well, this is tricky, and I have two problems.
For BuildUp, how can I take two 'minimum and maximum' values, say, 100 and 150, and then take a 'position' value between the two, say '125', and turn it into a color value, say, 'minimum' is 0, 'maximum' is 255, and 'position' is '127'?
And for CalmDown, how would I reverse that value so that the color gets darker over time?