No internet connection
  1. Home
  2. How to

Midi Transpose macro's

By Joe Kearns @Joe_Kearns
    2024-01-02 18:09:30.267Z

    Hey Guys,

    happy new year!

    I have a bunch of macro's that I used for transposing midi quickly but since pro tools changed the event operations window they havent worked. I was wondering if any would be able to modify one for me to work with the new window please? Then I could apply the new code to all my variations!

    thanks so much in advance, code is below:

    //

    var velLow = '0'
    var blank = '-1'

    sf.ui.proTools.appActivateMainWindow();

    sf.ui.proTools.menuClick({
    menuPath: ["Event", "Event Operations", "Transpose..."],
    });

    sf.ui.proTools.windows.whoseTitle.is("Event Operations").first.popupButtons [0].popupMenuSelect({
    menuPath: ["Transpose"],
    });

    sf.ui.proTools.windows.whoseTitle.is("Event Operations").first.textFields.allItems[0].elementSetTextFieldWithAreaValue({
    value: velLow,
    useMouseKeyboard: true,
    });
    sf.keyboard.press({
    keys: "delete",
    });

    sf.keyboard.type({text: velLow});

    sf.ui.proTools.windows.whoseTitle.is("Event Operations").first.textFields.allItems[1].elementSetTextFieldWithAreaValue({
    value: blank,
    useMouseKeyboard: true,
    });
    sf.keyboard.press({
    keys: "delete",
    });

    sf.keyboard.type({text: blank});

    sf.ui.proTools.windows.whoseTitle.is("Event Operations").first.buttons.whoseTitle.is("Apply").first.elementClick();

    sf.ui.proTools.windows.whoseTitle.is("Event Operations").first.getElement("AXCloseButton").elementClick();

    • 8 replies
    1. S
      Sreejesh Nair @Sreejesh_Nair
        2024-01-05 09:58:08.021Z

        This should work:

        var velLow = '0'
        var blank = '-1'
        
        sf.ui.proTools.appActivateMainWindow();
        
        sf.ui.proTools.menuClick({
            menuPath: ["Event", "Event Operations", "Transpose..."],
        });
        
        sf.ui.proTools.windows.first.textFields.allItems[0].elementSetTextFieldWithAreaValue({
            value: velLow,
            useMouseKeyboard: true,
        });
        sf.keyboard.press({
            keys: "delete",
        });
        
        sf.keyboard.type({ text: velLow });
        
        sf.ui.proTools.windows.first.textFields.allItems[1].elementSetTextFieldWithAreaValue({
            value: blank,
            useMouseKeyboard: true,
        });
        sf.keyboard.press({
            keys: "delete",
        });
        
        sf.keyboard.type({ text: blank });
        
        sf.ui.proTools.windows.first.buttons.whoseTitle.is("Apply").first.elementClick();
        
        sf.ui.proTools.windows.first.getElement("AXCloseButton").elementClick();
        

        Here is a more streamlined version of this code

        var velLow = '0', blank = '-1';
        
        sf.ui.proTools.appActivateMainWindow();
        sf.ui.proTools.menuClick({ menuPath: ["Event", "Event Operations", "Transpose..."] });
        
        const setTextField = (value, index) => {
            sf.ui.proTools.windows.first.textFields.allItems[index].elementSetTextFieldWithAreaValue({
                value: value,
                useMouseKeyboard: true
            });
            sf.keyboard.press({ keys: "delete" });
            sf.keyboard.type({ text: value });
        };
        
        setTextField(velLow, 0);
        setTextField(blank, 1);
        
        sf.ui.proTools.windows.first.buttons.whoseTitle.is("Apply").first.elementClick();
        sf.ui.proTools.windows.first.getElement("AXCloseButton").elementClick();
        
        1. LLlion Robertson @Llion_Robertson
            2024-01-23 09:50:50.559Z

            Hi Sreejesh,

            This is great. Is there any chance you could tweak it so it sets all selected midi notes to C1?

            Many thanks

            Llion

            1. SSreejesh Nair @Sreejesh_Nair
                2024-01-24 14:06:28.996Z

                This will work.

                var vTranspose = 'C1';
                
                sf.ui.proTools.appActivateMainWindow();
                sf.ui.proTools.menuClick({ menuPath: ["Event", "Event Operations", "Transpose..."] });
                
                const setTextField = (value, index) => {
                    sf.ui.proTools.windows.first.textFields.allItems[index].elementSetTextFieldWithAreaValue({
                        value: value,
                        useMouseKeyboard: true
                    });
                    sf.keyboard.press({ keys: "delete" });
                    sf.keyboard.type({ text: value });
                };
                
                setTextField(vTranspose, 5);
                sf.ui.proTools.windows.first.buttons.whoseTitle.is("Apply").first.elementClick();
                //sf.ui.proTools.windows.first.getElement("AXCloseButton").elementClick(); 
                
                1. LLlion Robertson @Llion_Robertson
                    2024-01-26 11:49:16.696Z

                    Thanks for looking into this for me. Unfortunately, it selects the 'Transpose in key' radio button in the Event Operations' box instead of 'transpose all notes to' when you run it so it sets the places the notes in an odd place. Any chance you could tweak?

                    1. SSreejesh Nair @Sreejesh_Nair
                        2024-01-26 17:30:55.251Z

                        What version of PT are you on? It works on 2023.12 as intended. If you are on a different version it could be that the order of the textbox has changed. Can you try changing

                        setTextField(vTranspose, 5);
                        

                        to

                        setTextField(vTranspose, 4);
                        

                        and check?

                        1. LLlion Robertson @Llion_Robertson
                            2024-01-26 17:38:16.124Z

                            Worked perfectly! Thanks so much!

                    2. In reply toSreejesh_Nair:
                      MMichael Ubinas @Michael_Ubinas
                        2024-02-19 18:49:04.905Z

                        Hey Sreejesh! Thanks for this script. One question, whenever I run this script, it doesn't click the apply button. Everything is fully updated and It'll still run through the script like everything is normal (and I don't get any errors), but in the end it doesn't transpose. Seems like everything's working perfectly except for

                        sf.ui.proTools.windows.first.buttons.whoseTitle.is("Apply").first.elementClick();
                        

                        Could you help me with a solution / workaround? Thanks!

                      • J
                        In reply toJoe_Kearns:
                        Joe Kearns @Joe_Kearns
                          2024-01-06 22:00:25.040Z

                          Thanks so much!! this works great.

                          Really appreciate the help!