Adobe After Effects Expressions Forum
Color Expression with Audio
Color Expression with Audio
by Andrew Pientka on Jan 31, 2008 at 4:48:58 pm

Dear Creative Cow,

I’m working on a project where I need to randomize color in text, to the beat of an audio track. The effect that I'm looking for, is that the color will "cut" or change immediately to a different pigment, with the beat of the music. Is there an expression that can do this for me? Thanks.




Re: Color Expression with Audio
by Dan Ebberts on Jan 31, 2008 at 6:24:38 pm

Something like this should work:

threshold = 10.0;

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--
}

seedRandom(n,true);
random([1,1,1]) + [0,0,0,1];


You may have to adjust the value of "threshold".

Dan




Re: Color Expression with Audio
by Andrew Pientka on Feb 5, 2008 at 2:47:34 pm

Hi Dan,

Just wanted to say thank you very much, the expression worked wonderfully.




Re: Color Expression with Audio
by Rafael Cruz on Nov 21, 2008 at 5:32:36 pm

I tried using this expression on the hue setting of the Color Balance (HLS) effect and it didn't work. The problem seems to be that there are too many values in the code for the property (hue) that i'm trying to manipulate.

Is there another effect that I should apply this expression to in order to have random color change in time with music?




Re: Color Expression with Audio
by Dan Ebberts on Nov 21, 2008 at 7:41:05 pm

Try changing the last line of the expression to this:

random(360)


Dan




Re: Color Expression with Audio
by Rafael Cruz on Nov 22, 2008 at 1:49:49 am

Thanks Dan!

The change worked.
I had come to suspect that the problem was with the last line but I didn't know what to do to correct it.




Re: Color Expression with Audio
by Deepak Kumar on Nov 14, 2018 at 6:24:52 am

Can Anyone Tell Me How This Expression Works. Why Color Reacts To That Value?


Re: Color Expression with Audio
by Dan Ebberts on Nov 14, 2018 at 7:36:28 am

Which value are you talking about?

Dan




Re: Color Expression with Audio
by Deepak Kumar on Dec 4, 2018 at 6:18:53 am

Value which is Evaluated by that expression. how we are telling AE to Change Value of Color tone. Why it reacting With Color Shade?


Re: Color Expression with Audio
by Deepak Kumar on Dec 4, 2018 at 6:30:15 am

Value which is Evaluated by that expression. how we are telling AE to Change Value of Color tone. Why it reacting With Color Shade?


Re: Color Expression with Audio
by Kalleheikki Kannisto on Dec 9, 2018 at 10:48:02 am

If the question is WHERE does this expression go, it would go to the color value either in the layer itself if it has one (such as in shape layer), or the color value of the fill effect, for instance, if you're using that to color something that doesn't have color option in it directly.

Kalleheikki Kannisto
Senior Graphic Designer


Re: Color Expression with Audio
by Deepak Kumar on Dec 15, 2018 at 7:26:24 pm

This Is actually what is happening. i want to know why It is Happening? If i Put This expression in rotation it Dont Work . Why work Only With Color?


Re: Color Expression with Audio
by Kalleheikki Kannisto on Dec 15, 2018 at 7:35:39 pm

Color values are arrays with 4 values in the range of 0 to 1 for R, G, B and alpha, whereas rotation is a single number value in the range of 0 to 360 (or multiples thereof) for angle. In order to use this for rotation, you need to replace the last line with random(360)

Kalleheikki Kannisto
Senior Graphic Designer





© CreativeCOW.net