Sample compression in XRNS files

Songs take less space in Renoise 1.8 than they would have in 1.5 and before. That is because the samples inside the songs are being compressed. Renoise uses lossless compression: once decompressed, the original samples are restored without any loss of quality. One of Renoise 1.8's best kept secrets may be the possibility to manually replace lossless samples with smaller, lossy ones. Lossy compression allows you to bring an 35 MB song back to 2 MB without degrading sound quality too much. I will go against the natural direction of writing articles by starting with the how-to and explaining what compression is afterwards.

Note: there are now tools to compress XRNS files with Vorbis automatically.

XRNIRipper - Java program

XRNS-OGG - PHP script with Windows GUI

Still, in some cases it pays off to compress the samples manually as described below. That way you can adjust the individual compression ratio or even leave some samples in FLAC format.

Replacing samples in XRNS files

We will be compressing samples with OGG VORBIS. On Windows you can use OggDropXPd to convert WAV or FLAC files. All you need to do is drag the samples onto its tiny window. Unfortunately you cannot drop complete folders. Check Vorbis for other converters.
  1. First make a backup copy of the song. You should always keep a lossless version. Lossless backup
  2. Take the samples from the XRNS file. Use a data compression utility capable of ZIP compression. WinRAR is a good choice. Open the XRNS file with the utility. Extract the "SampleData" folder to your harddisk. Extract SampleData
  3. Search the SampleData folder for *.flac or *.wav. Drag and drop the files from the search results onto OggDropXPd to convert them to OGG VORBIS. Each converted sample is stored in the corresponding input folder. Convert samples to OGG
  4. Remove the *.flac or *.wav samples from the SampleData folder. Again, use the search results wisely. If you are sure you don't need the original samples anymore delete them, otherwise copy them to a different folder. Remove original samples
  5. Delete the old SampleData folder from the XRNS archive. Delete SampleData folder from XRNS
  6. Add the modified SampleData folder to the XRNS archive. Do not apply ZIP compression, because the samples are already compressed well enough. Add SampleData folder to XRNS
  7. Load the song in Renoise to check if the conversion went alright. Check the edited XRNS

Tips

  • Renoise deliberately only exports samples with lossless compression. If you save a song that has OGG samples to a new file, all samples are converted to FLAC or WAV. Note that converting from lossy to lossless will not increase the quality.
  • Be careful with lossy formats. At all times, keep a lossless version.
  • You can decide to convert a few selected samples to a lossy format. There is little to gain from compressing small files. In fact, it is better you leave those intact. Concentrate on shrinking the larger files instead.
  • If you are going to replace single files: remember to add the compressed sample to the archive before deleting the original sample. WinRAR removes the folder in the archive once it becomes empty. Explanation: in reality there are no folders, only files tagged with output folder names.
  • Some sounds do not respond well to being compressed. One method is to convert all the samples, then replace bad sounding samples with the original ones. You could also try to redo the compression for specific samples with a lower compression ratio.
  • FLAC handles 32-bit samples pretty poorly by design. OGG VORBIS on the other hand produces near constant filesizes, regardless of the source being 32-bit 96 kHz Stereo or 16-bit 44 kHz Mono. The latter would only be about 10% smaller. Depending on the Q setting, the higher frequencies appear to be thrown away automatically.
  • Assign a data compression utility to XRNS files, so you can easily open them from the context menu.

What is compression?

Compression is about making files smaller. There are two forms of compression: lossy and lossless. To turn a compressed file into a playable or editable stream, there is a penalty involved compared to uncompressed files: either you have to wait a while or your computer needs to work harder.

Uncompressed

Analog audio is digitized to make it storable on for example harddisks. An uncompressed file offers the highest quality and the highest performance, but also takes the most space. Usually we talk about PCM, wrapped in a container like WAV or AIFF. You can make Renoise store uncompressed WAVs by going to Preferences > Im/Export. From the Sample Format dropdown list, choose WAV (uncompressed).

Lossy compression

Lossy compression cuts away data. It is not possible to restore a lossy compressed file to its original state. The trick is to throw away as much data as possible, while keeping the compressed file recognizable. You have to be careful with lossy compression if you start using it for songs. Imagine, you edit a lossy sample and save the result again with lossy compression. Repeat it a couple of times: eventually all that is left is poo. MP3 takes advantage of the human ear not being equally sensitive to all frequencies. On very high levels of MP3 compression it generally sounds bubbly and muffled, as if played underwater. OGG VORBIS has a smarter algorithm, which allows you to decrease the filesize to a level at which MP3 would sound like a dog in a washing machine. Shrinking an uncompressed file by 80 to 90% is not unthinkable.

Lossless compression

Renoise stores samples in a lossless format, either GZIP'ed WAV or FLAC. Once decoded, the compressed file matches the original uncompressed file. You can switch to formats by going to Preferences > Im/Export. From the Sample Format dropdown list, choose WAV (gzip) or FLAC. FLAC is optimized for cd audio (16-bit, 44.1 kHz) and has the generally the best compression ratio. Its encoding/decoding speed is close to that of WAV files. You probably need to convert FLAC back to WAV if you want to edit the files in an audio editor. Since the algorithm is based on linear prediction of the source material, the compression ratio varies between 30 to 50%. GZIP'ed WAV is exactly what it says: the WAV samples are simply wrapped and compressed with GZIP. You can easily extract the raw WAVs to load in other applications. Performance-wise though, it is surpassed by FLAC in both speed and compression ratio.

Containers

Often misunderstood for being types of compression, OGG and WAV are actually containers for data. They allow for extra functionality, but do not alter the actual data. Usually WAV is a container for PCM audio, but it is also possible to wrap a WAV around MP3 compressed audio. In a similar way, OGG is a wrapper for usually VORBIS compressed audio.
Category: 

4 comments

hey, great article, but it would be nice to know at least the names of similar softwares for osx,(that can do the thing the same way) i any body knows! thx
WinRAR is, despite its name, also available on MacOSX, so you must be referring to the OGG encoder. Did you check out the programs from the Vorbis page? <a href="http://www.vorbis.com/software/#macosx" rel="nofollow">http://www.vorbis.com/software/#macosx</a> <a href="http://nouturn.com/oggdrop/" rel="nofollow">Ogg Drop for MacOS</a> can batch convert stereo AIFF samples to OGG. You might also try <a href="http://www.xiph.org/quicktime/" rel="nofollow">XiphQT</a> to add OGG support in QuickTime applications.
yeah, thanx, tried ogg drop now, the only problem is that as far as i can see doesnt have the possibiliy of outputtin the ogg to the original folder, which i a quite essensial feature if you dont want to reconstruct the sampledata folder... i dunno, guess it is possible, just takes more work in osx(maybe i should borrow a windows computer...)
Instead of doing it manually, you can now easily convert XRNS songs with the XRNS-OGG script from the <a href="http://xrns-php.sourceforge.net/" rel="nofollow">XRNS-PHP</a> project.
wurst