This is the sound package for ZMP.
Sound can provide many benefits to a game. Music can set the tone and enhance the atmosphere of the game, while general sound effects can provide additional clues to the environment and increase the immersion of the player.
Despite the advantages of sound in a game, it is important that clients implementing the sound package allowed all features to be disabled at the user's request. Sound can, at times, be unwanted.
There are a variety of formats that sound can be delivered in. Each format has its own strengths and weaknesses. In order to maximize the compatibility between clients and servers, the sound format used by the sound package will always be Ogg Vorbis.
The Ogg Vorbis has several key advantages over competing formats. The first advantage is a decent compression rate, comparable to the MP3 format. Ogg Vorbis also offers very good sound quality. The most important advantage, however, is that the Ogg Vorbis format is entirely free to implement. Formats which are currently more popular, such as MP3, cannot be legally added to many clients due to the licensing restrictions. Code libraries for using Ogg Vorbis are available for every major platform.
Each game will usually feature its own unique sounds. For this reason it is important the games be able to tell clients where to fetch the sounds used by the game. This set of sounds is called a sound font.
Sound fonts are collections of Ogg Vorbis files in a ZIP archive. All Ogg Vorbis files in the archive must have the .ogg extension. All file and directory names must be lower case. Any files in the archive with a different extension are not sound files and must be ignored by clients. Directories may be used within the archive.
Sound fonts must be made available over anonymous FTP or HTTP. SSL versions of these protocols must not be used.
When a sound name is specified in any of the sound package commands, the name of a sound is equal to its path within the font archive, with the .ogg extension stripped. For example, a file in the combat/ directory named sword.ogg would have the sound name combat/sword.
The sound.font command is used by the server to tell the client where the game's sound font is located. The command must only be sent from the server to the client.
The command takes a single argument, which is the fully-qualified URL of the sound font to be used by the game.
This command sets the background music. The command must only be sent from the server to the client. The sound.music command takes two arguments. The first is the sound name to be played. The second is a number specifying how many tenths of a second it should take for the music to be faded in from zero volume to full volume. The second argument must be a non-negative integer.
When another sound is already being played as music, the client must replace that sound with the new one specified by the most recent sound.music command.
When the first argument of the command is empty then any currently playing music sound should be stopped. The fade-in argument then becomes a fade-out argument.
Clients should honor the fade-in argument. When one sound is playing another, clients should fade out the original while fading in the new sound.
The sound.play command tells the client to play a specific sound. The command must only be sent from the server to the client. The first argument is the sound name to play. The second argument is the number of times the sound should be played. The second argument must be a positive integer.
There is no way to ask a sound to play for an infinite number of loops. The sound.music command should be used for infinitely looping background music.
The sound.stop command tells the client to stop playing all sounds, except the background music. The command must only be sent from the server to the client. The command has no arguments. Upon receiving this command, the must stop any currently playing sounds, but must not stop the currently playing background music.
To stop the currently playing background music, send a sound.music command with an empty first argument and zero (0) as the second argument.
This document is the copyrighted work of AwesomePlay Productions, Inc.
AwesomePlay Productions, Inc. offers limited rights to recipients of this document to distribute unmodified copies of the document in electronic form, print form, or any other medium. Implementations of the protocol described in this document are wholly owned by their creators, and the implementations are not derivative works of this document and they not subject to the terms of this license.
This work is licensed under a Creative Commons License.