<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >Creating a midi map</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.61 "><LINK REL="HOME" TITLE="The KMid Handbook" HREF="index.html"><LINK REL="UP" TITLE="Midi Maps" HREF="midimaps.html"><LINK REL="PREVIOUS" TITLE="Do I need a midi map ?" HREF="doineedamidimap.html"><LINK REL="NEXT" TITLE="Using midi maps" HREF="usingmidimaps.html"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="stylesheet" HREF="common/kde-common.css" TYPE="text/css"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META HTTP-EQUIV="Content-Language" CONTENT="en"><LINK REL="stylesheet" HREF="common/kde-localised.css" TYPE="text/css" TITLE="KDE-English"><LINK REL="stylesheet" HREF="common/kde-default.css" TYPE="text/css" TITLE="KDE-Default"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#AA0000" VLINK="#AA0055" ALINK="#AA0000" STYLE="font-family: sans-serif;" ><DIV CLASS="logoheader" ><A HREF="http://www.kde.org/" ><IMG SRC="common/logotp3.png" BORDER="0" ALT="The K Desktop Environment" HEIGHT="62" WIDTH="229"></A ></DIV ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The KMid Handbook</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="doineedamidimap.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 4. Midi Maps</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="usingmidimaps.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="CREATINGAMIDIMAP" >4.3. Creating a midi map</A ></H1 ><P >There isn't any program to generate midi maps, so you will have to edit a file by hand (using your favourite text editor).</P ><P >A Midi map is a text file that keeps all the needed translations there will be made when playing music.</P ><P >It consist of four sections: <TT CLASS="LITERAL" >PATCHMAP</TT >, <TT CLASS="LITERAL" >KEYMAP</TT >, <TT CLASS="LITERAL" >CHANNELMAP</TT > and <TT CLASS="LITERAL" >OPTIONS</TT >.</P ><P >Each section must appear only once, except the <TT CLASS="LITERAL" >KEYMAP</TT > section that can appear as many times as needed, provided that each appearance use a different TextID (continue reading for details) .</P ><P >The general structure of a map file is :</P ><P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" > DEFINE PATCHMAP ... END DEFINE KEYMAP "Name of Keymap" ... END DEFINE KEYMAP "Another Keymap" ... END DEFINE CHANNELMAP ... END OPTIONS ... END</PRE ></TD ></TR ></TABLE ></P ><P >You can see that the <TT CLASS="LITERAL" >DEFINE</TT > word is used to specify which section is going to be started (except for <TT CLASS="LITERAL" >OPTIONS</TT >), and <TT CLASS="LITERAL" >END</TT > is put at the end of each section.</P ><P >You can put comments by starting the line with a <TT CLASS="LITERAL" >#</TT > character.</P ><P >Please, don't forget to send me your map file by email, so that future releases of KMid will include support for more non General Midi compliant keyboards.</P ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="THEPATCHMAPSECTION" >4.3.1. The <TT CLASS="LITERAL" >PATCHMAP</TT > section</A ></H2 ><P >This section is used to specify how patches are going to be mapped, from GM to your keyboard specs . The general usage is :</P ><P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" > (Name of GM Patch name)=(N) [AllKeysTo M]</PRE ></TD ></TR ></TABLE ></P ><P >Where <TT CLASS="LITERAL" >N</TT > is the number that you keyboard needs to receive to change the patch to the same that the GM standard does .</P ><P >Please note that the left side of the equal sign is ignored, so GM patches are supossed to be in order (from 0 to 127) , and so you are not allowed to change the order of the lines nor to omit any of the 128 instruments.</P ><P >The optional <TT CLASS="LITERAL" >AllKeysTo M</TT > is used to map all notes that use that instrument to the <TT CLASS="LITERAL" >M</TT > key . For example, suppose that your midi keyboard doesn't have a Gun Shot sound (GM patch 127) so you want to map it to a percussion drum (i.e. key 60), which sounds similar to a gun shot, then you can put in the 127th line of the <TT CLASS="LITERAL" >PATCHMAP</TT > section:</P ><P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" > Gunshot =100 AllKeysTo 60</PRE ></TD ></TR ></TABLE ></P ><P >So when a midi file tries to play a note with the patch 127 (gun shot), it will be mapped to the patch 100 (your keyboard's percussion patch) and play the note 60 (independently of the key that was goind to be played) .</P ><P >Please note that when I use the expression 'Percussion patch', I mean the patch in which each key plays a different drum, cymbal, tom, maracas and so on, and not to a possible sound which some keyboards have and which plays a different tone of the same drum with each key.</P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="THEKEYMAPSECTION" >4.3.2. The <TT CLASS="LITERAL" >KEYMAP</TT > section</A ></H2 ><P >The <TT CLASS="LITERAL" >KEYMAP</TT > section is used to specify how keys are going to be mapped, within a given channel or instrument . The usage is :</P ><P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" > DEFINE KEYMAP "Name of Keymap" C 0 =0 C#0 =1 D 0 =2 ... END</PRE ></TD ></TR ></TABLE ></P ><P >As with the <TT CLASS="LITERAL" >PATCHMAP</TT > section, it is very important the order of the lines, and that they are all there (the 128 keys).</P ><P >As you can define multiple keymaps for different channels and instruments, you must give a different name to each one in the first line.</P ><P >Keymaps are mainly used to map keys in the percussion channel . Have a look at the distributed maps to see some examples.</P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="THECHANNELMAPSECTION" >4.3.3. The <TT CLASS="LITERAL" >CHANNELMAP</TT > section</A ></H2 ><P >This section can be used to map some channels to different ones . For example, if you want to swap the first and second channels, you can easily do it within the <TT CLASS="LITERAL" >CHANNELMAP</TT > section .</P ><P >However it is more usefull for keyboards that need the percussion channel to be in a given channel (the GM standard use the channel 10, others use the channel 16 and others use channel 9).</P ><P >Note that midi devices use 16 channels, so the <TT CLASS="LITERAL" >CHANNELMAP</TT > section, has 16 lines, from 0 to 15 , as this one :</P ><P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" > (N) = (M) [Keymap "Name"] [ForcePatch x]</PRE ></TD ></TR ></TABLE ></P ><P >Where <TT CLASS="LITERAL" >N</TT > is the channel which is mapped to the <TT CLASS="LITERAL" >M</TT > channel . If the <TT CLASS="LITERAL" >Keymap</TT > option is used, the Keymap with name <TT CLASS="LITERAL" >Name</TT > will be used in this channel (this Keymap should be defined earlier in the map file !) . If the <TT CLASS="LITERAL" >ForcePatch</TT > option is used, all events that try to change the patch which is used in this channel will be ignored, and patch <TT CLASS="LITERAL" >x</TT > will be used instead .</P ><P >The <TT CLASS="LITERAL" >ForcePatch</TT > option may be useful for example to always use the percussion patch on the percussion channel .</P ></DIV ><DIV CLASS="SECT2" ><H2 CLASS="SECT2" ><A NAME="THEOPTIONSSECTION" >4.3.4. The <TT CLASS="LITERAL" >OPTIONS</TT > section</A ></H2 ><P >The <TT CLASS="LITERAL" >OPTIONS</TT > section has some general options that can be very useful :</P ><P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="SCREEN" > OPTIONS PitchBenderRatio = r MapExpressionToVolumeEvents END</PRE ></TD ></TR ></TABLE ></P ><P >You can specify both options, only one, or none of them.</P ><P >The <TT CLASS="LITERAL" >PitchBenderRatio r</TT > value, has the ratio by which pitch bender events will be multiplied . That is, when a midi file tries to send a pitch bender event with a <TT CLASS="LITERAL" >n</TT > value, the real value that will be sent is <TT CLASS="LITERAL" >n*(r/4096)</TT > (the <TT CLASS="LITERAL" >4096</TT > value is for not having to put decimal points in the map file).</P ><P >This is used because the GM standard says that when a midi keyboard receives a Pitch Bender event with a 4096 data value, it should bend the note to a higher one , but some midi keyboards try to bend the initial note by two or more higher notes (even an octave higher !) when they receive a 4096 . This can be easily fixed by trying different values so that instead of sending a 4096, KMid sends the appropiate value .</P ><P >When the <TT CLASS="LITERAL" >MapExpressionToVolumeEvents</TT > option is set in the map file, and a midi file try to send an expression event, KMid will send a volume event which is understood by more non-GM keyboards, and which has a similar effect . There are many midi files which use expression events to fade out at the end of a song, so if you feel that music should be heard softer and softer, you can turn on this option and see if this is what you need, because your midi synthesizer could be ignoring the expression events because it doesn't understand them.</P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="doineedamidimap.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="usingmidimaps.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Do I need a midi map ?</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="midimaps.html" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Using midi maps</TD ></TR ></TABLE ></DIV ></BODY ></HTML >