Musical Information (Mus 253/CS 275A)   
Kern to MIDI Lab
 | 
 
 |   
How to generate a MIDI file from **kern data
-  Humdrum Toolkit programs used in this lab:
   humdrum,
   proof,
   assemble.
   
 -  Humdrum Toolkit Extra programs used in this lab:
   hum2mid, transpose.
 -  Other unix programs:
   cp, less.
  
-  Find or create a Humdrum **kern file.  For example, copy and 
    paste this data into a file called test.krn:
 
| 
 | 
  Graphical form of the music being represented in the **kern data to the left:
 
  |   
 
  
 -  If you just inputted the file, run the humdrum command to check 
     the basic syntax of the file with the following command
     (click on the command for more information):
   humdrum test.krn
 
If the command does not reply with any messages, then the basic spine
structure of the file is correct.  Chapter 5 from the Humdrum User's Guide describes the
Humdrum file format in detail.
To do a more careful syntax check of the file, try this command:
 
   proof test.krn
 
If the command does not reply with any messages, then the musical content
of the **kern spines in the Humdrum file seem to be correct.  In this case
there was no key signature, so the proof command gives the following
warning:
   proof: Warning: No key or key signature declaration for spine 1
 
  
 -  Use the smf command to create a MIDI file from the file
test.krn will the following command:
   smf file.krn -o file.mid
 
The -o option in the smf command indicates the file name
to which the MIDI file contents will be written.  If you do not
specify the output file, the MIDI file will be printed in a ASCII
format similar to the contents of a MIDI file:
   smf file.krn | less
 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Number of Tracks: 2
Time method: 1 (Absolute timing)
Divisions per Quarter Note: 120
Track 0   +++++++++++++++++++++++++++++++++++++++++++++++++++
0	0xff 81 3 7 161 32 
2039	0x90 0 0 
2040	0xff 47 0 
Track 1   +++++++++++++++++++++++++++++++++++++++++++++++++++
0	0x90 60 72 
120	0x80 60 72 
120	0x90 60 64 
240	0x80 60 64 
240	0x90 67 67 
360	0x80 67 67 
360	0x90 67 61 
480	0x80 67 61 
480	0x90 69 64 
600	0x80 69 64 
600	0x90 69 59 
720	0x80 69 59 
720	0x90 67 65 
960	0x80 67 65 
960	0x90 65 65 
1080	0x80 65 65 
1080	0x90 65 69 
1200	0x80 65 69 
1200	0x90 64 68 
1320	0x80 64 68 
1320	0x90 64 68 
1440	0x80 64 68 
1440	0x90 62 63 
1560	0x80 62 63 
1560	0x90 62 59 
1680	0x80 62 59 
1680	0x90 60 68 
1920	0x80 60 68 
2039	0x90 0 0 
2040	0xff 47 0 
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
  
 -  Now that you have a MIDI file (hopefully), you will want to hear
it.  In the Lab, the easiest way to do this is to copy the MIDI file
into your home directory into the www subdirectory which is your publically
accessible webpage:
   cp test.mid ~/www/test.mid
 
  
 -   Here are other options which can be used with the smf program:
| -C |  | 
Don't include Humdrum comments as text in the MIDI file.
 |  
| -D |  | 
Ignore dynamic markings in file.
 |  
| -T |  | 
Don't display non-kern spines as lyrics in the MIDI file.
 |  
| -0 |  | 
Create a Type-0 (single track) MIDI file.
 |  
| --plus |  | 
Create a MIDI+ compliant MIDI file.
 |  
| -v # |  | 
Set the default volume of notes to a number in the range from 1 to 127.
 |  
| -t # |  | 
Scale the tempo by the given factor. 0.5 is twice as long, 2 is twice as fast.
 |  
| -I |  | 
Don't include any instrument specifications.
 |  
| -c # |  | 
Set the output MIDI channel (from 0 to 15).
 |  
 
 
  
  
Exercises
-  Choose a song from the list to encode in Humdrum **kern data format.
  
 -   Change the instrumentation of the example file.  By default the 
MIDI file does not include an instrumentation code, so it usually will
default to piano sounds.  Choose a new instrument by specifying a
Humdrum instrument somewhere at the top of the **kern data spine. 
Try some of the following:
      *Icemba        = harpsichord
      *Icello        = cello
      *Iorgan        = organ
      *Ivioln        = violin
      *Iclars        = clarinet
More instruments can be found on the instrumental code reference webpage.  If there
is a code on this page which does not produce an instrument which is listed
in the General MIDI specification, email me the code and which General
MIDI instrument it should map to, and I will add it to the smf program.
  
 -   Change the tempo in your MIDI file by altering the *MM120
line in the example Humdrum file.  MM120 indicates that there are 120 beats per 
minute.  MM60 would be twice as slow, and MM240 would be twice as fast.
  
 -  Try adding a few articulations to the **kern data.  For example,
staccato marks are indicated with an apostorphe (') and accent
marks are indicated with carets (^):
  
 -   Add dynamics to your file and listen to the resulting MIDI file:
  
 -  Use the transpose command to transpose the music.  Here is
a command which will transpose the music up a minor third:
   transpose -t m3 test.krn > test2.krn
 
The contents of test2.krn should be: 
 Try the following commands and listen to the final output:
 
     transpose -t P5 test.krn > test2.krn
     assemble test.krn test2.krn > test3.krn
     hum2mid test3.krn -o ~/www/test3.mid
 Try also following commands and listen to the final output:
 
     transpose -t m2 test.krn > test2.krn
     assemble test.krn test2.krn > test3.krn
     hum2mid test3.krn -o ~/www/test3.mid
  
 -  For homework, choose 2 examples from the SCORE Assignment #1 examples
to encode in Humdrum **kern data format.  After entering the music, run
the file through the humdrum and proof commands.  Also, listen to the 
melody by converting it to a MIDI file before emailing it to Rob. 
  
 - 
For more **kern encoding exercises, go to the webpage:
   
   dactyl.som.ohio-state.edu/Music824/Exercises/exercise01.html.
Also, you should read the second chapter of the Humdrum User's Guide which gives an explanation of
basic **kern data encoding of music.  A more detailed description of
**kern encoding can be found on the webpage: Everything You Need to Know About
The Humdrum "**kern" Representation.
   
 
 
Revised: 7 March 2005
 |