Teaching NCSA Mosaic to recognize ABC format

This is how I taught NCSA Mosaic to play abc tunes on a sound-capable Linux PC. Most other sound-capable Unix-like machines would be quite similar, and it should be possible on non-Unix machines, too. The relevant documentation from NCSA is here.

It is also possible to configure other WWW browsers (i.e., from Netscape and Microsoft) to recognize this MIME type. There are no ABC plug-ins, and I don't expect any very soon. However, these browsers can be instructed to start up one or more of the ABC applications as helpers. I do not use commercial WWW browsers and I cannot assist with such configuration.

NCSA Mosaic under Unix

First, create a .mime.types file in your home directory containing
text/x-abc     abc
Then, create a .mailcap file in your home directory containing
text/x-abc; mimeabc %s
Finally, create a little shell script mimeabc in your bin directory
#! /bin/sh
# Bourne shell script which translates files in Chris Walshaw's ABC format
# to visible (printable) and audible forms.  This could be made much
# more cool if it were a Tcl/Tk script which gave pushbutton control
# over the viewing and playing of the music.
# It could also be rewritten to use abc2ps and ghostview.
########################################################################
#       various and sundry extra inputs for TeX, mostly for music
ABCHOME=$HOME/abc
TEXINPUTS=.:$ABCHOME/abc2mtex:$ABCHOME/musictex/macros:
export TEXINPUTS
TEXFONTS=.:$ABCHOME/musictex/tfm:
export TEXFONTS
TEXPKS=.:$ABCHOME/musictex/300pk:
export TEXPKS
XDVIFONTS=$TEXPKS
export XDVIFONTS
########################################################################
for file in $*; do
	################
	# construct the sound
	nfile=`echo $file | sed s/abc/au/`
	# sed steps around a bug in playabc 1.0 on Linux
	gawk '
		/^P:/ {
			# trim out all the TeX garbage found in P fields
			gsub("Ch"      , "A" );
			gsub("/2"      , ""  );
			gsub("\\infty" , ""  );
			gsub("[}$. ^{]", ""  );
		}
		{ print }
		END { print "" }        # add a blank line at the end (for flex)
	' < $file | playabc | tune > $nfile
	################
	# construct the picture
	abc2mtex m $file
	tex music.tex
	# alternatively, could proceed on to PostScript and use Ghostview
	xdvi music.dvi &
	/bin/rm abc2mtex.log
	/bin/rm music.tex music.log
	sleep 3
	################
	# play the sound
	showaudio $nfile
	# clean up
	/bin/rm $nfile
	/bin/rm music.dvi
	################
done
########################################################################
This assumes that Don Ward's playabc and tune programs are built and in the default search path.

You'll have to restart Mosaic before this takes effect.

Back to the WWW Morris Music page.


Steve Allen <sla@ucolick.org>