Creating XRNS files pragmatically

Hi,

I have a personal project in the works which generates music based on user input and outputs the music in the form of MIDI files. The project is written in Python 3 and uses midiutil to create the output.

I only use MIDI as a way of previewing the music, but the goal is to create something that is compatible with Renoise for tracking and arranging.

I noticed that Renoise does import MIDI files pretty nicely, but none of the files I import have correct LPB or pattern length values. I’m assuming there is no way to control these within the MIDI file since they aren’t a part of MIDI, but if I’m wrong please correct me.

That said, I want to somehow make my program compatible with Renosie. The only two ways I can see this happening are (1) I create an intermediate format and write a LUA tool to import the intermediate format, or (2) find some API which can be used to create the XRNS files pragmatically. I can’t see myself writing directly to XRNS since the format seems very complicated and there’s no spec available.

It is looking like I’ll have to choose the former but I don’t want to since I’m not interested in learn lua, plus it’s a great deal of extra steps in the first place. Before drawing this conclusion I was hoping maybe someone here who knows better can confirm my reasoning? Is there no way to create XRNS files pragmatically, or to get MIDI and Renoise to work nicely with each other?

Thanks

1 Like

Possibly you can generate MOD, XM or IT in your Python code ? - Renoise imports those. Though, for a better answer, please be patient until someone who knows Renoise better than me to post here.

Very interesting, I never would have thought of looking for another format besides MIDI. Thank you, I’ll take a look a these and see what apis are available.

From reading a little about these formats and testing them out on Renoise they seem like a good solution. It’s proving difficult to find an API for any of them, but the .mod format seems like it might be simple enough to maybe do from scratch? If anyone has some advice or knowledge here please share, I’ll keep researching in the mean time.

An XRNS file is actually just a zip file so if you change the file extension to .zip instead you should be able to extract the file contents… as far as I understand the actual song format is in XML so if your python program can generate XML then you may be able to create song files without needing to delve into lua.

1 Like

Exactly, You don’t need Lua to programatically generate an xrns file.

Code needs to emit XML (i.e. text), and bundle in the instruments (which may need to be created as well if they are using custom samples).

It’s non-trivial but doable.

That’s the catch. I opened up the XML for the deepblue demo that comes packaged with Renoise and it has over 220k lines of markup. I guess I could try just making a few simple test songs and look at those instead, I’m sure the complexity will be lower.

I’m writing a Ruby tool to generate layered instruments from a set of wav files. It was not too bad once I split out the boilerplate parts and focused on what was specif to each instrument.

(My xrni-building program works for simple cases. Need to check that it is robust for more complex examples/)

So it’s not that bad? I’ll have to take a look at it and see what’s actually there. I tried creating an empty “song” and it was much shorter- a little less then 3k lines, so maybe it isn’t intractable as I thought :^).

What helped me was to split out anything that could be common to multiple instruments if all the defaults were left. Then I only needed to generate XML for the samples and layers, while the rest could be stuck in as a single string.

I think the XML for track data may be more complex, than for instruments, but still predictable enough to generate.