http://www.evl.uic.edu/pape/sw/bergen/
bergen is a very simple system for playing back audio files from a program. It was originally created for use in CAVE applications, but does not depend on the CAVE library.
bergen uses a client-server model, and so consists of two parts - a client library (libbergen.a), that applications are linked with, and a separate server program (snerd), that will do the playing of sounds. Client programs communicate with snerd via a UDP network connection. This means that the server can be running on a separate machine from the client.
The basic way to use bergen in an application is:
create a bergenServer object (connection to snerd) for each sound file you want to play, create a bergenSample object call play() to start playing a bergenSample
For example:
#include <unistd.h> #include <bergenServer.h> #include <bergenSample.h> main(int argc,char **argv) { bergenServer *server; bergenSample *sound1, *sound2; server = new bergenServer; sound1 = new bergenSample("loopsound.wav", server); sound2 = new bergenSample("othersound.wav", server); sound1->setLoop(1); sound1->play(); sleep(1); sound1->setAmplitude(0.25); sound2->play(); sleep(1); delete server; }
The server program snerd must be started before the client program is run. snerd should be run from the directory that contains the sound files you are going to play. It has a command line argument, -srate, that can be used to control what sample rate to play sounds at (e.g. snerd -srate 44100). For best quality, this rate should be the same as that of the sound files.
The main bergenSample functions that you will use are:
Example: bergen0.cpp
Note that sounds can be created and deleted at any time. Also, you can change the amplitude of a sound as often as you like; this can be used to make the sound very dynamic, or even to create a basic spatialization effect, by making the amplitude a function of the distance from the camera to an object.
Example: bergen1.cpp
The files for bergen are located in /util/bergen/linux on the DMS Linux PCs.
To compile a program with bergen, add pointers to the lib & include
directories to your Makefile. Add -I/util/bergen/linux/include to your
compile flags (CFLAGS or CPPFLAGS), and -L/util/bergen/linux/lib -lbergen
to your link libraries (LIBS).
For example:
CFLAGS = -O -I/home/dms/dave/424/include -I/util/bergen/linux/include CPPFLAGS = $(CFLAGS) LFLAGS = -O LIBS = -L/home/dms/dave/424/lib -ldms -limage -ltiff \ -L/util/bergen/linux/lib -lbergen \ -lglut -lGLU -lGL -L/usr/X11R6/lib -lX11 -lm bergen0: bergen0.o c++ $(LFLAGS) -o bergen0 bergen0.o $(LIBS)