MidiToCSound Alpha 1 Release

The first, alpha-level release of the bigwinky.com MidiToCSound utility is available for download

General Instructions:

  • Make sure you have Java 1.5 or greater
  • extract the zip file somplace
  • read the readme

If you’re really in a hurry, cd to the folder you extracted to and try something like this:

$ java -jar miditocsound-alpha-1.jar -convert -in /home/jsmith/midis/98092001.mid -notemap default-notemap.txt -progmap default-progmap.txt

In its current form, the utility can be used in one of three modes:

  • List: list all the MIDI program numbers and MIDI percussion (channel 10) note numbers used in the sequence.
  • Convert: convert a specified MIDI file to a CSound .sco file. The user must supply two files that tell MidiToCSound how to map MIDI Program numbers and MIDI percussion (channel 10) note numbers to CSound instrument numbers.
  • Check: Check the user supplied mapping files against the timbres used in the input MIDI sequence.


Known limitations / planned enhancements:

  • Java Runtime Environment 1.5 or greater is required.
  • There are no default note number or program number mappings. (Although this distribution contains the default-progmap.txt and default-notemap.txt files that can be used with the -progmap and -notemap options.) Useful defaults for determining CSound instrument numbers in lieu of explicit mappings might be to add 100 to program numbers and add 200 to MIDI percussion note numbers. (This can be obtained using the provided default-progmap.txt and default-notemap.txt) Another possibility is to simply map every program number and percussion note number to CSound instrument number ‘1’.
  • Currently one of -check, -convert or, -list must be specified, even though the program could infer the user’s intention using the presence or absence of other options. ( E.g. if -out is specified, -convert is implied; if no -notemap and no -progmap then, -list is implied)
  • The program emits a comment when MIDI controller changes are found during a note. For now these are obviously informational only (and possibly confusing). In future releases, there might be an option for using the controller changes to set some higher numbered p fields.
  • miditocsound writes an i-statement only after the corresponding note-off MIDI event is found. This causes the i-statements to not be sorted by note-start time as users may expect.
  • A related subject: When two or more notes with the same note number and same channel are overlapping in the input sequence, miditocsound uses a FIFO queue to determine which MIDI note-off belongs to which MIDI note-on. (The first note-on will get the first note-off and so on.)
  • i-statements corresponding to MIDI percussion will not have a p5 (pitch) field. The design assumption here is that MIDI percussion is not melodic and a reasonable pitch cannot be guessed by the program.

Here’s some sample output:

;===========================================================================
;   CSound .sco File Generated by bigwinky.com MidiToCSound
;===========================================================================
; Converted:    2007-06-06T23:39:35.049-0400
; MIDI Input:   /home/jsmith/midis/98092001.mid
; MIDI Sequence Length: 76436 (ticks)
; MIDI Sequence Resolution:     120(ticks/beat)
; MIDI Program Number to CSound .orc Instrument mapping:
;       prog#   Name                    instrument#
;           0   Acoustic Grand            100
;           4   Electric Piano 1          104
;           7   Clavinet                  107
;           8   Celesta                   108
;           9   Glockenspiel              109
;          30   Distortion Guitar         130
;          45   Pizzicato Strings         145
;          64   Soprano Sax               164
;          80   Lead 1 (square)           180
;          81   Lead 2 (sawtooth)         181
;         104   Sitar                     204
;         108   Kalimba                   208
;         113   Agogo                     213
;         115   Woodblock                 215
;
; MIDI Percussion Note-Number to CSound .orc Instrument mapping:
;       note#   Name                    instrument#
;          35   Acoustic Bass Drum        235
;          38   Acoustic Snare            238
;          42   Closed Hi-Hat             242
;          46   Open Hi-Hat               246
;          54   Tambourine                254
;

i100    0.0000  0.1000  7937.5  293.66
i235    0.0000  0.1250  6250.0
i242    0.0000  0.1250  6250.0
i254    0.0000  0.1250  5000.0
i100    0.0333  0.1000  7937.5  293.66
i108    0.1250  0.1000  7937.5  329.63
i242    0.1250  0.1250  4375.0
i254    0.1250  0.1250  3750.0
i108    0.1583  0.1000  7937.5  329.63
i164    0.2500  0.1000  7937.5  329.63
i235    0.2500  0.1250  6250.0
i246    0.2500  0.1250  6250.0
$

Thanks for trying it. Let me know how this could be made more useful. (Just remember I have a fairly strenous day job)

(dan at this domain)