Jump to content


Massconverter For Collections Of Multisampled Instruments

  • Please log in to reply
4 replies to this topic

#1 jonte


    New Member

  • Normal Members
  • Pip
  • 9 posts
  • Gender:Male
  • Location:Sweden

Posted 29 March 2012 - 01:06

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):
# harvester.py -c "D:\Samples\Maschine" "D:\Samples\Renoise\Converted"
 <locates samples in the first folder, and put the instruments in the second folder>

# xrnishrink.py -m "D:\Samples\Renoise\Converted" "D:\Samples\Renoise\Converted-and-shrunken"
 <locates instruments in the first folder, and puts the shrunken ones in the second folder>

What is this?
This is a python tool that converts organized note-annotated samples into note-mapped renoise

It can handle wav-files without any external dependencies (other than python), and flac support
can be added by installing the mutagen library: http://code.google.com/p/mutagen/

Also included is a script that attempts to shrink the filesize of a renoise instrument by
recompressing the audiosamples within. This is mainly useful when you have converted a bunch of
wav-samples, and you dont want to open up each of them in renoise and re-saving.
This tool requires "flac" or "flac.exe" to be in the same directory, or in $PATH.

How do I use the converter?
usage syntax: harvester.py [-h] [-m] [-c] sourcedir targetdir

sourcedir: directory that will be scanned for instrument folders
targetdir: directory where the xrni instruments will be created

-m: look for multiple instruments within the same folder
        Instruments/Flute A C4.wav
                    Flute A F#4.wav
                    Flute B C4.wav
    Without this flag, each directory will be treated as a single instrument instrument
        (and can have multiple samples mapped to the same key).

-c: used when converting NI Maschine libraries
    The flag tells harvester to skip some directories which speeds up the process,
    and add some annotations to the instrument filenames.

How do I use the instrument shrinker?
usage syntax: xrnishrink.py [-h] [-m] source target

source: file to shrink, or directory to scan
target: target directory for shrunken instruments.

-m: scan source directory and shrink all xrnis found.

Additional notes:
    The instrument naming isnt always solid, and how good the names turn out will depend on how
    you name your directories and samples.

    Assume running the converter on the following directory structure:
            SourceDir/Violins/Rusty violin C4.wav
                             /Rusty violin G4.wav

    The instrument will be named: Violins-Rusty violin.xrni

    The base note can be anywhere in the sample filename.

    The tool isnt very fault-tolerant when it comes to finding files, and it assumes that all samples
    has a "Name"-tag with a filename that exists.

    Otherwise it will try to load a nonexisting file and crash.

Edit: updated zip-file and readme.

Edited by jonte, 29 March 2012 - 13:22.

  • Conner_Bw and .xrns like this

#2 kazakore


    Probably More God or Borg Than Human Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6140 posts
  • Gender:Male

Posted 29 March 2012 - 09:12

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?

#3 jonte


    New Member

  • Normal Members
  • Pip
  • 9 posts
  • Gender:Male
  • Location:Sweden

Posted 29 March 2012 - 11:15

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?

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.

Could it not have been done as an integrated, LUA Tool?

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

Edited by jonte, 29 March 2012 - 13:21.

  • fladd likes this

#4 deathdisco



  • Normal Members
  • PipPip
  • 16 posts
  • Gender:Male

Posted 01 September 2015 - 10:58

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 :P

Edited by deathdisco, 01 September 2015 - 10:58.

#5 fugue



  • Normal Members
  • PipPip
  • 14 posts

Posted 21 November 2015 - 16:05

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 "./harvester.py 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.

Attached Files

Edited by fugue, 21 November 2015 - 16:09.