Massconverter For Collections Of Multisampled Instruments

I have a bunch of multisampled instruments (among them the NI Maschine library) on my harddrive that never really gets used, and turning all of them into fully mapped renoise instruments one-by-one would probably give me RSI.

I didn’t find an existing tool to do all this massconversion for me (and I sort-of wanted to do this myself), so this weekend I wrote a python tool that does just that. I’m posting it here in case someone else might find use for it.

Most of the samples in my collection are WAVs, which causes most instruments waste more disk space than necessary. So I threw together another tool that attempts to shrink an instrument by recompressing its samples (requires the flac encoder). My instrument collection shrunk by 55%, but your milage may vary. This tool will not work for all existing instruments (yet), but it should work for all instrument created with massconverter.

These tools are only tested on Windows, but they should work on any platform.

And a final note: there are probably bugs lurking about (it’s just a quick hack afterall), tell me if you find a show stopper. :)

Source: bitbucket-repository (zip)

Example usage doing both mass conversion and instrument shrinking (flags are explained in the readme below):

# -c "D:\Samples\Maschine" "D:\Samples\Renoise\Converted"  
<locates samples in the first folder and put instruments second><br>
# -m "D:\Samples\Renoise\Converted" "D:\Samples\Renoise\Converted-and-shrunken"<br>
 <locates instruments in the first folder and puts shrunken ones second><br>


What is this?<br>
This is a python tool that converts organized note-annotated samples into note-mapped renoise<br>
It can handle wav-files without any external dependencies (other than python), and flac support<br>
can be added by installing the mutagen library:<br>
Also included is a script that attempts to shrink the filesize of a renoise instrument by<br>
recompressing the audiosamples within. This is mainly useful when you have converted a bunch of<br>
wav-samples, and you dont want to open up each of them in renoise and re-saving.<br>
This tool requires "flac" or "flac.exe" to be in the same directory, or in $PATH.<br>
How do I use the converter?<br>
usage syntax: [-h] [-m] [-c] sourcedir targetdir<br>
sourcedir: directory that will be scanned for instrument folders<br>
targetdir: directory where the xrni instruments will be created<br>
-m: look for multiple instruments within the same folder<br>
        Instruments/Flute A C4.wav<br>
                    Flute A F#4.wav<br>
                    Flute B C4.wav<br>
    Without this flag, each directory will be treated as a single instrument instrument<br>
        (and can have multiple samples mapped to the same key).<br>
-c: used when converting NI Maschine libraries<br>
    The flag tells harvester to skip some directories which speeds up the process,<br>
    and add some annotations to the instrument filenames.<br>
How do I use the instrument shrinker?<br>
usage syntax: [-h] [-m] source target<br>
source: file to shrink, or directory to scan<br>
target: target directory for shrunken instruments.<br>
-m: scan source directory and shrink all xrnis found.<br>
Additional notes:<br>
    The instrument naming isnt always solid, and how good the names turn out will depend on how<br>
    you name your directories and samples.<br>
    Assume running the converter on the following directory structure:<br>
            SourceDir/Violins/Rusty violin C4.wav<br>
                             /Rusty violin G4.wav<br>
    The instrument will be named: Violins-Rusty violin.xrni<br>
    The base note can be anywhere in the sample filename.<br>
    The tool isnt very fault-tolerant when it comes to finding files, and it assumes that all samples<br>
    has a "Name"-tag with a filename that exists.<br>
    Otherwise it will try to load a nonexisting file and crash.<br>

[b]Edit: [/b] updated zip-file and readme.</locates></locates>

Does the base note, eg C4, always have to be at the end of the original sample filename or will it find it wherever it is in the string? Looks a great tool though! Could it not have been done as an integrated, LUA Tool?

Good point - currently it has to be at the end of the filename, but I think finding it wherever is an easy fix. I’ll look into it today.

Edit: It should now be able to find the base note wherever. It does in my small pool of test cases anyway.

Probably! I simply used the language I’m most comfortable with. :)

Just a heads up,

The lines above, 373 - 378, introduce a bug whereby notes with flats will be incorrectly converted.

I’d recommend deleting this short block as it’s kind of unnecessary anyway. I was going to submit a pull request but you’re using bitbucket and not github :stuck_out_tongue:

It looks like xrniharvester can generate xrni files that crash Renoise. I filed a bug report with Renoise about it, and the response was:

The sample keyzone ranges are broken in the
converted instrument. Renoise’s maximum value for keyzones, notes in
general, is 119 and not 127 as it is in the MIDI standard. This is a bit
ugly, but has its roots in the pattern editor notation, B-9 being the last
possible note that can be entered into the pattern.

We do not “fix” imported XRNI data, our native format, in general before
importing it. So if the input data is broken, it’s quite likely that
something strange happens or that it’s crashing sooner or later. So I’d
recommend to fill in a bug report for xrniharvester to limit notes to 119.

Alternatively, the tool also could simply create SFZ files too, which could
then be used in other applications too. Also when importing SFZ files,
Renoise also will take care of necessary validations.

Attached is a zip file containing a directory named “synth” with a couple of wav files. When this directory is passed through xrniharvester as “./ synth .” it will generate an xrni file which, when loaded up in to Renoise 3.1.0b4 on Linux amd64, will crash it when you open up the sample editor.