Audio devices

Top  Previous  Next

Note: differences between editions of WhiskerServer


If you have the Basic Edition of Whisker, all audio commands generate the following error from the server:


Error: command not supported by this version of WhiskerServer


or return Failure on the immediate socket.


How the server searches for media files


When the client passes a filename to the server, the server first tries to find it by appending the filename to the server's media path. (This path is configured on the server and stored in the registry.) If the server's media path is, for example, 'd:\whiskermedia', the client can then request playback of 'myclient\ping.wav' and the server will first attempt to find it as as 'd:\whiskermedia\myclient\ping.wav'.


If this attempt fails, the server will then try the filename as an absolute filename (so the client can pass, for example, 'd:\myclient\wavs\ping.wav').


Development note: these checks are performed by CWhiskerServer::MediaFilename(), not CSoundDevice.


Specifying filenames to the server


Whenever a media filename is passed to the server, it is the last parameter passed, and it may include spaces.


How the sound system works internally


The server detects a number of physical audio devices, and assigns one or more logical audio devices to each. (Normally there will be one logical device per physical device, but if you choose to use the left and right stereo channels as separate devices, you will get two logical devices per physical device.) The clients only see logical devices.


The client can claim control of logical devices and assign them aliases. (Clients always have exclusive access to logical devices that they have claimed.)


Each logical device may have a number of sounds associated with it. You can load WAV files or simple tones as sounds, giving them a name, and play them.


Audio devices may share aliases. For example, if sound device 0 has the aliases left and stereo, and sound device 1 has the aliases right and stereo, you can issue the command AudioLoadFile stereo explosion explosion.wav; AudioPlaySound stereo explosion and the sound will be played through devices 0 and 1. But the AudioLoadFile call created a sound named 'explosion' for both audio devices, so you can now also say AudioPlaySound left explosion and only device 0 will play.


Sounds may also share names – but this will lead to sounds being mixed together. You may issue the command AudioLoadFile left bignoise gunfire.wav; AudioLoadFile left bignoise crowscreech.wav; AudioPlaySound left bignoise and the guns and the crow will both make their voices heard. These commands load two sounds into one sound device but both are given the same name. (You may substitute stereo for left in this example and a veritable cacophony will arise.)


The server uses the DirectX (DirectSound) interface to control sound devices; therefore, DirectX must be installed to obtain sound support. (The devices are set to have global focus; that is, no matter which Windows program has the input focus, the sound is audible.)


Audio commands


Audio devices are controlled using the following commands: