A couple standalone application questions...

Rodrigo's icon

I've been building a dynamic score system for use over a local network, and it's finally ready to get used. In order to facilitate deployment I'm going with a standalone app as there are a few dependencies (using Bach externals, which are also dependent on fonts).

Making an app gets all the Bach stuff in order, and I found a plist attribute that lets you define a local font folder (inside the application itself), so it's fully standalone at the moment, which is great.

Now I've been using Dan Nigrins amazing tutorial for making standalone apps:

But between all the steps required there, and the steps required to have the fonts be local, it's a bit time consuming to produce a new version every time I change one of the core files. I've built it so the display/rendering engine is separate from everything else to avoid problems like this, but it's still early days, so I am still working the files a bit.

So I have a few kind of advanced standalone app questions.

1) If nothing else changes (in terms of externals/dependencies), can I just save the patch as a new collective file, and place it inside the /Contents folder as a .mxf with the same name? (to avoid having to do all the grooming steps mentioned above)

2) Is it possible to declare a local assets folder, or a place for the files to look for files that are needed? Basically image/text files that are part of the composition the system will be displaying. It would be great if I can just throw all the required images into the /Resources folder, and have them show up when referenced in the patch as local files. OR, do you declare a folder structure for the file location like /Resources/1.jpg when referring to them inside Max?

3) If I have a settings.txt file, that contains each performers information, can that be placed in the /Resources folder too? Can I edit/change/replace it in there after the fact?

Rodrigo's icon

Ok, after some testing, I figured out answers to the questions, so for forum search-ability, here is what I know!

1) You can export a new collective, and just drop it in the /Contents folder and it works fine. I just launching the application just refers to that file. I don't know if this will work once updating to a new Max/build engine or what, but in my brief tests, it was fully functional.

2) It seems like the /Resources folder is treated as the top level directory as far as the patch goes. Anything that is referred to with just a local file name (read file.wav, etc..) loads perfectly from the /Resources folder. You can add whatever you want to it, and it acts fine.

3) This applies to a settings.txt file, or any dependencies that aren't abstractions/externals. Just stick them in /Resources, and you're good to go!

I am now having a osc port issue as Max seems unhappy about having an application AND max being on the same port.

Mike S's icon

Hi Rodrigo,

I'm trying to read/write a text (.txt) file as a preference file from a standalone application.

Do you know how to specify where to read/write from once the standalone application is built?

Currently it is writing a file to the directory the application resides in, which isn't what I want.

Rodrigo's icon

Yeah, if you put it in /Contents/Resources, it shows up as 'root level' (ie, you can just refer to it).

Oh wait, I misunderstood your question I think.

Mike S's icon

inlets = 1;
outlets = 2;
autowatch = 1;

function address(app_path)
{
outlet(0, app_path + "your_app_name_here.app/Contents/Resources/the_nane_of_your_pref_file.txt");
}

Absolute head in hands business as usual!

The above JS takes the app path and spits out a path that you can prepend with 'read' or 'write' to read and write the text file, using the [text] object.

Not sure if this works on Windoze?!

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

Max patch below finds the app path..