This directory contains patched source of xglk-0.4.11
(http://www.eblong.com/zarf/glk/). I've added rudimentary sound
handlers to enable xglk to play AIFF sounds and MOD files.  The design
is very loosely coupled -- each audio channel opened spawns a child
process to handle the sound effect.  Unix pipes connect back to the
parent glk application which issues commands ("play', "repeat",
"volume", etc) -- hence providing asynchronous control flow.

Source for the two helper programs are included. Compile them thus:

   gcc -o glksndplay glksndplay.c -lesd
   gcc -o glkmodplay glkmodplay.c -lmikmod

and place the executables in a directory listed in your $PATH.  You will
need to have installed the development files for libmikmod and esd.

Using the Enlightened Sound Daemon (esd)

Both helper programs are esd aware so multiple channels can be
supported with the added bonus of xglk applications being able to work
well with the GNOME desktop.  Make sure esd is running before starting
your glk application. Depending on your distro, you may have to
install the esound RPM.




Audio Problems with ESD?

I've been alerted to serious shortcomings of esd.  It sucks at
converting sampling rates -- 16kHz audio sent to a 44.1kHz esd
introduces a helluvalotta noise.  Thus, the reason for doing
resampling prior to sending to esd.

The AIFF handler uses linear interpolation to adjust frequencies (esd
is crap at adjusting frequencies) and then applies a low pass filter
to get rid of high freq noise introduced by the interpolation. The
filter needs a little more work. You can go back to the sox based
handler glksoxplay.c should this be a problem.

Also, on some machines esd makes rather embarrassing noises when
changing from idle state (no sounds playing) to active (sounds
playing).  I've found that the only way to prevent this is to keep esd
active continuously. Create a file filled with zeroes:

   awk 'BEGIN{ for(i=0;i<1024;i++) printf("%c",0); }' >zerofile

then feed this to esd in an infinite loop:

   esdloop zerofile

This keeps esd busy playing silence.  Any sounds sent by xglk will
meet an already warmed up esd so no awful transition noises should be
heard.




Using the "analog realtime synthesizer" (aRts)

Esd leaves much to be desired so why not use aRts instead?  The Analog
RealTime Synthesizer sound system is part of the KDE desktop
environment and is responsible for handling audio media streams.  If
you'd rather use xglk applications with KDE, recompile the sound
handlers to use aRts.  Change the line in glkmodplay.c and
glksndplay.c where USE_ARTS is defined to read:

#define USE_ARTS 1

then recompile:

   gcc -o glksndplay glksndplay.c -larts
   gcc -o glkmodplay glkmodplay.c -lmikmod

You'll need to have the libarts development package installed.  You
may need to add -I/usr/include/kde on some distros (e.g. Debian) for
glksndplay to compile properly.  The libmikmod library must support
the "pipe" output driver.  This may be lacking in some older versions.
Make sure the "artsd" sound daemon is running in the background when
the xglk application executes.




Recent changes:

* Sound Notification added (2001-10-27)
  Another pipe returns status messages from the handler back to xglk
  thus informing the parent when to send sound notifications

* Replaced sox's AIFF converted with my own implementation. Plays AIFF files
  while ignoring MARK and INST chunks; Plus some buggy files can be played.
  Also integrated code of esdcat into the glksndplay source (no more pipes)
  (2001-11-04)

* aRts support added (2001-11-17)




Bugs:

* SONG support has not yet been implemented.

TODO:

* SONG support

* replace ESD mixer perhaps? ESD doesn't handle sound at a variety of sample
  rates very well

Adrian Chung (ajchung@email.com)
(17th November 2001)

