Converting MIDI to a text file in a unique format
Hi all
I'm trying to help a friend come up with a Max for Live device that takes MIDI note on/offs, and the distance between note on/offs information and converts that into a unique format/language on a .txt file.
I've tried a couple different ways, but I seem to be getting alot of duplicate notes, and all the ways ive come up with are really laborious and convoluted. Anyone have any really simple ideas for how to make a really simple patch for this? Struggling how to wrap my head around poly~ too. Feels like it may help? I've tried with borax too but haven't quite cracked it. thanks
Here's the language:

the text file needs to look more or less like this:
15,u
13,u
d,10
13,o
d,4
14,u
etc etc
so each new line needs to be a new bit of MIDI information. whether it's note on, off, or time in between each note on/off.
and for context - this is for an instrument that reads an SD card and only reads/understands in this strange format off a .txt file. I'm not sure why, but that's what it is.
1- what is midi input ? midi file ? real time input ?
2- is midi numbering standard C4 ?
would mean
e3 = 52 = 1 in that strange languge
...
...
f#2 = ? in that strange language
why are some notes repeated in that list , using different number?
20 & 21 = a#2 or 5 & 6 = c3
makes no sense.
to convert this, you first scale input to match 1 - 25
once that numbering is fixed.
then repace note on and off with u & o , then insert
delta time between events as d