relating data to files - with Dict 📚

jay doe's icon

Hi Everyone,

I'm trying to build a little system to store/retrieve a few bits of data when I load a video.
This consists of relevant playback params: rate, looppoints, etc..
Also, want to store some tags related to the semantic content of a clip... such that one can query the Dict and get a list of the files tagged 'sleepingBeauty', or whatever the case.

(This is not at all video specific so it's not in the Jitter forum category).

The idea is...

- load a folder of videos into a umenu.
- dump the names of the files into a Dictionary, with some default values.
- edit/update the values
- retrieve all the values,... (or specific values) when we are going to play the vid.
-query for tagged items when we want to build a playlist of those

I am a bit confused with some aspects of using dict, and perhaps the terminology.
Am I stupid, or is there no place in the documentation that really explains the 'nesting' aspect?

{
    "wheels" :     { // so.... wheels is a dict
        "front" :         { //and front is a nested dict?
            "spokecount" : 24,
            "lacing" : "radial",
            "tirewidth" : 21
        }
,
        "rear" :         {
            "spokecount" : 3334,
            "lacing" : "2-cross",
            "tirewidth" : 23
        }

}

The example attached is a bit silly... using every second item in an array as a param label.
But,... I'm not able to do what I think makes sense, (dumping a folder and applying defaults, using the nesting structure as above), as I get an error that the dict has not been created.

I'm sure the patch explains better than I.
Appreciate any hints on this.
thanks💖

Max Patch
Copy patch and select New From Clipboard in Max.

MIB's icon

not sure if it helps, but here are some ways of doing what I think you are asking for. Might not be the best but similar things have worked for me in the past:

Max Patch
Copy patch and select New From Clipboard in Max.

tyler mazaika's icon

If you just need a default dict structure in every key, do it with "replace" message where the value is a dictionary reference**. It's much easier than setting nested key values individually.

EDIT: Added the green box, which shows how to directly edit the nested dict values without needing to format <key>::<subkey>::<more> strings by setting the @name attribute of [dict.pack]. (This capability seems not well-documented or understood…)

**This can also use further-nested dictionary values if you want, but for this demo I just used [dict.pack] to define a single-layer defaults set, rather than [dict #0defaults].

Max Patch
Copy patch and select New From Clipboard in Max.

MIB's icon

brilliant! I totally missed the @name argument! learned something new, thanks!!