On Fri, 2012-07-27 at 23:04 -0400, David Robillard wrote:
> On Fri, 2012-07-20 at 16:46 +0200, Gabbe Nord wrote:
> > Hello!
> > 
> > I'm using the LV2-plugin for Linuxsampler alot with ardour (3,
> > svn-version) and an issue i've been having for quite a while now is
> > that it does not reload the sample-files it should correctly upon
> > session startup.
> > For example, the terminal displays this when loading a session:
> > 
> > Scheduling
> > '/home/zth/MUSIK/WhatProjekt/simpleBeat/plugins/401/state8/DecayBass.sfz' 
> > (Index=0) to be loaded in background (if not loaded yet).
> > Loading sfz instrument
> > ('/home/zth/MUSIK/WhatProjekt/simpleBeat/plugins/401/state8/DecayBass.sfz',0)...OK
> > Caching initial samples...sfz::Engine error: Failed to load
> > instrument,
> > cause: 
> > /home/zth/MUSIK/WhatProjekt/simpleBeat/plugins/401/state8/DecayBass.wav: 
> > Can't get sample info: System error : No such file or directory.
[...]
> Long story short, SFZ (or any multi-file format) in LV2 doesn't work
> across saves.

Attached is a patch to resolve this issue.

LinuxSampler LV2 state is still not archivable, and multi-file .gig will
still not work, but SFZ should save and restore correctly at least.

It would perhaps be a good idea to move this fix lower to the SFZ engine
so loading from a symbolic link path always works.

Patch also available online here:
http://drobilla.net/files/linuxsampler_lv2_sfz_fix.diff

Cheers,

-dr

Index: src/hostplugins/lv2/PluginLv2.cpp
===================================================================
--- src/hostplugins/lv2/PluginLv2.cpp	(revision 2359)
+++ src/hostplugins/lv2/PluginLv2.cpp	(working copy)
@@ -18,6 +18,8 @@
  *   MA  02110-1301  USA                                                   *
  ***************************************************************************/
 
+#define _BSD_SOURCE 1  /* for realpath() */
+
 #include <algorithm>
 #include <cassert>
 #include <cstdio>
@@ -118,6 +120,23 @@
         dmsg(2, ("linuxsampler: Deactivate\n"));
     }
 
+    static String RealPath(const String& path)
+    {
+        String out   = path;
+        char*  cpath = NULL;
+#ifdef _WIN32
+        cpath = (char*)malloc(MAX_PATH);
+        GetFullPathName(path.c_str(), MAX_PATH, cpath, NULL);
+#else
+        cpath = realpath(path.c_str(), NULL);
+#endif
+        if (cpath) {
+            out = cpath;
+            free(cpath);
+        }
+        return out;
+    }
+
     String PluginLv2::PathToState(const String& path) {
         if (MapPath) {
             char* cstr = MapPath->abstract_path(MapPath->handle, path.c_str());
@@ -131,9 +150,10 @@
     String PluginLv2::PathFromState(const String& path) {
         if (MapPath) {
             char* cstr = MapPath->absolute_path(MapPath->handle, path.c_str());
-            const String abstract_path(cstr);
+            // Resolve symbolic links so SFZ sample paths load correctly
+            const String absolute_path(RealPath(cstr));
             free(cstr);
-            return abstract_path;
+            return absolute_path;
         }
         return path;
     }

Attachment: signature.asc
Description: This is a digitally signed message part

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel

Reply via email to