vgplay.c implements the player side of Replaygain as a drop in replacement for the libvorbisfile function ov_read(). It applies decibel gain values as a scale factor, as well as providing a preamp and either scale limiting or hard limiting, to prevent clipping. The final scale factor is applied to the the floating point output of the vorbis decoder, before being packed as regular integer PCM in a variety of possible word length, sign and endian configurations using the same packing code as ov_read(). Hence, with replaygain, the preamp and limiting disabled, vgplay_read() behaves exactly the same as ov_read().
vgplay is designed to be able to have any of it's features toggled and acted on while playing, and to make the transition between one set of settings and another smooth; all you have to do is specify the time in seconds to make the transition over. It doesn't try to make smooth transitions between tracks, but album gain accomplishes that where you typically need it. It does, as a side effect, have fade up and fade down functions that could be used by a player's crossfading engine (though this is untested at present).
It has a GNU Savannah page, but if you're here, you probably want to cut straight to downloading the latest stable version.
Patches:
Related software and reading: