PCX2MIDI


What is PCX2MIDI?

PCX2MIDI is a utility that converts PCX graphic image information into MIDI information. PCX2MIDI will run on any DOS/Windows machine with the following specifications:

It isn't enough to build MIDI information. PCX2MIDI builds MIDI files. A MIDI file is a file which contains header information and MIDI information. These MIDI files can then be loaded into a computer program that is capable of processing MIDI file (by playing or modifying the MIDI file).

What is PCX?

From the Fastgraph User's Guide:

The PCX file format was originally developed by ZSoft Corporation for their commercial paint program, PC Paintbrush. It has evolved into one of the more popular image file formats because so many products can read and write PCX files to at least some extent.

What is MIDI?

From Digital Projects for Musicians:

MIDI (Musical Instrument Digital Interface) [is] an internationally-recognized specification that expresses musical events (notes played, vibrato, dynamics, tempo, etc.) as a common "language" consisting of standardized digital data.

How Do I Run PCX2MIDI?

PCX2MIDI takes 2 or 3 arguments when run. These arguments are:

< OUTPUT_FILE > < GRAPHIC_FILE > [ scanlines = 1 (1-16) ]

You will notice that the third argument is optional. If the scanlines argument is left off, then it will default to the value 1.

The OUTPUT_FILE is the file which will be created by the PCX2MIDI program. This will be the MIDI file that is created by converting the PCX file to MIDI.

The GRAPHIC_FILE is the file which will be used by the PCX2MIDI program. This will be the PCX graphic file.

SCANLINES is the number of chanels or tracks to generate from the PCX file. This argument can range from 1 to 16. The PCX2MIDI program will divide the PCX image into SCANLINES number of segments, one for each chanel. For example, a PCX file 200 lines long will be broken into 4, 50-line segments if the SCANLINES argument is set to 4. If the number of lines in the PCX file is not evenly divisible by SCANLINES, then some of the final information in the PCX file will not be used in the MIDI output file. This results because the number of lines scanned in each track is the same for all scanlines/chanels.

How does PCX2MIDI Work?

PCX2MIDI works by scanning in successive lines of the graphic file and converting them to MIDI information. The MIDI information that is output is based on the colors displayed in the graphic file.

PCX2MIDI will display the PCX file in the "best" screen resolution possible (i.e. it will maximize the image on the screen). The PCX file can be a 2, 4, 16, or 256 color image file. The PCX file can be of any resolution up to 768x1024. For more information about PCX file format, check the Fastgraph reference in the reference section of this document.

After the program displays the image, it scans the image and converts the image into MIDI information. This MIDI information is saved in a MIDI file whose name is specified by the first argument.

Once finished, PCX2MIDI returns to text mode and displays a "Conversion Complete" message.

Now What?

Once PCX2MIDI finishes the conversion, you have a MIDI file. This file can be loaded into your favorite music editing and playing program. You may find that the MIDI files that are output by PCX2MIDI are too high or too low in pitch. This will result from low or high color values in the image file. To compensate for this, you should transpose the MIDI file information after it is loaded into your MIDI software. Once you establish reasonable pitches, you can set each track or chanel to a specific instrument or sample. In doing so, with PCX2MIDI and your MIDI software, you can compose music from graphics!

Studio4 by MidiSoft was used to test the MIDI files created while developing PCX2MIDI.


Download PCX2MIDI

Click here to download PCX2MIDI.EXE version 1.0

sample1.midi - a MIDI output file [1k]

sample2.midi - a MIDI output file [16k]


Common Errors

The following is a list of common problems and possible solutions when using PCX2MIDI:

Problem Possible Solution
PCX2MIDI does not run Did the file get corrupted in download?
PCX2MIDI gives error: USAGE... Use the correct number of parameters when running
FILE NOT FOUND or CANNOT OPEN Specify a PCX file that exists
PCX image is not displayed For smaller images, this is common - it displays, but it disappears too quickly
MIDI file will not load into my MIDI program Was the MIDI file corrupted? Did you get a "Conversion Complete" message from PCX2MIDI?
MIDI file loads but isn't visible Is the pitch too high or low to be seen? Try transposing the track/chanel up or down a few octives
MIDI file doesn't play or make sounds Make sure the volume is high enough
I didn't get the number of tracks/chanels I wanted PCX2MIDI will only output 1-16 tracks/chanels


References

The following references were used to design and build PCX2MIDI. The MIDI links are especially useful for information about the MIDI file format.

  1. Anderton, Craig et al. Digital Projects for Musicians. Amsco Publishing. New York. 1994. 295-310.
  2. Schildt, Herbert. Using Turbo C++. Osborne McGraw Hill. Berkley. 1990.
  3. Weiss, Mark Allen. Efficient C Programming: A Practical Approach. Prentice Hall. New Jersey. 1995.
  4. _ . Fastgraph Programmer's Graphics Library. Ted Gruber Software. 1993.
  5. Midi File Specification 0 06 [26KB]
  6. Midi Note Numbers For Different Octaves [2KB]
  7. Midi Status And Data Bytes [10KB]

If you have questions about PCX2MIDI or any questions about MIDI and PCX that was not answered in the above references, feel free to contact me, Jon A. Preston at jonp@cc.gatech.edu


Last modified by Jon A. Preston, March 10, 1996