MidiTemp - a Midi Tempering Utility
by Fred Nachbaur ©1999, 2002
(This documentation included in the distribution package as a .txt file)

V2.4b, Apr. 18, 2002


This program allows you to import output from HARMONIC.EXE to temper pre-existing midi files according to predefined or "roll-your-own" scale tempers. It will process any valid midi file, inserting pitch-bends for every note to produce a new file tempered according to your wishes.


The self-extracting install program will, by default, place the program and all support files into the C:\HARMONIC directory, but you can override this by specifying a different extraction directory. It will also create the following subdirectories:

\DAT - for temperament files exported from Harmonic Analyser, for reimport into MidiTemper.
\DOCS - Documentation (including this file)
\MIDI - Midi files (source and destination)
\SCL - for "Scala" format .SCL files
\SOURCE- The qbasic source files for these programs. May be deleted if you don't intend to study/modify the programs.

See HARMONIC.TXT for instructions on installing the distribution package. After extraction, all you have to do to run the program is enter MIDITEMP at the command prompt.

This and the other programs in the suite will run fine under most versions of Windows, the notable exception being Win2000 (under which keyboard difficulties have been reported). After running the self-extracting install executable, you can create links ("shortcuts") to your desktop or Start Menu (32 bit Windows versions) or Program Groups (16-bit Windows versions)


Using File Manager, drag-and-drop miditemp.pif into your desired program group. You'll just have a generic DOS icon at this point. Click on it to select it, then in the Program Manager window click File -- > Properties. Click on "Change Icon", Windows will tell you no icon is associated with that file. Ignore that bit of wisdom, and browse to your directory and select miditemp.ico.

To adjust window/font size, bring up the program by double-clicking its icon, then click the system button at the upper-left corner, select Fonts. . . and adjust according to taste. Windows will remember your settings in the future.


Using Windows Explorer, drag and drop harmonic.pif (usually shows up as just "miditemp") into your destop folder of choice. At this point you'll just have a generic DOS icon. Right-click on it, select Properties. Click the Program tab. Click the Change Icon button. Click Browse. Find your way to the directory (folder) containing miditemp.ico, click on it and then click the Open button. Click OK. Now fill in the "Working" field with the path to miditemp.exe, example: c:\myfiles\music\weirdstuff\. Click OK. You'll now be all set to go.

To adjust font-size, right-click on the icon, select Properties, click on the Fonts tab, and adjust according to taste and proclivity. Windows will remember the setting the next time you use it (if all goes well...)


  1. Create your temperament file.

    When you first start Midi-Temper, it asks you to input the filename of the temperament data (.dat) file. Note that default is in the \DAT subdirectory. (If you enter a full path-name, this overrides the default.) If you press ENTER only, the filename HARMONIC.DAT is assumed. If it doesn't find it, you have to exit and create it using HARMONIC.EXE. A sample HARMONIC.DAT file is provided for those who want a quick-start. This is the Werckmeister temperament, centred at A=432, tonic C.

  2. Specify the midi file to process.

    The source midi should ideally be in the \MIDI directory, but a full path name is also allowed (re-enabled in V2.3a). Please note that, although the program will blithely process any valid midi file, you will ONLY get proper results if the midi files meet the following criteria:

    1. There should ideally be no more than one note on at any given time on any given channel. This is because pitch bends affect all notes on that channel. In other words, no chords or held notes. Drake Donahue's SPLITTER might be useful to NWC users for splitting chorded tracks into separate channels. (All that being said, there are occasions where you can judiciously have some overlapping notes, or "collisions.")

    2. Reliance on pre-existing pitch bends (slides, etc.) is now permitted, (as of V2.4) but there may be occasions where MidiTemper won't transform these as expected, especially if the tempering process results in pitch-bend overflow. Such overflows are reported after tempering, but be sure to examine your tempered midi after the fact even if no such errors are reported. Alternately, you can revert to the old mode of operation, in which any existing pitch bends are stripped.

    If the specified filename exists in the \MIDI subdirectory, (or in the path you explicitly define) you'll be prompted to give a different name, or exit.

    A simple sample midi file meeting the above requirements is provided as test.mid, again for those who want to jump right in and play.

  3. Specify the output filename.

    If the specified filename exists in the \MIDI subdirectory, (or in the path you explicitly define) you'll be prompted to give a different name, or exit. As throughout the program, entering a filename only assumes the default directory (\MIDI in this case), but if a drive spec is included (e.g. C:\MYDIR\... ) then the path is followed. Exception: if the filename exists but has length zero, you will be allowed to use it.

  4. Edit temperament if necessary.

    The imported temperament data is now displayed for your edification. If your temperament has less than 12 tones (e.g. the Persian temperaments), you'll be warned that undefined notes will be treated as "no pitch bend from equal-tempered default."

    If your temperament has more than 12 tones (different values for one or more enharmonics) you'll have to make an editorial decision on which one(s) to use. Too bad that midi only specifies twelve tones.. and too bad that this program isn't smart enough to figure it out for you. For many tempers, the choice shouldn't be too hard, remembering that one enharmonic is usually much more common than the other. For example, in the key of C, it's much more likely to encounter C#, Eb, F#, G# and Bb than the corresponding Db, D#, Gb, Ab and A#. That being said, which ones you choose are up to you.

    The problem is especially sticky in fancy temperaments like 19-tone 5-limit Just Intonation, where you have up to three possible pitches for some notes. What can I say, except that perhaps this program is not a do-it-all solution for such temperaments. Notwithstanding that, real purists can at least get the bulk of the work done automatically, fixing up the oddballs manually using an external sequencer.

  6. Let it rip!

    And away it goes. Press any key to start the conversion process. If you selected "verbose" output you'll see all the additions/replacements as they occur. Warning: don't use verbose output on large files and slow computers unless you plan on having a coffee break anyway.

    All events on channel 10 (the percussion track) are left alone. Tempering an unpitched instrument is rather pointless, and ignoring channel 10 helps reduce the loading on your synth.

    When complete, the output filename is given (in case you forgot it).


    (New as of V2.3b) If there were any "collisions" (i.e. overlapping notes on any given channel), and if your source file is a Type 1 midi file, you also get a report on how many such collisions were encountered while processing the file. The collisions are also itemised in the file collisn.log, which appears in your default directory. Depending on your file, such collisions may or may not require you to rework your source midi. (For instance, I challenge anyone to hear the effect of the collisions on the harp arpeggios in the supplied demo midi "caverns.mid".) The collision reporting algorithm has been improved in V2.4, and should give more accurate results in most cases. However, it is *not* guaranteed to work properly on Type 0 midi files, so for such files it is highly recommended that you convert your file to Type 1 first. (See also the HINTS: section below.)

    Secondly, if the program finds that there are more note-on commands than note-off events, it deduces that your midi file has "stuck notes" and reports on the number of such unresolved events. (Even if these are on rapidly-decaying sounds such as glockenspiel, etc. they can be a real nuisance in midi processing programs. As relates to MidiTemper, they can result in greatly inflated collision reports.)

    Finally, if you chose to adjust existing pitch-bends, there is a distinct possibility that you will overflow the allowed pitch-bend range. This is especially true if your existing bends traverse to one extreme or the other. In this case, MidiTemper does the best it can, and simply assigns the maximum (or minimum) value as appropriate. It also reports on the number of such events that had to be "approximated."


    Pressing a key exits the program. If the program was called from within Harmonic Analyser, you are now returned to the parent program for further editing, exporting another midi, or any of the other Harmonic Analyser "End Menu" options.


    It can happen that more than one midi track share the same midi channel. In this case, collision reporting can miss events that occur simultaneously on different tracks, even though they share the channel.

    Similarly, while most midi tracks will exclusively have events on one channel, the GM spec does not disallow "channel hopping," with events occurring on different channels within a single track. In this case, collisions may be reported that are indeed not valid.

    Both problems can be circumvented by "collating" your midi file first. For Type 0 midis, this is as simple as converting to Type 1. For Type 1 midi files, you merely have to convert first to Type 0, and then back to Type 1. I suggest that you get Jeff Glatt's excellent freeware "Midi File Converter,".


    As of this writing (Mar. 2002) there are no known problems or bugs. The old problem of DOS-generated errors (e.g. by non-existant paths or invalid filenames) is now internally trapped. Such errors should now return you to the point just before the error occurred, or allow you to terminate the program using ESCape. Reports of any difficulties with this would be greatly appreciated.

    Although CNTL-BREAK will abort the program just about anywhere, it's not recommended unless it gets into some bizarre loop condition. Aborting this way *could* leave files open, with resulting contentions later. If this /does/ happen, you might have to reboot, and then delete any leftover *.tmp or *.mid files you find in the program directories.


    This program doesn't process the raw midi file directly. Dealing with those variable-length numbers, hi/lo byte order, running status complications, etc. was just more than I felt like tackling. So instead it stands on the shoulders of Piet van Oostrum's freeware "midi-to-text" and "text-to-midi" programs, which are called from within the MIDITEMP executable. The midi file is first converted to text, in a temporary file called MIDINPUT.TMP. This is the file that's actually processed, and output written to MIDOUTPT.TMP. When done, these temporary files are killed.


    The distribution package may be used and circulated for free, in any way you see fit, provided that such distribution is not for profit. See license.txt for further details.

    mf2t.exe and t2mf.exe owned by Piet van Oostrom. Used with implied permission.


    V1.0 - first release version

    V1.1 - minor cosmetic changes

    V1.2 - changed data file routine to allow importing arbitrary filenames. modified for new .dat file format as of Harmonic Analyser V2.2

    V2.3 - synchronised version number with Harmonic Analyser, added reset option #4, allowed for partial integration with Harmonic Analyser (Miditemp can now be called from within the HA environment). UI and cosmetic improvements.

    V2.3a- restored full path-name functionality. Uses default data subdirectories only if no drive spec included.

    V2.3b- Writes "collision" (overlapping notes) log to collisn.log (midi Type 1 only). Report number of collisions on-screen also.

    V2.4 - Added new options and re-organised options selection. Included are: Facility to adjust existing pitch-bends. Facility to collate input midi to reduce collision reporting errors, and find collisions that otherwise would go undetected. Delete controllers if desired. Expanded "verbose" reporting. Improved collision reporting. "Stuck note" and "Pitch over- range" reporting on-screen and in collisn.log. Error trapping now handles errors generated by DOS. Improved enharmonic selection.

    V2.4a - Maintenance release. No significant changes. V2.4b - Updated new web domain for Dogstar Music's main site.

    Comments? Suggestions? E-mail me at fnachbaur@netscape.net

    Website: http://www3.telus.net/dogstarmusic

    Back to Midi Utilities Page

    Copyright ©1999, 2002 by Fred Nachbaur

    To get in touch with me, please e-mail Dogstar Music at fnachbaur@netscape.net

    Back to "Fred's Freebies"

    Go to Dogstar Music's Main Page

    ---This page last updated Apr. 18, 2002.---