This is my first attempt at elisp so it is probably not
very well written (clues will be gratefully received :)
but it seems to do a reasonable job.

If you put the file in your site-lisp directory (probably
in /usr/share/emacs or /usr/local/share/emacs) you can
use it be adding this line to your ~/.emacs:

 (autoload 'midge-mode "midge-mode")

Otherwise you need the full path:

 (autoload 'midge-mode "/some/directory/midge-mode.el")

To associate *.mg and *.mgh with midge-mode add this line:

 (setq auto-mode-alist (cons '("\\.mgh?$" . midge-mode) auto-mode-alist))

The menus have only been tested in FSF emacs and may not
work with other versions. If they cause problems, they
can be disabled with:

 (setq midge-use-menus nil)

in your ~/.emacs, or the variable can be changed in the elisp source.

=> Variables <=

  midge-compiler		path to the midge executable

	default: "midge"

  midge-decompiler		path to the midi2mg executable

	default: "midi2mg"

  midge-midi-player		path to a command line midi player

	default: undefined

  These variables can be set in your ~/.emacs with eg:
  (setq midge-midi-player "playmidi")


=> Commands <=

Here is a list of keybindings with brief descriptions of the commands:

key             binding
---             -------

TAB		midge-indent-line

	indents current line to the correct level.

}		midge-close-bracket

	inserts closing bracket `}' indenting if neccesary.

C-c C-c		Prefix Command

	for multi line inserts

C-c C-c c	midge-choose-block
C-c C-c a	midge-chain-block
C-c C-c t	midge-tuplet-block
C-c C-c d	midge-define-block
C-c C-c b	midge-bend-block
C-c C-c r	midge-repeat-block
C-c C-c n	midge-channel-block
C-c C-c g	midge-body-block
C-c C-c h	midge-head-block

	these functions insert a blank block of the
	apropriate type, prompting for any variables
	(eg channel number). The new block is indented
	to the correct level and point is placed between
	the `{}' brackets.

C-c C-d		Prefix Command

	for single line block inserts

C-c C-d c	midge-choose-line
C-c C-d t	midge-tuplet-line
C-c C-d d	midge-define-line
C-c C-d b	midge-bend-line
C-c C-d r	midge-repeat-line

	These functions do the same as the `block' versions
	but they put all the inserted text on a single line.

C-c C-f         Prefix Command

        for inserting values

C-c C-f p       midge-select-patch
C-c C-f d       midge-select-drum
C-c C-f s       midge-select-scale

        These functions allow patch, drum and scale names to
        be chosen from a menu by typing the number of the
        required selection in the minibuffer.

C-c C-f t       midge-insert-tempo
C-c C-f g       midge-insert-time-sig
C-c C-f v       midge-insert-volume
C-c C-f y       midge-insert-pan
C-c C-f r       midge-insert-reverb
C-c C-f c       midge-insert-chorus

        These functions insert prompt for a value and insert
        the relevent keyword and value if it is valid.

C-c C-v		Prefix Command

	for compile/play/decompile commands.

C-c C-v C-f	midge-compile-ask

	prompt for options

C-c C-v C-d	midge-compile-debug
C-c C-v C-v	midge-compile-verbose

	use debug/verbose options

C-c C-v C-c	midge-compile

	use no options

	note: `midge-compiler' must be set correctly
	      to use any of the compile commands.

C-c C-v C-m	midge-decompile

	prompt for a midi file to decompile into a new buffer.

	note: `midge-decompiler' must be set correctly
              to use this command.

C-c C-v C-p	midge-play-background
C-c C-v C-l	midge-play-foreground

	play midi file generated from current source file.

C-c C-v C-o	midge-play-ask-background
C-c C-v C-k	midge-play-ask-foreground

	prompt for midi file to play.

	playing in the foreground causes emacs to wait untill
	the player process exits (C-g will kill it), whereas
	playing in the background lets you continue editing
	but you can't kill the player process as easily (it
        can be done with "C-c C-c" in the pocess buffer).

	note: you must have `midge-midi-player' set to a
              command line midi player to use any of the
              play commands.
