Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to target multiple keyframe to check their values from Slider Control

  • Shahid Raza

    January 26, 2017 at 1:26 am

    I’ve changed the code slightly to this now per .ai file’s layer in the comp:


    midiNote = thisComp.layer( 'midi' ).effect( 'ch_0_pitch' )( 'Slider' );
    noteActive =thisComp.layer("midi").effect("ch_0_vel")("Slider");
    midiNumber = parseInt(name.split("/")[0]);
    if ( midiNote == midiNumber && noteActive > 0 ) 100 else 0;

    Still need to figure out how to target the multiple keyframes.

    Hope someone can give me a hand here… Thanks 🙂

  • Dan Ebberts

    January 26, 2017 at 10:45 pm

    Just curious–in your graph of the keyframe data, where are those keyframes?

    Dan

  • Shahid Raza

    January 27, 2017 at 9:12 pm

    Hi Dan!

    Here’s what those keyframes are if this is what you meant…

    Thanks, looking forward to your reply!

  • Dan Ebberts

    January 27, 2017 at 9:52 pm

    No, I meant what properties are they on?

    DaN

  • Shahid Raza

    January 27, 2017 at 10:25 pm

    Sorry, I’m not quite sure what you mean — might be that I’m new to After Effects and all (like literally a week of proper messing about with it).

    The keyframes were created by using the om_midi script from here: https://omino.com/pixelblog/2011/12/26/ae-hello-again-midi/

    After importing the midi file, it created a null layer named midi with several Slider effects full of keyframes.

    So those keyframes you are seeing are only on the midi layer’s ch_0_pitch, ch_0_vel and ch_0_dur effects.

    Would this be of help? I’m sorry if I’m sounding too noobish!

  • Dan Ebberts

    January 27, 2017 at 10:58 pm

    I’m at a loss as to what you mean by “target multiple keyframes”. The pitch slider can only have one note value at a time. Unless there are multiple channels–is that the case?

    Dan

  • Shahid Raza

    January 27, 2017 at 11:02 pm

    Hm, that’s really odd. I have only one channel (ch_0) and the pitch slider has 2-3 or more in some cases within the same slider…

    Could this be a bug with om_midi script or am I doing something wrong?

    If you see this image from my previous post you’ll see I have only highlighted the midi layer’s ch_0_pitch slider:

    There are no other layers down selected here. Just the midi layer.

  • Dan Ebberts

    January 28, 2017 at 12:02 am

    I’m not quite sure what’s going on there. A given frame can only have one keyframe value. It looks like you have some in quick succession, where maybe a chord is played, but each particular note value is held for only one frame. I’m not sure how an expression would know whether a particular note is still playing or not.

    Dan

  • Dan Ebberts

    January 28, 2017 at 12:29 am

    It would interesting to compare the midi data to the resulting keyframes. I wonder if each note duration is bookended by a pair of keyframes, one signifying note on and the other note off. if that’s the case, the expression for each key would have to look at all the keyframes up to the current time to see how many times the value for his particular key shows up. If it’s an odd number that note is on, if it’s a even number the note is off. Definitely do-able if that’s how it’s set up.

    Dan

  • Dan Ebberts

    January 28, 2017 at 7:31 am

    OK, so if that’s how it operates (keyframe pairs to designate note on/off) something like this should work:


    midiNote = thisComp.layer( 'midi' ).effect( 'ch_0_pitch' )( 'Slider' );
    midiNumber = parseInt(name.split("/")[0],10);
    n = 0;
    for (i = 1; i <= midiNote.numKeys; i++){
    if (midiNote.key(i).time > time) break;
    if (midiNote.key(i).value == midiNumber) n++;
    }
    if (n%2) 100 else 0

    Dan

Page 1 of 2

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