rncbc / samplv1

samplv1 - an old-school polyphonic sampler
https://samplv1.sourceforge.io
GNU General Public License v2.0
38 stars 9 forks source link

Use absolute rather than relative paths for samples #36

Closed srithon closed 1 year ago

srithon commented 3 years ago

When I load saved presets in samplv1, the application and my DAW crash. I looked at the saved preset file and noticed that the tag used a path relative to the current directory rather than an absolute path. Changing this to an absolute path (starting from the root directory) fixed the crash. However, after making changes and overwriting the preset, the relative path returns. Could we have an option to use absolute paths when saving presets? I understand that for users with project-local samples, relative paths may be more useful so that the project itself can be moved without breaking the sampler. However, for people who use sample packs and do not duplicate samples into their projects, using absolute paths would be better. Also, using absolute paths means that we don't have to rely on the current directory, which can change between instances.

This is an extreme example of what I'm describing

<filename>../../../../../home/username/Music/Samples/Hi Hat.wav</filename>

vs.

<filename>/home/username/Music/Samples/Hi Hat.wav</filename>
rncbc commented 3 years ago

the stored path is relative to the directory where the *.samplv1 was first saved--not the current directory whatever it is at runtime (host).

simply told: you're here advised to NOT MOVE any *.samplv1 files around your file-system; always keep them on it's original location, where they were first saved;

exception to this rule is when the sample file and the .samplv1 preset file (that refers to it) are stored on the very same folder: in that case you may well move both files around without issues (remember that this is also the rule for .sfz files too although you must obey to it at all times;)

srithon commented 3 years ago

@rncbc Thanks for the clarification!

I didn't move the *.samplv1 files after writing them, but the crash still persisted until I replaced the path with an absolute path. One thing that might be relevant is that my ~/Music folder is a symlink to /pool/ROOT/music. This could be causing the wide string of ..'s in the original filename.

My theory for the crash is that it's attempting to apply the relative path from the preset's real path to the preset's symlink path, but I'm not so sure. This would mean applying ../../../../../home/username/Music/Samples/Hi Hat.wav to /home/username/Music/DAW/Project/' rather than /pool/ROOT/music/DAW/Project/, but I believe in this case the Music directory has the same depth from the symlink and the realpath, so this would not be a problem.

Do you have any ideas on what could be causing the crash? It's entirely possible that I'm mislabelling what happened, so I apologize in advance.

rncbc commented 3 years ago

no clue whatsoever about the crash... you'll have to try something else (like saving the .samplv1 files on the same or on a non-symlinked file-system tree and check to be sure it doesn't crash in that manner

otherwise, you'll probably have to run the whole show under gdb and catch a stack-backtrace to locate the culprit (where and what is causing the crash).

srithon commented 3 years ago

Thanks for the ideas! I'll let you know if I find anything.