• Profile picture of Karim
  • Profile picture of Jean


Groupe Public active 20 hours et 31 minutes ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

get the pathname of the using om patch

Auteur 3 Utilisateurs souscrits |
Profile photo of JialinLiu

Dear friends,

I would like to know, with which function or global variable could I get the pathname of the using om-patch within this patch?
In lisp-editor it is the global variable ” *load-pathname* “, but it will return nil, if I put it into a function located in OpenMusic patch.

Thank you for the help in advance!

Best regards,

Juillet 29, 2018 à 09:05 #27295
Profile photo of anders

Hi Jialin.

I don’t know of any ready method which returns the pathname of the current patch.
But you can call mypathname on the ‘obj slot of the current window (om-front-window):

(defun this-patch-pathname ()
    (mypathname (obj (om-front-window))))


Juillet 29, 2018 à 10:17 #27296
Profile photo of Jean

This will give you the pathname of the front-most patch window, but not necessarily of the patch that is being executed…

I don’t see a way to get the pathname without significant hacking of the patch eval/compilation methods.

Just curiosity: what do you need it for ?

Juillet 30, 2018 à 08:07 #27298
Profile photo of JialinLiu

Hello Anders,

Thanks a lot for the great solution! I have tried and it can do the job very well in my case.
I will check and learn the code for window later.

All the best,

Juillet 31, 2018 à 04:26 #27334
Profile photo of JialinLiu

Hello Jean,

Thank you for the reply and the information. In my libraries or patches, I usually generate a database with a huge amount of tiny files, and work with them later. Every time when I change my directories, or render files with another computer, or send it to another friend, I need to find and choose the directories again, it takes time to find the correct folders and let it run correctly.
So I would like to generate the database directly near the patch folder (or somehow related to the patch folder) and later, read and write the files directly from and into the folder.

Another thing is that when we import some of library tutorials, or several patches and files together, which are related to each other, there could be many files or pictures, which can not be loaded, and we need to find and load it manually.

I don’t know if there is way to avoid this situation, do you have some suggestion or idea?

Thank you again for the help!

All the best,

Juillet 31, 2018 à 04:27 #27335
Profile photo of Jean

In principle the patch file contains in its header the list of all ressources in it (sounds, pictures etc.) along with corresponding relative pathnames.
This should help retrieving these ressource files using relative location on the disk, but it is not much used at the moment with OM’s workspace-based document management: ressources are more supposed to be stored in the in-file/out-file and other subfolders of the workspace.
So I guess Anders’ solution is your way to go for the moment :)
Good luck !

Juillet 31, 2018 à 08:05 #27343
Profile photo of JialinLiu

Yes! Many thanks for the information about retrieving the resource, it is very helpful!
I am now also considering generating the files directly into a sub-directory of the in-file folder.

Jialin Liu

Août 2, 2018 à 00:04 #27367

Vous devez être connecté pour répondre à ce sujet.

Log in now