Using pattr to create portable presets
I’m working on a patch for a multi-channel video performance. I want to create presets for various video clips to adjust brightness, contrast, scaling, etc., so that when I load up a given clip, it will automatically come up with those preset values. Ideally, I’d like to have the clips and their presets be portable between channels. In other words, I’d prefer if I can put VideoA.mp4 into any one of the three channels – which each have independent adjustments – and have it take its presets with it. At minimum, I need to be able to set each video’s preset values in one of the three channels without it affecting the others. For example, if I have VideoA.mp4 in channel 1 and VideoB.mp4 in channel 2, I need to be able to save their values independently, because next time I load up VideoA.mp4 in channel 1, a different video might be in channel 2. So I would not want channel 2’s presets to load along with channel 1’s.
I’m having difficulty with two things:
1) Getting independent control through the pattr system of different sets of objects. Haven’t figured out how to get pattr to save and load channel 1’s presets without doing channel 2’s presets at the same time.
2) Getting the selection of video name to be the thing that loads the presets. In other words, when I load a video from a menu, it should automatically load the presets, rather than requiring me to recall them with numbers. Do I need to do it with some sort of a lookup, or is it possible to do this directly within the pattr system?
I’ve attached a piece of my patch with (hopefully) the relevant pieces in it.
Thanks for any suggestions!
This is easier with presets, because they can be as local as you want. If you want to use pattrstorage, you’ll need separate ones at each patch level for them to be independent. The example patch below puts them in subpatches, so each has its own pattrstorage, for local interpolation. In the main patch there’s another one with @greedy 1 which sees all the named objects in each subpatch, plus it sees the actual subpatches as clients too (showing the current interpolation point).
It takes some doing to get the order of creating the objects right, they tend to get named automatically and retain old scripting names. you will want all other objects in the subpatches to NOT have any scripting names, otherwise they will show up in the main pattrstorage’s client list (like your comments etc. which you’re not storing).
If you use [bpatchers] instead, you’ll have your pattr-ized controls right in the main patch instead of popup windows. For this example I didn’t want the hassle of saving two files, so I used subpatches.
Interesting stuff, there seems to be more and more you can do with pattrstorage once you dig around… and once you get the process in the right order. If you change client lists while experimenting (add or remove a client object), your stored slots are lost, so don’t laboriously save a whole bunch of presets while you’re experimenting, wait until it’s done to store your goodies.
Hopefully the change to the umenu works for your purposes too, not sure if you needed all that regexp stuff, check and see if it’s OK…
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 3327.3oc6cs0iaaiE94o.8+ffeZWfYUDI009zta6tEH.oMnYQeYSgAsDsslH KYHIOSlFr+22CotKKYqwi7EkvAH1wTTjmyGOmCOjleVe46+t6lsH5yrjYJ+f x+U4t69BTxchx3kbWQA2MaC8ytAzDQEm4FsYCKLc184WLk84TwE9MVBKUIcM S4QZvNVhhen3SI6Vrkl5tlEmnrzONIU4uPCBTRiTP+UUk+yZVnRB8Qlx1XQC fxtO+DnFaUBXOxBT+X3GCEUbUD+pzPOE20zvUPiGsgoDsrV2duxSqYvGiUdN ZmxtDl3ZYM99xDTRhxtsboAptpxuF5xpqCzXVdW4ceCwDuuXpHZxbUJZKKqq 1PgJ5F3CX1S9gdQOIDe+vTV71n.ZJSYAK8IFTajp3RXUtz7DusTD.UCDkQgh KD+bQSfOePnAJtTQ2lioPG5+nu2NpP3RAvOJlBv1a+vu9KvfQ.zlKiha1n2K jhELWZN38rxZdaIvMJ.2g61r.fWdsRedq.9iV7.yMEv9BQH4I517NnP8f6ei ZoYSfeHyMZWnv1AgKJdYTXZHzIBKp+QrOMn7Nft0OL.FDE2QQo9dhpBBveiX WutQ6RKprV8VOw+OYY8oZY4B81Ob07XPKxbGHZ1v0UvZN72HDS9aHK3lT9Cw c8+99ui+N718C12YCKIAf+88cpaeL6khE3NvBcsdvBzwvhr5xGXy.hYyT9iC gS5Vp155Xh88JN1pVHMcGi6UrMUczf+v.nY+pvrkAQfFTpMfd6uA9LWpU0F. TAMVwMf0qtiiZMgI8ffMrUWRcY8CqlG.VA8hBQQUls.bgOBFiIbqOSM9qNBC RrwqBTyBh8BbsL6ALz6U+J5BkY9gh2ZVvQTXrvcSW7plPu003ZbsapLZVlqE Dlc136X1neFCGSB9B4XlCaDhtpoC11BANkYnp84IFFeFuwAhHuHHx9zickiP jRDxXLbtBYOApQG1RtfXGGEL6jmrasumG.x84jpeoh4qoZhzLfYsUHl.VogL LLAvyVkvi4S3SaNlH3iz3RXZ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QEjCFi KHNYqO.VFYAkvplEjfkWznnWVCQuLdo50nHZX7PwbzkW1FDtwe.TdMDN6gHb XmqynpyfQtS0UhnUy6owGvj8bkDEMNwuzGjlY7ZzrL1jkqYM9.VqslQNVZLC WyFTnYh9UwfhfGLre4cEIlM61A8E3bolSCOrg0qyDts1N1ymvwK.d6+SWfHc c -----------end_max5_patcher-----------
Thanks! Sorry for the delay in responding – had a family emergency so I had to go out of town for a bit. Back now and working with your patch. I like your idea of handling each set of objects independently and then swapping the files. Seems to me then I really want to set everything up in just one of the subpatchers, then copy the file over to the other two. You mention JSON files in the patch’s comments. I assume you mean the .xml files that get generated by pattrstorage?
Assuming I get all that working, the remaining problem to solve would be to make everything dependent on the video names, since that is the independent variable that all the presets will be based on. (i.e. video1 needs this much tweaking, video2 needs that much, etc…) Is there some way that the video name can be the independent variable, rather than preset 1, 2, etc? If I had a complete list of videos that would never change, obviously I could just have the umenu items recall the preset numbers. However, this wouldn’t be flexible enough – we’ll need to be able to add and delete videos from the bins periodically, which would change the numbers output by umenu.
Otherwise, seems like I’d have to read from a hash someplace that contains keys/values as video name/preset #.
[coll] could be useful to deal with the names, they can be searched/indexed by symbol (video file name) and could output the right number. Will take some experimenting to get it right, depending on what you’re looking for…
I can’t find a way to write then read only one slot/preset of a [pattstorage] or [preset] object.
I really need this to compile presets from different [pattstorage] into a new one
Ref manual talks about adding a number before the file to load but the issue is I can’t find a way to store only one slot.
any help will be welcome ;-)
Ok, I found a way using the trusty [coll]
I really like this object :-)
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 1454.3oc2atsaipCEF95zmBKtqRYhv3CXlK1Ras2uEaMph.tszAvQfS6jNZd 229.jPZS3zjgR5MIMb72e92qk8B5OuYgyZwO3kNfuB9OvhE+7lEKLaRugEU+ dgSV3OhRCKMGlSjHKimKcVZ2mj+CoY63aAk77Xf7QNHRjKUGCPJL+bSnTVTJ EEgOvqOuzjbdjXat4j8p1n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vPt684TZVJxiNjSNSVh0eaKJ.Z3F7oHuR0l0CXaXrcJSERuUOU J16R5YX0MgEJgpViyc77v0o7FKtPcMrnqIjbMkizrBOiGy8v.jnzD0RnNxUR o5GXRf5TfTMTwL7gi2bqSxSjYhXdyH60M8Bwq77taBOTv4w6L.Z7iHOWwJeo HQ1iztd1LDX7fqTIYdNYjQ9rnPA1BVO5mEE85BGcrFGnsTZdDViUANDbf+bU G6ygwnTdXQ21JeawHGCGYWW9JgZsPsvCh8Ii4aqwvX3QvmpwYd1pO5SbGIOH dWW73knTQYa4kpJqhO0RD+ASDzUlC40ztBh.su4FrpWkfg+PEYWYHoq4tT8R Uf8CF4bWfnqhrSliw7VG7lWjLCSza+X3VJ1VDUeGpeAY.GTQrZh2I4lWQkFG jt9IMNnGShi44MqUeVR7FgZoQUh3Lqtu2ZBM+zjNJ5rSSv4mlzYemcZhMC0D tGZBNs1oYmhnyNEglg1as6F1gjHSKl5SfIBZZc2ndfI1zFCvuO8bzoES8YLG 6XgOIbpKM4Os1IeTe4zDqI37RSr9z2wl1wcr9Le.JYZ0Tv7yOoeEI61OEL8Z pyTKdSql5yb4B7led7tlTvQKjMfh8coG9OT33ku9F0iPvUjkf.Fx9FMfe+uP 1m1rG6vuNpMq9wut4+UIt5jJ -----------end_max5_patcher-----------
Actually, uebergeek, you shouldn’t give up so quickly on umenu. In the umenu inspector Items tab, check the ‘Pattr Stores Symbol’ checkbox (I think this is also umenu’s pattrmode attribute), and from then on pattrstorage will keep track of the current umenu item name (instead of the number), so that you can add & delete videos without worrying about their numerical order.
Before I discovered this, I wasted too many hours building an ingenious workaround – I hope I can save you from a similar fate.
Thanks all! Thanks pseudostereo for the info on umenu! Didn’t know that.. But can that solve the problem of making the umenu the dependent variable, so to speak? I.e., being able to call up the presets by video name, rather than preset number? The idea is to be able to select the videos by name and have the patch know what settings go with it. Otherwise, during performances, we’d have to somehow lookup which video is number 1, 2, 3, 25, 26, 27 so we can call it up by the preset.
I know I’m very late to the party, but I pasted your suggest patch into my own and it is unable to recognise any objects other than the three (dial, textedit, float) you have in your example.
Is this because any object you want the coll object to write / read you have to use a special scripting name? If so, where have you defined the scripting names?
Forums > MaxMSP