Forums > MaxMSP

Using pattr to create portable presets

August 30, 2010 | 1:48 am

Hello,

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!


August 30, 2010 | 11:54 am

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. –

September 16, 2010 | 11:08 pm

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?

Part 2 of the puzzle – javascript?
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 #.
So: personeating.flv => 1 dogbarking.flv => 2 etc. Could do this in Perl… guess I could figure out how to do it in Javascript to put it into Max (though I haven’t done this before)… would that be what’s necessary?

Thanks again!


September 17, 2010 | 1:24 am

[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…


September 17, 2010 | 9:42 am

hi,

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 ;-)

thanks

olivier


September 17, 2010 | 3:21 pm

Ok, I found a way using the trusty [coll]
I really like this object :-)

– Pasted Max Patch, click to expand. –

September 17, 2010 | 10:35 pm

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.


September 18, 2010 | 12:39 am

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.

Thanks again!


Viewing 8 posts - 1 through 8 (of 8 total)