Details about Bergen and Snerd

"Bergen" and "Snerd" are the two software components that provide the basic Ygdrasil sound functionality. The two together are also called the "Bergen Sound Server." Snerd is the actual sound server (the application that actually plays sounds), while Bergen is a set of components that can be included in another application to communicate with Snerd over the network. All communication with Snerd takes place over the network, even if both are running on the same machine. Bergen and Snerd can be built into any application to provide networked sound playback capability, but they are most often found as part of Ygdrasil.

The Snerd Daemon

In versions of Bergen older than Bergen 0.5, Snerd was just part of the Ygdrasil directory instead of being in its own directory - i.e., /usr/local/yg
/bin.linux/snerd
Snerd is a standalone program that runs in the background, known in Unix as a Daemon. It receives commands over the network, and plays sounds. Snerd is usually kept in the Bergen directory, such as:

/usr/local/bergen/bin.linux/snerd

Snerd is usually launched from the RUN script. The RUN script sets environment variables to tell where snerd is located, then launches it in the background right before launching YG. After YG quits, the RUN script kills the snerd daemon before exiting completely. If YG quits or crashes and the sound keeps playing, the line killall snerd will quit the Snerd sound server.

Bergen, and How it Communicates with Snerd

Bergen is a library of C++ classes that control Snerd over the network. The YG sound node contains a bergen sound object which communicates with Snerd, sending it names of sample files, amplitudes, and location information. This update process happens continuously while Ygdrasil is running, sending a steady stream of data to Snerd so it can localize sounds appropriately. This data stream is sent using UDP.

Using Snerd on a Remote Sound Server

Scenes with large amounts of audio can get pretty heavy, especially when combined with complex graphics. To speed things up, you can have a second computer handle the sound, so the main Ygdrasil machine can focus on simulation and graphics display. In this case, the "Sound Server" refers to the Snerd application AND to the second computer it's running on.

  1. set up a second linux box; let's call the main YG box "spectacle" and the sound server "euphonium".
  2. install Bergen on euphonium, in /usr/local/bergen.
  3. find out what euphonium's IP address is
  4. on euphonium, go ahead and run snerd:

    /usr/local/bergen/bin.linux/snerd

    It doesn't print out any output. When you want to quit it, just hit CTRL-C.
  5. Back on spectacle, edit your RUN script. Comment out the line that launches snerd locally, and set the YG_SOUND_SERVER environment variable to euphonium's IP address.

See the chapter on Installing Ygdrasil for more details about the directory structure, how to download, compile, and install Bergen and Snerd.

(c) Ben Chang