MIDI-to-CLTF converter v2.1 - converts Standard MIDI to ClanLord Tune Format
Usage: mid2cl [OPTIONS] <INPUT.MID> [OUTPUT.TXT]
If the output file is missing, the input name with a .TXT extension will be used.
If the output file is "-", stdout is used.
Valid channel numbers are 1..16.
Options can appear more than once.

Valid options:
  -a              auto-transpose: transpose the lowest note found to \c
  -d C1[,C2...]   disable channels C1..CN
  -d all          disable all channels (for combination with -s, obviously)
  -e              eliminate identical notes
  -h              print this text and exit
  -l              allow long chords (as [...]$)
  -n              do not use triplets (default: allow triplets)
  -m T,C1[,C2...] merge channels C1..CN into target channel T
  -m all          merge all channels into target channel 1
  -p N | C@N      set number of allowed simultaneous notes to N
                  (for all channels/for channel C)
                  N=0: unlimited (default: unlimited for all channels)
  -s C1[,C2...]   output channels C1..CN only (default: all)
  -t N            transpose input by N (can be combined with -a)
  -u              allow upper c (as /b#)
  -v N            set verbosity level to N (0..9, default==4)

Default settings:
- all channels enabled
- no auto-transpose
- keep identical notes (identical means same starting point and same note value. duration is ignored)
- use triplets (which are not yet implemented...)
- no long chords
- no upper c
- no polyphony limit
- verbosity 4

Merging of channels:
When selecting channels for merging, the first number given is the target channel. The other numbers denote the channels that will be merged into this one, depending on whether they are active (-s) or disabled (-d). So "-m all -d 10" and "-d 10 -m all" yield identical results: merging all channels except the percussion channel into channel #1.
Multiple merge commands may be given (e.g., "-m 1,2 -m 4,5,7,8"), but no channel may be used twice anywhere.
If the target channel was deactivated previously, it will be automatically activated. Trying to deactivate it after the merge command is not allowed.

Selecting/deselecting channels:
Initially, all 16 channels are active. To parse only channel 4, use "-d all -s 4". To parse all channels except #10, use "-d 10".

Transposing:
Transpose all channels simultaneously up or down using "-t". To automatically transpose all active channels so that the lowest note found is shifted (up or down) to \c, use "-a". To automatically transpose it to \d, use "-a -t 2".
Note that "-a" looks for the lowest note only in active channels, so disabling certain channels may yield different results.
Transposing of individual channels is not supported.
In any case, notes outside the valid range \c../b are always clamped to the nearest octave.

Cleanup of identical notes:
Especially merging, but also automatic octave clamping, may result in several notes of the same pitch starting at the same time. Per default these are interpreted and can be used for example to create really loud notes (such as "[ccccc]").
With "-e", all identical notes within (target) channels are removed. Note that note lengths are ignored in this case - only the first note (when merging, this usually means the one from the lowest channel number) will be preserved.

Triplets and short notes:
Triplets and 1/32 notes are not yet supported. When encountered, a warning will be issued, and note durations will be clamped to the nearest 1/16 note.
Note that timing problems are likely to occur when triplets are encountered. You can try to resolve some of these problems by using "-n", but this will not help in all cases.

Polyphony check and forced limitation:
Per default, all channels allow unlimited polyphony (=number of simultaneously playing/sounding notes). Since all instruments in CL/Arindal have a maximum polyphony limit, it is possible to automatically reduce the number of simultaneous notes.
If possible, notes already playing are shortened, once the given limit is reached. If this is not enough, notes are dropped completely. The heuristics used for this are: The oldest notes still sounding are dropped first, and if there are several choices (because they started at the same time), more notes are dropped in the order of lowest to highest, in the hope of preserving the melody (which usually has the highest pitch).
The results even for extreme cases such as "-p 1 -m all -d 10" are usually very good and useful, so it should be possible to replay all MIDI files on a single bone flute, while the songs and rhythm are still (mostly) recognizable.
As another example, if you composed a trio and have a harp in channel #1, a violin in channel #2, and a guitar in channel #3, you'd use "-p 1@10 -p 2@2 -p 3@6".
Note that the CL-/Arindal polyphony limit can generally be exceeded by one, by playing the last note *outside* the chord. This way it is possible to play three notes simultaneously on a violin, for example, by using "[ce]G" instead of [ceg]p4". This is also the reason why single-note chords (and thus two tones) are possible with the Conch. While mid2cl is not consistently checking for this additional note at the moment, you may often get lucky with the larger limit anyways (i.e., "-p 3" for the violin). The only cases where this will fail is, if those notes do not start at the same time, but sequentially. However, this "feature" will probably be fully supported in future versions.

If you encounter any bugs, problems, glitches, or if you have feature requests, please contact Newt in Arindal, or the CL- or Arindal forum.

Version history:
1.0 - 20080820
Initial version

2.0 - 20080829
- command line options
- merging of channels
- selecting/deselecting of channels
- optional autotransposing to accommodate lowest note
- transposing
- eliminate identical notes (e.g., as a result of a merge)
- polyphonic overflow checking and limitation

2.0.1 - 20080911
- option "-u" for upper c (/b#)
- option "-l" for long chords ([...]$) --INCOMPLETE!
- use channel volumes, even on merged channels
- use note velocities, respect chord velocities

2.1 - 20080914
- support for long chords

http://wkresse.de/WekaDev/mid2cl/
