-
changing light colour to music with expressions
I am trying to change light colors based on audio keyframes, but can’t seem to make it work. I had found an expression that did what I was looking for on a fill layer :
threshold =20.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]
But when I try to apply this to a light colour, it gives after effects a complete heart attack, and I can’t preview any video until I remove the expression and re-load. I tried applying this effect to just a fill layer, and then linking the light color to it, but it just has the same effect. Works flawlessly when just on the fill layer…
What I am trying to achieve is a group of 4-5 lights following a null object along a path, inside a trapcode Tao ‘tunnel’ so the blinking lights affect the walls etc. I was hoping to have each light cycle between a few colors to different parts of the beat. The only thing I am having trouble doing is changing the light colors to the music – they just don’t want to respond. Any insight woudl be appreciated.