I've not personally tested this patch but that sounds like a very useful
addition to me so I hope to try it shortly and hopefully see it work and
get adopted by LS.

Dan

On Sun, Jan 22, 2012 at 11:09 PM, Frank Neumann <beachn...@web.de> wrote:

>
> Hi all,
>
> I came across the following problem: On my harddisk, there are lots of
> sample
> collections I grabbed from the web, and I have started writing small .sfz
> files to use them in LinuxSampler.
>
> By nature, those .sfz files would reside "near" the samples (like, in a
> parent
> directory), but this means that the .sfz's are just as wide-spread across
> my
> disk as the samples are. Rather than that, I wanted to have a single
> directory
> where I can store all of them - or at least my favourites. So, the idea is
> to:
>
> - Have the samples e.g. in directory very/deep/path/samples/
> - Have the .sfz file in the parent, e.g. very/deep/path/collection.sfz
> - Have a modified version of that collection.sfz (called
> collection_abs.sfz)
>  that uses absolute instead of relative references to the file names
>  To get that, I cooked up a tiny C program that converts all "sample="
>  references in a .sfz file to their absolute path name; of course, this is
>  local to my system, so I have to keep the "relative" versions around.
> - Have all my sfz's in one place, like ~/SFZfiles
>  -> Since I do not want multiple copies of the same files, I make these
>     as symlinks to the actual SFZ files
>
> Now, if I try to open such an "absolutified" sfz from its linked location,
> LinuxSampler cannot open them since by default it will prepend the current
> directory (which would in this case be ~/SFZfiles) to the file name.
>
> I looked at the sources, and found the code in
> linuxsampler/src/engines/sfz/sfz.cpp (line 1275ff):
>
>        if ("sample" == key)
>        {
>            std::string path = default_path + value;
>            #ifndef WIN32
>            for (int i = 0; i < path.length(); i++) if( path[i] == '\\')
> path[i] = '/';
>            #endif
>            path = currentDir + LinuxSampler::File::DirSeparator + path; //
> TODO: check for absolute path
>
>            if(pCurDef) pCurDef->sample = path;
>            return;
>
> (aha, so the comment there tells me someone has already been thinking about
> this! :-)
>
> I tried this trivial diff:
> --- sfz.cpp.orig        2012-01-22 22:52:01.000000000 +0100
> +++ sfz.cpp     2012-01-23 00:03:16.000000000 +0100
> @@ -1278,7 +1278,8 @@
>             #ifndef WIN32
>             for (int i = 0; i < path.length(); i++) if( path[i] == '\\')
> path[i] = '/';
>             #endif
> -            path = currentDir + LinuxSampler::File::DirSeparator + path;
> // TODO: check for absolute path
> +            if (path[0] != '/')    /* only prepend currentDir if path is
> non-absolute */
> +                   path = currentDir + LinuxSampler::File::DirSeparator +
> path; // TODO: check for absolute path
>
>             if(pCurDef) pCurDef->sample = path;
>             return;
>
> and, well, "it works for me" (under Linux only, of course).
> If this or something even more portable can be applied to the svn tree, I'd
> be very grateful.
>
> Greetings,
> Frank
>
>
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> Linuxsampler-devel mailing list
> Linuxsampler-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel
>
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel

Reply via email to