Recording Midi Internally From Norns Scripts?

Hi Everyone,

I have found all of the unique Norns sequencers I have tried to be inventive and endlessly inspiring. I was wondering if there was any way that the midi generated by those sequencers could be recorded to a file in the Dust folder (for example), similar to the way that audio can be recorded to Tape? It would be incredibly useful to me if, after stumbling across a set of sequencer settings that I liked, I could press a button and record that midi in the same way I can currently record the audio to Tape, without having to hook up a DAW or other device first to do so. Could this be done within Norns using virtual midi cables, perhaps, sending the output from a script directly to a file?

Any thoughts that you have would be appreciated - thanks in advance!

17 Likes

that’s an interesting idea!

it could be done, but of course needs some engineering.

specifically, i think it could be done as a mod entirely in lua, without needing external processes or virtual midi devices.

here’s one way it could be structured, the mod would inject stuff into various system functions:

  • patch audio.tape_record_open to optionally begin recording MIDI events as well. could stream to a file, or just write events and delta-times to a table in RAM, saving it on ..._record_close. (maybe just have a output_xyz.midi for each output_xyz.wav. wav/midi selection could be exposed as a mod option or something. )

  • patch MIDI input handlers. there is a single function that is called for all devices on all scripts. the mod would add a routine here that saves [event data, time delta] to the output table/file.

9 Likes

i love this idea! you’ll give RK008 a run for its money!

1 Like

There’s also system level capability:

… but would require some aconnect and virtual midi port Kung-fu

The solution above might actually be easier (as long as you know the correct format for the mid file)

(Has dreams of doing an MMT-8 script once upon a time :grin: )

3 Likes

Ha! Gerrit is a great guy, and I love all his stuff (although some of it, like the RK008, is too rich for my blood :grinning:).

I’m glad people think this idea is worth exploring! Unfortunately for me, the technical implementation ideas everyone has mentioned are way beyond my current capabilities (the most programming I have done with Norns to date is add the Midigrid line of code to enable Launchpad connectivity in several scripts). Nevertheless, I’m happy to help bring this to life any way I can, whether it be just beta testing or trying to write some aspects of the code if you point me in the right direction. The possibility of saving my Norns sequencer noodlings as midi files for future development is very exciting.

5 Likes

I’ve been dreaming of a mod like this too (for HW input originally), inspired especially by Geert Bevin’s work (like GitHub - gbevin/MIDITapeRecorder: AUv3 MIDI Tape Recorder). There is actually a Norns library Middy that does a piece of the puzzle.

it can record midi with quanitzation and play it back as a mini midi loop (see “recording midi” below). this is useful for getting ideas from a midi keyboard recorded into norns quickly (in case you don’t have a daw) and also i find it useful for composition and using midi in a non-midi script.

4 Likes

yes but we are patching into rawmidi rather than alsasequencer. etc etc. so that solution is complicated and the the lua solution is simple.

1 Like

Wondering if a third option might be to modify @nattog’s passthrough v2 to optionally record MIDI from configured source port(s).

Is there a use case when we want to save MIDI from each source port separately?

3 Likes

I wonder if one of the virtual midi ports could be utilized as an always-on recording device. Then there would be an option to grab the last chunk of time or start capturing to a file via a menu option or line of code, similar to tape. Although building it into tape like suggested above might be just as simple.

5 Likes

I’d love it if tape was always-recording.

3 Likes

I could see wanting to record the two midi sources I have in passthrough separately, however can this option get the midi from Norns itself?

1 Like

Having this option too would really be great. Midi files are tiny - even 5 minutes’ worth of midi data at a healthy BPM would probably take up very little disk space.

1 Like

This is a cool discussion!

I was intending to add MIDI file recording to the script I’m working on at the moment. I’ll probably still attempt it myself, but having builtin real-time recording of MIDI data from any script would be great!

Any recorder should also be able to record other types of MIDI data - CCs (most importantly), program-change, pitch-bend and maybe even NRPNs and sysex.

I found a couple of Lua libraries for MIDI file creation. I’m having network issues at the moment, so can’t find links, but a quick search should turn them up. I think one needed to be installed via Lua Rocks (which isn’t installed by default on Norns), but the other (simpler) library could be downloaded directly.