saving parameter settings in standalone app

Stef Haynes's icon

Hi all, I'm creating a standalone app, and I'd like the user to be able to save all of their parameters (button states, integer values, slider positions, etc). What's the best way to do this when creating a standalone application? It would be great if the parameter settings could be automatically persisted after the app is closed and re-opened, but if they user needs to hit a "save" button, that would be fine too.

btw, all my UI objects are recognized by pattrstorage, and I can do this just fine when it's just a patcher, but none of the methods I've tried seem to work after I build it as a standalone application.

Any help is much appreciated!!

Source Audio's icon

All it need is correct path to write and read preset file.

I would suggest to pick location which is granted in most cases no matter which OS,

like user's documents folder.

you can use ~ as shortcut to user folder.

example :

write ~/Documents/MyApp_Presets.json

loadbang ~/Documents/MyApp_Presets.json

to absolutepath.

if found, read the file, and recall preset 1.

If not, use default values and store 1 , then

write file to start with.

I personally dislike any autostore - write options.

it fails anyway in most cases, unless you disable app quit

using shortcuts and menu, and use dedicated button

to first write settings and then quit app.

Stef Haynes's icon

Thanks very much!!

Source Audio's icon

P.S.

you can bundle messages into comma separated ones, like

store 1, write ~/Documents/Presets.json

or

read ~/Documents/Presets.json, 1

in most cases max objects follow such orders taking care that

functions proceed only when previous ones succeeded.

Nodanoma's icon

the best call is to always address the Preferences-folder of the user who installs your standalone. On both Windows and Mac these are always in the same location and all files stored there will be unaffected by removal of the application or a version update. On a Mac, for instance, this will be ~/Library/Application Support/[Application name]/. In this folder you can save a .json file from a dictionary, or preset files from [pattrstorage], etc. — and everything will be recalled regardless of what happened in the meantime to the standalone. Note, that the 'Application name' you need to specify as attribute to the [standalone] object @preffilename 'Application Name'. This will automatically create a folder with this name once the user first opens the standalone. In order to provide support for both Windows and Mac you will need to query the OS using [gestalt], for example and handle paths accordingly.

In fact, I am still building an entire stanlone wrapper which handles all these cumbersome nuisances in one object, including version changes, initalisation flags, Max preferences, paths to directories based on whether it is a standalone or not, automatic parameter saving, etc. etc. — it can get really involved very quickly. but first off, the Preferences Folder is what you want to address and manage. Should people express interest, I'll gladly share it for beta testing...

Source Audio's icon

Max settings folder on both operating systems is hidden to user.

one has to gain access to do anything manually there,

like to backup something or edit few lines.

not very convenient, at least not for someone that has no idea

about system structure and how to deal with unvisible files

or gain write privileges

Nodanoma's icon

On my system Max' preference folder is not hidden but accessible through

~/Library/Application Support/Cycling '74/Max 9/

and by default visible/accessible.

But even it were hidden, one could still access it and modify it through Max in many different ways.
So I am not sure what you mean ?

Source Audio's icon

don't worry, if you don't know what I mean, then it does not matter.

Stef Haynes's icon

Thanks you guys! I ended up going with the solution of storing the file inside the .app contents folder, as outlined here: https://cycling74.com/forums/pattrstorage-doesnt-overwrite-preset-files-in-standalone#reply-6752362084ea210012d78ff2

Nodanoma's icon

Yep, that you can do. Any new version or reinstall of the Standalone will ship with fresh settings though, user 'preferences' will not exist outside of the standalone and will not be recalled in this case.