Jump to content

Convert MIDI to text and back?

Go to solution Solved by kasugatei,
10 hours ago, Implosivetech said:

Could you recommend a program to open with?

To just open and see binary content you can use any hex editor around there (I use Hex Editor Neo), as someone already mentioned. What I was saying was to use programming language of a choice because after all you want to do is

Quote

will then run a custom code, and convert each note to an ascii character

For example in C++

std::ifstream input( "C:\\file.mid", std::ios::binary );
    std::vector<char> buffer((
            std::istreambuf_iterator<char>(input)), 
            (std::istreambuf_iterator<char>()));

this would read all the data from the MIDI file and store it into a buffer. After that you need some sort of a loop which would go thru the buffer and find all note on and off events and do what ever you want to do with it. 

You can take a look here for MIDI file specification so you can find corresponding events and make proper algorithms according to it https://www.cs.cmu.edu/~music/cmsip/readings/Standard-MIDI-file-format-updated.pdf

Is there some sort of program i can use that can allow me to convert MIDI files to raw data values, and then with modification, back again?

i like trains 🙂

Link to comment
Share on other sites

Link to post
Share on other sites

8 hours ago, Implosivetech said:

Is there some sort of program i can use that can allow me to convert MIDI files to raw data values, and then with modification, back again?

What kind of modification do you want to do?

Change instruments, notes, something completely different?

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Niksa said:

What kind of modification do you want to do?

Change instruments, notes, something completely different?

Time for a long explanation:

 

Spoiler

First off, I will get the midi notes down to note on and note off, with the data values of the numbers. I will then run a custom code, and convert each note to an ascii character. I will then put these into a machine learner that will learn to try to mimick those ascii characters. I will then do the entire process in reverse and listen to my final product.

 

i like trains 🙂

Link to comment
Share on other sites

Link to post
Share on other sites

Then, isn't this more of a programming question? You can open MIDI file as binary file, look at the structure for note on and off and run a specific algorithm which will do the conversion?

Link to comment
Share on other sites

Link to post
Share on other sites

42 minutes ago, Niksa said:

Then, isn't this more of a programming question? You can open MIDI file as binary file, look at the structure for note on and off and run a specific algorithm which will do the conversion?

Could you recommend a program to open with?

i like trains 🙂

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, Implosivetech said:

Could you recommend a program to open with?

To just open and see binary content you can use any hex editor around there (I use Hex Editor Neo), as someone already mentioned. What I was saying was to use programming language of a choice because after all you want to do is

Quote

will then run a custom code, and convert each note to an ascii character

For example in C++

std::ifstream input( "C:\\file.mid", std::ios::binary );
    std::vector<char> buffer((
            std::istreambuf_iterator<char>(input)), 
            (std::istreambuf_iterator<char>()));

this would read all the data from the MIDI file and store it into a buffer. After that you need some sort of a loop which would go thru the buffer and find all note on and off events and do what ever you want to do with it. 

You can take a look here for MIDI file specification so you can find corresponding events and make proper algorithms according to it https://www.cs.cmu.edu/~music/cmsip/readings/Standard-MIDI-file-format-updated.pdf

Link to comment
Share on other sites

Link to post
Share on other sites

  • 8 months later...

I think this is what you're looking for rather than binary dumps or writing your own. :) Here are two good ways to do it. Even though these were written years ago, they're good & work well with all versions of Windows including 10. They convert both ways- from midi to txt and from txt to midi. So you can edit the txt as you wish, convert, & then play it. Actually, the one converts to/from a csv file that you can open and edit it in Excel. Cool. The downloads are compressed as tar and gz files so you'll need a program like 7-Zip. The source files are included, but all you need are the exe program files. These must be run from the command prompt, but the basic command is very easy. Example: "mf2t.exe -v midifilename.mid txtfilename.txt" converts the mid file to the txt file. The mf2t program and/or a slightly later version mf2tXP can be downloaded from www.midiox.com. The mf2csv can be downloaded from http://www.fourmilab.ch/webtools/midicsv/. Have fun. 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×