No internet connection
  1. Home
  2. Script Sharing

Pro tools 2023.12 new memory locations window - getMemoryLocations

By samuel henriques @samuel_henriques
    2023-12-13 17:24:34.332Z2023-12-20 17:17:42.718Z

    Hello everyone,

    The new memory locations window for pro tools 2023.12 can be read with sf.proTools.memoryLocationsFetch().collection['List']but we wont get the correct information.
    Here's a function to replace this command. I tried to keep the same object key names as we had before so it should be easy to replace it.

    You might still need to change memLoc.name to memLoc['Name']for example. So the object key is correct.
    Also I removed the "Selected." from the values of the selected memLoc and added isSelected to the object.

    Happy holidays to all.

    /**
     * Retrieves a list of memory locations.
     *
     * @function
     * @returns {Array<Object>} An array of objects representing memory locations.
     * @property {boolean} isSelected - Indicates whether the memory location is selected.
     * @property {string} Sharing Merging
     * @property {string} Active Location
     * @property {string} Number
     * @property {string} Name
     * @property {string} Track Name
     * @property {string} Marker View filter
     * @property {string} Selection Memory Location View filter
     * @property {string} Zoom Settings View filter
     * @property {string} Pre/Post-Roll View filter
     * @property {string} Show/Hide View filter
     * @property {string} Track Heights View filter
     * @property {string} Active Groups View filter
     * @property {string} Window Configuration filter
     * @property {string} Venue Snapshot filter
     * @property {string} MainCounterValue
     * @property {string} Sub Counter
     * @property {string} Comments
     */
    function getMemoryLocationsList() {
        let memLocList = []
        sf.ui.proTools.memoryLocationsEnsureWindow({
            action: () => {
                const memLocWin = sf.ui.proTools.memoryLocationsWindow.tables.whoseTitle.is("Memory Locations")
                const memLocColumns = memLocWin.first.children.whoseRole.is("AXColumn").first.children.whoseRole.is("AXRow").first.children.whoseRole.is("AXCell").map(mem =>
                    mem.children.whoseRole.is("AXStaticText").first.title.value
                        .replace("Numeration", "Number")
                        .replace("Marker Name", "Name")
                        .replace("Main Counter", "MainCounterValue")
                );
    
                memLocWin.allItems[1].children.whoseRole.is("AXRow").map(r => {
                    let obj = {};
                    r.children.whoseRole.is("AXCell").map((cell, i) => {
    
                        obj["isSelected"] = false
                        const cellValue = cell.children.whoseRole.is("AXStaticText").first.value.value
    
                        if (cellValue.startsWith("Selected. ")) {
                            obj["isSelected"] = true
                        }
    
                        obj[memLocColumns[i]] = cellValue.replace("Selected. ", "")
                    })
                    memLocList.push(obj)
                })
    
            },
            restoreWindowOpenState: true
        })
        return memLocList
    };
    
    • 14 replies
    1. J
      John York @John_York
        2023-12-14 16:59:57.791Z

        Hi Samuel

        Complete novice re the coding

        Do I create a new Script and then Copy and Paste this script into it - and give that script a Keyboard Trigger?

        No success so far - the Search Memory Locations window does not come up - even if I run the Script from the SF App

        Best regards

        John

        1. samuel henriques @samuel_henriques
            2023-12-14 20:39:42.638Z

            Hello John,
            This is meant to grab the memory location list so you can use the data for some script.
            If you want to see how it looks like, add

            let memLocList = getMemoryLocationsList()
            log(memLocList)
            

            after what you pasted, and you can see it in the SF log

            1. JJohn York @John_York
                2023-12-15 08:18:46.338Z

                Hi Samuel

                No result

                I think what I want is not what you are describing for this script
                I am looking for bringing up the SF window with all the Marker names in - and then typing the name wanted in the top left to search all Markers with that word in. So I can click on the marker name I want - then PT jumps to that Marker

                This got broken a few days ago when I installed the latest PT 2023.12

                Is this what your script is about?

                Kind regards

                John

                1. samuel henriques @samuel_henriques
                    2023-12-15 10:41:37.658Z

                    Hey John,
                    I'm sorry for the confusion.
                    I know what you mean, the built in search window, and I can confirm SoundFlow's Christian is working to fix it and hopefully will be released if a few days.

                    I the mean time, here's a simple script to open pro tools memory locations window and focus it so you can start typing to filter memory locations.

                    sf.ui.proTools.memoryLocationsEnsureWindow({
                        action: () => {
                            sf.ui.proTools.memoryLocationsWindow.windowFocusClick()
                        }
                    })
                    

                    Or you can just use pt's shortcut ⌘5
                    Hope it helps a bit.

                    1. Hi Samuel,
                      Thanks for the script.
                      That should work but have to rewrite a few scripts.

                      Anyone knows if memoryLocationsFetch() will be fixed? @chrscheuer?
                      MainCounterValue is empty or "Marker Ruler" with 2023.12 and 5.5.4
                      so you can't filter the array to get the marker at current cursor position.

                      13.01.2024 15:01:33.65 [Backend]: [LOG] Name -> School Gang
                      [LOG] MarkerTrack -> Marker Ruler
                      [LOG] MainCounterValue -> Marker Ruler
                      [LOG] StartTime -> null
                      [LOG] EndTime -> null
                      [LOG] StartTimeInSamples -> 0

                      Regards,
                      Pierre

                      1. Dustin Harris @Dustin_Harris
                          2024-01-15 02:25:47.971Z

                          Since you're on 2023.12, give this a shot?

                          const memoryLocations = sf.app.proTools.memoryLocations.invalidate().allItems.map(m => {
                              let mappedProps = {};
                          
                              for (let prop in m) {
                          
                                  const itemsToSkip = ["Parent", "FriendlyNodeName", "SupportsAutoUpdate",]
                          
                                  if (!itemsToSkip.includes(prop)) {
                                      const lowerCasePropName = prop.slice(0,1).toLowerCase() + prop.slice(1);
                                      mappedProps[lowerCasePropName] = m[prop];
                                  }
                              }
                              return mappedProps;
                          })
                          
                          log(memoryLocations);
                          
                          1. Much more elegant than the brute force approach I was trying, I sure wish it would tell us what color the marker was too.

                2. G
                  George Hinson @George_Hinson
                    2024-03-11 16:30:11.821Z

                    Hi @samuel_henriques ,

                    A novice here, I am trying to open the memory location at the start of a selection and copy the name but I'm struggling to work out a way to do so, any help would be much appreciated,
                    All the best,

                    George

                    1. samuel henriques @samuel_henriques
                        2024-03-13 10:56:11.733Z

                        Hello George,

                        To get selection first memory location name, you can use:

                        
                        
                        const memoryLocations = sf.app.proTools.memoryLocations.invalidate().allItems.map(m => {
                            let mappedProps = {};
                        
                            for (let prop in m) {
                        
                                const itemsToSkip = ["Parent", "FriendlyNodeName", "SupportsAutoUpdate",]
                        
                                if (!itemsToSkip.includes(prop)) {
                                    const lowerCasePropName = prop.slice(0, 1).toLowerCase() + prop.slice(1);
                                    mappedProps[lowerCasePropName] = m[prop];
                                }
                            }
                            return mappedProps;
                        })
                        
                        const { inTime, outTime } = sf.app.proTools.getTimelineSelection({ timeScale: "Samples" });
                        
                        const selectionMemLocs = memoryLocations.filter(ml => ml.startTimeInSamples >= inTime && ml.startTimeInSamples <= outTime);
                        
                        const firstMemLocInSelectionName = selectionMemLocs[0] && selectionMemLocs[0].name
                        
                        log(firstMemLocInSelectionName)
                        
                        
                        
                        1. GGeorge Hinson @George_Hinson
                            2024-03-21 17:54:53.030Z

                            Hi Samuuel, thank you so much for this! Do you know if there is a way I can then copy the name from the script log? Thanks so much,
                            All the best,

                            George

                            1. samuel henriques @samuel_henriques
                                2024-03-22 10:38:28.202Z

                                hello George,
                                If you want to set the firstMemLocInSelectionName in the clipboard, so you can paste it somewhere else, you can add

                                if (firstMemLocInSelectionName) {
                                
                                    sf.clipboard.setText({ text: firstMemLocInSelectionName })
                                }
                                
                                1. GGeorge Hinson @George_Hinson
                                    2024-03-22 11:47:21.311Z

                                    Thanks so much Samuel! This is great I'm creating a code to copy the memory location name and bounce a mix with that name and I've been stuck getting the memory name for ages so thank you :)

                                    1. samuel henriques @samuel_henriques
                                        2024-03-22 11:59:34.512Z

                                        here's a good start for you, add after line 22, the log you can delete.

                                        
                                        sf.ui.proTools.appActivateMainWindow();
                                        
                                        sf.ui.proTools.menuClick({ menuPath: ['File', 'Bounce Mix...'] });
                                        
                                        const bounceMixWindow = sf.ui.proTools.windows.whoseTitle.is("Bounce Mix").first
                                        bounceMixWindow.elementWaitFor();
                                        
                                        bounceMixWindow.textFields.first.elementSetTextFieldWithAreaValue({ value: firstMemLocInSelectionName })
                                        
                              • O

                                This is awesome man, Is there any way you could add color detection to this?