URGENT HELP NEEDED! Stadalone search paths

    MaxMSPresolved

    Andy Maskell
    Nov 08 2022 | 12:20 pm
    Help!!!!
    I am trying to write a standalone app called Nudger for somebody in a different country whose setup I have no details for and who does not have Max or enough tech knowledge to play with it. It's a very simple tool that converts control message coming from one port into note messages sent to another port and all unmodified message to a third port that can then be used in Cubase to control various jog wheel functions from an X-Touch controller. All that works fine.
    In order to ensure that the MIDI configuration matches his system, I have provided picker lists to ensure that the MIDI messages are being read from and then sent to the correct ports. Again, all that works fine.
    However, in order to save him having to re-enter the configuration every time he uses the app, I am trying to store the three port configurations using a coll with a read process to load the coll data when the app starts and to write the coll everytime the port selctions are changed. Again, that works in the patcher but not in the standalone!
    I have three problems:
    1) I assumed that the executable (the Nudger.exe file) would operate entirely on its own but I am now concluding that I need to include the collective (the Nudger.mxf) and its resource folder when I send it to him. Is that correct or not?
    2) No matter what I try, the executable is reading the configuration file (Ports.txt) into the coll from the resource/support folder but when I write the data back, it always goes to another copy of the Ports.txt folder in the same directory as the executable. How can I resolve this such that the executable uses the same file for both reading and writing?
    3) Is it not possible to embed the coll and its data in the patch so that it doesn't need to be read from a file at all? Again, this works in the patcher but not in the standalone.
    In the attached patch, I have put a red box to indicate the bit of code that has the problem.
    Urgent assistance with this would be greatly appreciated!
    Max Patcher
    In Max, select New From Clipboard.
    Show Text

    • Source Audio's icon
      Source Audio
      Nov 08 2022 | 12:47 pm
      Hi Andy,
      the 100 % solution is to use absolute path to Ports.txt file.
      you use path message to this patcher to use that as path while editing in max,but ; max senapppath message to get path to standalone exe file. Assuming that you want it to read/write next to patch or exe file.
      Give me a minute, I'll post a patch demonstrating that, there were many posts here dealing with same thing.
      Share
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Nov 08 2022 | 12:54 pm
      hope it works
      Max Patcher
      In Max, select New From Clipboard.
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Nov 08 2022 | 1:03 pm
      sorry, I was too short in reading and missed your other questions.
      Standalone that you send must be complete. Means folder with exe file + mxf + all resources . in some cases one has to copy vb runtime dlls into it.
      If midi configuration always remains unchanged, you can simply loadbang port messages to midi objects, needs no coll at all. By the way, embedded coll is stored into mxf same as in the patch, but unchangeable, once compiled into mxf.
      As it takes some time to load all ports, depending what else is running on app start, I would add some delay before reading Ports.txt file.
      I am sure you remember that one can set midiport as exclusive for midi I/O objects
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Nov 08 2022 | 1:11 pm
      P.S.
      this is what I would enter in standalone inspector
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Nov 08 2022 | 1:26 pm
      Thanks and thanks again @SourceAudio. There's a lot to digest there but I'm hopeful that your ideas will work.
      Yes, I realise now that the standalone .exe file is simply the Max Runtime module and that the actual code comes from the .mxf file and the resouce folder. Not ideal when you want to send just one file to do all the work but, hey ho! I'm wondering if there is tool that creates a truely standalone, compiled and linked executable from Max code in a single file, like I was used to in my Fortran/Pascal days? I get what you are saying about embedded colls - it was what I suspected, thus having to read and write the config to something external. I have no idea what MIDI ports he has in his sytem and I can't assume they won't change. Hence why I went for the picker lists and an initialisation sequence that ensures all the Max midi ports are disabled before I start (bottom left in my patch). I have put some delays in at the initialisation stage to try to see if that fixed the problem but it didn't make any difference. The whole thing only runs through a single presentation window that shows the port configuration menus. The code that actually does the task of converting and separating the MIDI messages is tiny (bottom right of my patch). Anyway, I will have a look at your suggestion and see if I can get that to work now.
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Nov 08 2022 | 1:35 pm
      @SourceAudio - thanks again. I can see what your patch is doing - except, what is the symout argument in the sprintf command - I've not come across that one before?
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Nov 08 2022 | 1:40 pm
      Hi Andy, yes it is possible to make a single exe file, but not from max itself.
      I use enigmavb exe packer, which is freeware, to do so. I am not at home, have only mac with me, so can't upload any windows resources. It is a very simple procedure, most work actually is to trim standalone down to include all needed files, but nothing else, to reduce the size.
      When I come back home in few days, I'll be able to upload or send any infos needed. ---------- About disabling midi ports till correct ones are selected ... ? Correct ports are the ones your user has to select in popup menu, and then store them into coll. On loadbang, it is enough to keep gates to all midi ports closed, till coll dump with all stored ports finds corresponding symbol(s) in the menu, which then opens the gate upon setting the port. Manual selection in menu also opens the gate, route menu symbol output to t 1 s trigger 1 (for gate) symbol for port
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Nov 08 2022 | 2:22 pm
      Your idea works perfectly thanks! I'll have a look at enigmavb - it looks interesting. The problem with Windows is that not all MIDI drivers are multi-client - in fact very few are in my experience. It means that if Max is sitting on them then other apps can't connect to them. It's a real pain sometimes. As I'm not able to see what happens at his end, I'm having to cover all bases and make sure that Max doesn't inadvertantly stamp on his system, hence the decision to ensure that Max diables its own access to all the MIDI ports and then only activate the ones he chooses to use. In fact, thinking about it, I ought to disable any previously selected port when the picker list changes!
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Nov 08 2022 | 5:10 pm
      glad it worked, at least the part with path etc I guess. Windows limitations with midi and audio drivers use between applications is really a big problem. I am not sure if disabling midi ports in Max does free them for other applications, never tested that being Mac user ... I will post some settings of enigmavb as soon as I come back.
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Nov 08 2022 | 10:08 pm
      symout in sprintf outputs string as symbol, in case there are any spaces. Same as inserting tosymbol at output. ----
      Disabling all but selected midi out ports might get tricky because you use 2 output menu objects. One could loadbang - disable all, then read coll for saved ports, enable them if matching ports are found in the menus. Manual selection for input - no problem
      But you can't do it same way for 2 output ports. I would suggest to select all midi ports and execute all using button which would set ports and store Ports.txt file.
      Max Patcher
      In Max, select New From Clipboard.
    • Andy Maskell's icon
      Andy Maskell's icon
      Andy Maskell
      Nov 09 2022 | 10:53 am
      It's Ok, I have that covered. On startup, a loadbang disables all the ports in Max and then when the config is read into the coll it enables those ports it finds. As the config file only ever contains the names of ports that are listed in Max at the time they are chosen, it is unlikely to fail. In the event that a port is removed or the name changed externally, Max will simply select the first port in the list by default. I suppose I could be clever and compare the name in the config file and the name in picker and if they don't match, colour the picker red to indicate that it needs a new selection.
    • Guillaume 's icon
      Guillaume 's icon
      Guillaume
      Mar 23 2023 | 9:34 am
      Hi ! I read in this topic that it is possible to make a single exe file with enigmavb (@source audio). I try to use the sofware but when I launch the packed exe., only the max runtime open as if it didn't have embedded the mxf file. would you be able to explain to me how proceed with enigmavb ? Thanks !
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Mar 23 2023 | 11:20 am
      https://cycling74.com/forums/fyi-successfully-protected-a-standalone-max-app-on-pc
      instructions posted
      Mar 07 2016 | 5:21 pm
    • Guillaume 's icon
      Guillaume 's icon
      Guillaume
      Mar 23 2023 | 3:01 pm
      Perfect ! Thanks a lot