Index of /knowledgemedia/PLAYERS/UNIX/RPLAY

      Name                    Last modified       Size  Description

[DIR] Parent Directory 11-Jun-2003 14:45 - [TXT] INSTALL 11-Jun-2003 14:45 1k [TXT] LIBRPLAY.C 11-Jun-2003 14:45 6k [TXT] LIBST.C 11-Jun-2003 14:45 3k [TXT] LIBST.H 11-Jun-2003 14:45 3k [TXT] MAKEFILE 11-Jun-2003 14:45 2k [TXT] RPLAY.C 11-Jun-2003 14:45 2k [TXT] RPLAY.H 11-Jun-2003 14:45 2k [TXT] RPLAYD.C 11-Jun-2003 14:45 8k [TXT] VERSION.H 11-Jun-2003 14:45 1k [TXT] WARNING 11-Jun-2003 14:45 1k

This is rplay2.0 which provides the ability to rplay sounds on both
local and remote Sun workstations with sound support.  This version
of rplay is not compatible will the older versions of rplay but
as you will see it is much better.  For installation instructions
see INSTALL.

Major features of rplay2.0:
	- Sounds are no longer indexed by id, the sound names are now used.

	- Sounds can be played, paused, continued, and stopped.

	- Each sound can have a volume associated with it.  A volume is
	  a number between 0 and 255 and it is relative to the actual volume
	  of the audio device.

	- Sequences of sounds are supported.  This is useful for playing
	  sentences or sounds that need to be played sequentially.

	- mmap is now used to read sounds.  This increases performance
	  and saves a lot of memory.  Thanks to stripes@pix.com for this
	  suggestion.

	- Broadcasting sounds.  To use this just use a broadcast address
	  instead of a hostname.  For example, I use:
		rplay 130.191.255.255 burp.au
	  to play burp.au on all our machines running rplayd on our subnet.

	- The Sun audio stuff is no longer used.  Thanks to libst.c and 
	  libst.h from Sound Tools.  See these files for more information.

Now that sound ids are not used, the rplay.conf file is just a list of
pathnames for all the sound files.  I run the following cron job to update
my rplay.conf file every morning:

57 5 * * * find /usr/local/sounds -name '*.au' -print > /usr/local/etc/rplay.conf

The new rplay library includes the following functions:

	RPLAY	*rplay_create() - create an rplay packet

	rplay_destroy(rp) - free memory used by rp
	RPLAY	*rp;

	rplay_set(rp, ...) - set rplay attributes
	RPLAY	*rp;

	int rplay_open(host) - return a UDP socket for the host
	char	*host;

	rplay(rplay_fd, rp) - send a rplay packet to a host
	int	rplay_fd;
	RPLAY	*rp;

	rplay_close(rplay_fd) - close the UDP socket
	int	rplay_fd;

	rplay_perror(s) - report an rplay error to stderr
	char	*s;

Here are some examples using the rplay library:

	int	rplay_fd;
	RPLAY	*rp;

	rp = rplay_create();
	if (rp == NULL) {
		rplay_perror("rplay_create");
		exit(1);
	}

	rplay_fd = rplay_open("sounds.sdsu.edu");
	if (rplay_fd < 0) {
		rplay_perror("rplay_open");
		exit(1);
	}

	/*
	 * play one sound
	 */
	rplay_set(rp, RPLAY_PLAY,
		"burp.au",
		NULL);
	rplay(rplay_fd, rp);

	/*
	 * play the list of sounds sequentially 
	 */
	rplay_set(rp, RPLAY_PLAY,
		"burp.au",
		"beep.au",
		"boom.au",
		"Passing_Train.au",
		NULL);
	rplay(rplay_fd, rp);

	/*
	 * set one sound then append another
	 */
	rplay_set(rp, RPLAY_PLAY,
		"burp.au",
		NULL);
	rplay_set(rp, RPLAY_APPEND_PLAY,
		"beep.au",
		NULL);
	rplay(rplay_fd, rp);

	/*
	 * play a sound with a volume
	 */
	rplay_set(rp, RPLAY_VOLUME_PLAY,
		"burp.au",	255,
		NULL);
	rplay(rplay_fd, rp);

	/*
	 * stop a sound that is playing
	 */
	rplay_set(rp, RPLAY_STOP,
		"burp.au",
		NULL);
	rplay(rplay_fd, rp);

There are more rplay attributes that can be used with rplay_set, see
rplay.h for the list.  It is very important that you always NULL terminate
the rplay_set argument list.  One other thing that might be peculiar is
that when stopping, pausing, and continuing sound lists, the exact sound
list must be sent to rplayd.

I have used rplay to add sounds to many programs, patches will soon be
available for the newest version of xtank.

If you are looking for sound files, sounds.sdsu.edu has about 300 Megs of
sound files available via anonymous ftp.

Have fun, let me know of any problems or suggestions.
 
Mark
boyns@sciences.sdsu.edu