On 2012-01-23 00:09, Frank Neumann 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.

Thanks, I've committed this now (with an extra check on Windows).

/Andreas

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel

Reply via email to