Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Transition between condition statements

  • Transition between condition statements

    Posted by Baard Kolstad on September 2, 2016 at 12:23 pm

    I’m creating this equalizer, and I’m trying to get the different bars to change color depending on the value of the sound they are connected to. The code below is what I have so far.

    Now, it is working. The only thing it is lacking is that it is not transitioning between the different states. So what I’m looking for is a gradient transition between the different if/else conditions. I could of course manually just set more else if statements, but that would take too much time.

    soundValue = Math.floor(thisComp.layer("Medium Gray-Magenta-Red Solid 17").effect("Sound Keys")("Output 1").value);

    if (soundValue >= 570)
    [0,0,1,1]
    else if (soundValue >= 200)
    [0,1,0,1]
    else
    [1,0,0,1]

    Dan Ebberts replied 9 years, 8 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    September 2, 2016 at 1:28 pm

    Something like this maybe:


    if (soundValue > 200)
    linear(soundValue,200,570,[0,1,0,1],[0,0,1,1])
    else
    linear(soundValue,0,200,[1,0,0,1],[0,1,0,1])

    Dan

  • Baard Kolstad

    September 2, 2016 at 1:54 pm

    Thanks Dan! Seems to be working. Is there a way to convert hex values to the 0-1 rgba system? Can’t find any converters online.

  • Dan Ebberts

    September 2, 2016 at 4:07 pm

    There may be something simpler, but this should work:

    myColor = 0x75ff20;
    r = ((myColor & 0xff0000) >>> 16)/255;
    g = ((myColor & 0xff00) >>> 8)/255;
    b = (myColor & 0xff)/255;
    [r,g,b,1]

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy