Seems to be a line missing from the expression that Dan originally posted. To use this expression, you need to select your audio layer, go the “Animation” drop down > Keyframe Assistant > Convert Audio to Keyframes. That will drive your color changes.
Then add a fill to your spectrum, alt + click the color stopwatch and add this expression. In my example I have it set to 3 colors, RGB, you can add more colors by adding a “, [0,0,255,255]/255]” to the end of the expression, just make sure you take the last bracket ] off the previous color.
threshold =10.0;
colors = [[255,0,0,255]/255,[0,255,0,255]/255, [0,0,255,255]/255];
audioLev = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
above = false;
frame = Math.round(time / thisComp.frameDuration);
n = 0;
while (frame >= 0){
t = frame * thisComp.frameDuration;
if (above){
if (audioLev.valueAtTime(t) < threshold){
above = false;
}
}else if (audioLev.valueAtTime(t) >= threshold){
above = true;
n++;
}
frame--
}
colors[n%colors.length]
Johnny Cuevas, Editor
ThinkCK
“I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work.”
—THOMAS EDISON on inventing the light bulb.