OT: MIDI file pitch bend conundrum

I came across a website, which has loads of downloadable MIDI files.

However, the files have been ‘scrambled’ – the notes are “wrong”, but changed with pitch bend so they sound correct. The net result is that the files are unusable for notation.

The music is all public domain, so I’m not sure why they do it.

Can anyone think of a way to ‘reverse engineer’ the correct notes? Here’s an example.

04810.mid (2.9 KB)

They are simple enough that I could aurally transcribe them, but still…

Perhaps you could convert them to CSV files using MIDICSV, then ask a chatbot to remove the pitch bend messages, applying the necessary compensatory pitch change to the affected notes, and spit out the revised CSV files, then convert them back to MIDI again?

2 Likes

Sounds like a stylistic mash-up of Stravinsky and Ben Johnston — wild. What a bizarre way to make a MIDI file! Just curious: Could the pitch-bend data have gotten corrupted somehow, or can it only have been the file creator doing something very odd up front?

Ben,

I long ago came across a file like that. They must be as much of a pain to create as they are to unscramble.

I keep meaning to find something useful to do with the music21 python library, so perhaps this could be it!

Does removing pitch bend events with a DAW get you closer? That’s what I did to your file in Nuendo and then exported it to a new MIDI file.
no pitch bend.mid (1.9 KB)

Thanks, but that just gives the wrong notes, with no pitch bend correction!

How do you feel about VCVRack?

You might send the midi data from Dorico to VCVRack. The free version of VCVRack won’t host directly in Dorico. But you can still route the midi from Dorico to the Desktop version which is free. (Or use Mirack on a Mac or iPad, which Dorico can host as an AU3.)

Patch it like this maybe?

rack_solution

The patch is just basically taking the incoming midi, adding the incoming pitch data (1V/Octave) and Pitch wheel together (which have been converted to “voltages”) using the quantizer. Setting the quantizer to “chromatic” should handle any “off” or microtonal weirdness. Then the patch is just sending the “right” notes back out again as midi where you can record in a DAW - or live record in Dorico if you have it set up for that.

No warranty yet - I might try it just for fun later if I can get away.

Yes, it varies. Otherwise, they’d just all be transposed.

I tried. I’m sorry to say that I failed miserably.

1 Like

In other words, the audio has the correct pitches, right? Would StaffPad’s audio recognition work? (or similar)

You could mute all but one in turn to create audio tracks or sequence them after each other (which might be quicker and only one file, import, get it to render it, then cut paste to assemble), or just play one instrument at a time (Piano?) with StaffPad listening/recording/notating. I have not used this for a while, so the various steps are a bit unclear.

1 Like

Try this file:

04810 Repitched.mid (1.3 KB)

I repitched the notes affected by pitch bend and deleted all of the pitch bend commands.

1 Like

Awesome. Can I ask how you did it, as I’m hoping to apply the technique to several files?

1 Like

I used the utility midicsv to convert the original MIDI file to a text file. I then spent some time analyzing the text file to determine the interaction between pitch bend events and note on and off events. In one case, there was a pitch bend event which changed the pitch bend occurring just before a note off event, and I had to delete that pitch bend event.

I wrote a program in QBasic which repitched the notes affected by pitch bend and deleted all of the pitch bend commands:

REPITCH.ZIP (489 Bytes)

I then used the companion utility csvmidi to convert the resulting text file to the repitched MIDI file.

9 Likes

Wow.

Jesper

1 Like

Lovely stuff. Plenty to work with here!

Thanks so much, @johnkprice

1 Like

It’s likely that a more modern programming language than BASIC would work better to convert the text files containing MIDI events, but I’m a retired computer programmer, and BASIC was the first programming language I learned back in 1970.

@benwiggy, where did you get that original file (and the others you mentioned)? Truth be told, I found the version à la Stravinsky/Johnston to be pretty cool! (Which, @johnkprice , I suppose means I’d want a version of your program that worked in reverse!)

There’s a database of anglican psalm chant, which is amazingly comprehensive, but for some reason, doesn’t actually contain the music, except in this form.

The vast majority of it is from the 18th and 19th century.

1 Like

It is likely that Logic could do this directly with it’s built-in scripting language which operates on MIDI. Load the MIDI file into Logic and run a custom-written script on it. Logic’s scripting language is used to remap MIDI notes under various circumstances, i.e. it provides simple logical statements and variables.

Reaper could definitely do it in a Reaper script because of Reaper’s support of lua.

1 Like