1

Inverse of this question: Transcribing a Standard MIDI File to sheet music

How does one actually make an MIDI file work, as in, what determines the octave and the length of each note? How does the notation form a note correctly? My main software to work with this is Starbound Composer, a MIDI file renderer for the Chucklefish game Starbound.

(I'm asking about something like this segment: 3/4 ^G,3/4 [^D3^D,3/2] =G,3/2 [c/4C,/4] C/4 [d3/8^A,/8] G; taken straight from A Little Fight Mewsic by Homestuck)

Note: I'm actually hand-making the music from total scratch. Knowing no other way, I'm going to render it as a .wav using Starbound Composer, and then use Audacity to render it to .MP3

Has sequel: Note Positioning: .abc files and note length

  • 4
    Are you really looking for the details of the binary format of midi files (which are thoroughly documented online, but mostly only useful if you're writing your own software to read/write them) -- or are you just looking for an existing midi editor program to create them? If the later, while poduct recommendations are off topic, you might try MuseScore. – Caleb Hines Jul 28 '15 at 15:33
  • 1
    I agree with Caleb: most notation programmes are quite capable of exporting very good MIDI to file. A fairly good explanation of the file format is here: ccarh.org/courses/253/handout/smf. – user16935 Jul 28 '15 at 16:56
  • 1
    The octave is determined by the note number. The length is determined by the timing of the note on/off messages. And I guess this answer did not help you. – CL. Jul 28 '15 at 17:23
  • I'm really looking for the details of the note numbers, like what denotes the length of the note. – Nefer007 Jul 30 '15 at 17:31
  • 1
    In my answer, I mentioned, in passing, ABC Notation. After a bit more research (the beginning of this video: youtube.com/watch?v=br1kkm4cNI0), I've discovered that "Starbound Composer" (which I'd never heard of) actually converts MIDI files into ABC notation, which is what you posted. In order to get the information you are looking for, I would recommend that you ask a new question about "Understanding ABC Notation". – Caleb Hines Aug 7 '15 at 3:54
8

(I'm asking about something like this segment: 3/4 ^G,3/4 [^D3^D,3/2] =G,3/2 [c/4C,/4] C/4 [d3/8^A,/8] G; taken straight from A Little Fight Mewsic by Homestuck)

You seem to be confused about what MIDI is. I'm not sure where you got that, but the above clip is emphatically not MIDI. MIDI is a binary format, and as such, is not really human readable. Here, for example, is the opening of Bach's Prelude No. 1 in C Major from the Well-Tempered Clavier, as viewed in a binary editor. Or at least one MIDI realization of it:

enter image description here

What you have looks like an ASCII/text-based format. It might be something like the ABC file format (or some variant thereof), or it could be something else. But it is definitely not MIDI.

How does one actually make an MIDI file work,

One typically uses another program to export a MIDI file. These often take the form of a musical notation program, such as Musescore, Lilypond, Finale, or Sibelieus; or the piano-roll editor of a more fully-featured DAW, such as Reaper, Sonar, Logic, or Garageband.

Or else one writes their own computer program from scratch to create a MIDI file that conforms with the MIDI standard file format. One does not simply manually edit a MIDI file in their right mind.


Given the clip you provided, I do not believe your question should actually be about MIDI. However, I will answer your question anyway, from a high-level, perspective of MIDI.

as in, what determines the octave and the length of each note? How does the notation form a note correctly?

MIDI was first-and-foremost designed as a specification for controlling hardware. As such, it consists of a series of digital commands called MIDI Messages that are sent over a cable in real time. These messages typically represent performance data (such as depressing and releasing keys or pedals, twisting knobs, adjusting sliders, or varying breath pressure), and are used control a musical synthesizer -- either a hardware synth or a software synth (though other equipment such as stage lighting can be controlled as well). How the synthesizer reacts to these messages to produce sound, or other effects, is up to each individual synth implementation to determine. Some messages are also tagged with a number called a "channel" from 0-15, which I'm not going to discuss further.

MIDI files are a way of storing these messages. Each MIDI message is preceded by a corresponding time stamp, and this pair forms a MIDI Event -- a specific message at a specific time. The timestamp is actually provided as a delta-time; it gives the number of abstract units called ticks from the previous event. Converting between ticks and real time or musical time (bar, beat) can be a bit of a convoluted practice... For convenience, events in a file can be grouped into sequences called tracks. A MIDI file will then contain a header section, and some number of tracks.

Because a musical note lasts for a certain duration, and is not a single point in time, there is not a single "note" event in MIDI. Instead, to "form a note correctly" requires two events -- Note On, and Note Off -- representing the start and end of the note. These messages each have a note number, listed in the table that Felice provided, representing their pitch including octave. The duration of the note is just all the time that happens between these two events. Since there can be any number of other events in between them, if you wanted the full duration, you'd have to add together all the delta-times of all the events after the note-on event until you find a corresponding note-off event (in the same track, with the same pitch number, and on the same channel...).

All of that to answer what you technically asked, but, I fear, not at all what you wanted to know.

3

MIDI is a binary file, you can't read as a regular text file, you need a program to extract information from it. Basically a midi file is a sequence of commands, representing what each istrument must do at a certain time. The most common command is probably NoteOn/NoteOff, and that command takes the note and the velocity. Note and velocity are in a range 0-127, and if you want know how "real" note are mapped to these number, have a look here: http://newt.phys.unsw.edu.au/jw/notes.html or look at the image ( from the site above) : enter image description here

Regarding your dubt about how is written the note length, we can say it is not actually written, since the file format store events in time, the note length is a consequence of the two event note-on - note-off.

0

You are talking about Standard MIDI Files (SMF). If you actually want to learn to write the raw code, you can find all the technical specifications and documentation at the website of the MIDI Manufacturers Association:

http://www.midi.org/techspecs/index.php

I'm not an expert, but essentially:

MIDI was originally envisioned as a "real-time" serial data protocol. There is a MIDI command for "note on" for a particular pitch, and there is another command for the "note off" for that pitch, and you can write code to represent them. However, MIDI itself doesn't put any of that in the context of a tempo or a timeframe. That's where the Standard MIDI File specification comes in -- essentially it provides for MIDI events and commands to occur with timestamps for each command and event against a "grid" of a tempo at a certain resolution (think of it as a kind of "bit rate") expressed as "ppq" or "parts per quarter note" (see the documentation).

So read up on the MIDI commands and events, and on the Standard MIDI File specification.

However, if you can read and write standard music notation (sheet music), you don't need to learn how to write MIDI commands and events as text code. It would be useful to learn how to use a music notation software program such as Finale, Sibelius or MuseScore. Create your score in standard music notation, and any of these programs will output a highly detailed Standard MIDI file which you can use either within the program itself, or exported to a DAW (digital audio workstation) for playback using high-quality virtual instruments, to create an audio rendering.

Another method, without resorting to written sheet music notation, is to use the MIDI sequencer portion of a DAW to program music in step-time entry. The MIDI sequencer can play back your step-time programming in real-time and run your MIDI data through virtual instruments to create an audio rendering. I've just run a lot of terminology past you; you will need to look up all these terms and learn how MIDI sequencing works.

If you really want to go even further with writing code, music notation in a computer app such as Finale, Sibelius or MuseScore can be output as MusicXML, which contains a lot of metadata pertinent not only to the musical notes but also to how they are displayed as music notation. The MusicXML specification and its development are open-source; at this writing, it is in the process of being transferred from the ownership of the MakeMusic corporation to the W3C.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.