# 9 ways to NRT, part 5: Generating Milkytracker files with NRT
Welcome to Part 5 of 9 Ways to NRT
Today, NRT will be used to generate XM files, which are the native file format for the fasttracker 2 inspired music tracker Milkytracker.
The main program used in generating the XM files is
libXMT, a Lua library I wrote a few months ago. Using XMT,
I wrote a lua script that could parse the output of NRT and write the note information to
an XM file.
The cool thing about the XM file format is that it is a self-contained piece of music with a very small footprint. XM can embed samples and wavetable synthesizers inside of itself. Conceptually, it is a lot like a MIDI file with sounds. The script I made programatically creates a squarewave synthesizer that plays the NRT notes.
nrt2xm program, one could use it with NRT in the following
way with this bash script:
#!/bin/bash nrt_string="d4. r8 m s | t4 s m | r2 t4 | (D2. m s)" BPM=120 offset=70 echo $nrt_string | nrt -F' ' | sort -n | ./nrt2xm out.xm $BPM $offset
The NRT program uses the '-F' flag to change the separator from the default comma
to a space. This is done so the notes can be sorted chronologically with the Unix
sort before being fed into the lua script
Running this script generates a file called "out.xm", opening it up in Milkytracker gives you a pattern that looks like this:
All code can be found on the 9 ways to NRT github
The nrt2xm program, while absolutely functional for basic NRT notation, is definitely proof-of-concept and should be modified for any serious needs.