GVU AudioLab DirectSound3D Functions Documentation
Jarrell Pair, 2 August 1998
These functions simplify the task of exploiting Microsoft's DirectSound3D Library. They are designed to work with any system with DirectX installed. These functions have been successfully tested on machines running Windows NT, Windows 95, and Windows 98
void InitAudioEngine(HWND hWnd, bool spatialflag)
-This function must be called before calling any other audio functions
-HWND hWnd is the handle of the windows application
-set spatialflag true to use any 3D sound functions
-set spatialflag false if no position, distance, volume, or doppler functions are to be used
Int LoadAudio(HWND hWnd, LPSTR soundfile, bool spatialflag)
-Loads a .wav soundfile
-HWND hWnd is the handle of the windows application
-set spatialflag true to use any 3D sound functions with the loaded sound
-set spatialflag false if no position, distance, volume, or doppler functions are to be used with the loaded sound
-Example:
helicopterID = LoadAudio(hWnd,"helicopter.wav", TRUE)
Opens file "helicopter.wav" and assigns it the ID "helicopterID" with 3D sound capabilities
void PlayAudioObject(int ID, bool LOOP)
-Plays the sound indicated by ID
-set LOOP true to play sound looped
-set LOOP false to plays sound once
-Example:
PlayAudioObject(helicopterID, TRUE)
void StopAudioObject(int ID)
-Stops the sound indicated by ID
-Example:
StopAudioObject(helicopterID)
void SetAudioObjectVolume(long volume, int ID)
-sets the volume of an audio object
-volume can range from 0 (no attenuation) to -10000 (complete silence)
-amplification is not supported
Example:
SetAudioObjectVolume(-1000, helicopterID)
void SetAudioObjectPosition(LONG x, LONG y, LONG z, int ID);
-Sets the x,y,z coordinate position of an audio object
-Example:
SetAudioObjectPosition(0, 0, 0, helicopterID)
Sets helicopter sound position to 0,0,0
void SetAudioListenerPosition(long x, long y, long z)
-Sets the position of the listener
-The listener’s position can be moved independently of an audio object positioned with SVE_audioSetPosition
-The listener is roughly equivalent to the 3D world’s camera object
-Example:
SetAudioListenerPosition(0, 0, 0)
Sets the listener’s position to 0,0,0
void AudioDistance(float distfactor, float rollfactor, float maxdist, float mindist, int ID)
-This function can be used to exaggerate and control the effects of distance on an audio object
-distfactor can be effectively set from .01 to 10
-a distfactor of 1 means moving the sound by 1 increment is equivalent to moving a sound by 1 meter in the real world
-distfactor is global in scope, affecting all sounds
-rollfactor can be effectively set from .01 to 10
-a rollfactor of zero minimizes distance attenuation
-a rollfactor of 2 doubles the default distance attenuation
-rollfactor is global in scope, affecting all sounds
-maxdist and mindist define the range over which a sound’s volume varies
-a maxdist of 100 sets a sound’s minimal volume at a distance of 100:
-a mindist of 1 sets a sound’s maximum volume at a distance of 1
-maxdist and mindist are local in scope, applying only to the sound designated by ID
void AudioDoppler(float factor, float velocity, int ID)
-This function is effective only on systems with audio accelerator cards
-This function can be used to exaggerate and control the effects of doppler shifting
-factor sets the degree to which the function emulates real world doppler conditions
-a factor of 2 sets doppler effects at twice those experienced in real world conditions
-velocity sets the speed at which the audio object is moving
void AudioCone(float orientationx, float orientationy, float orientationz, DWORD InsideConeAngle, DWORD OutsideConeAngle, long outsidevolume, int ID)
-This function is most effective on systems with audio acceleration hardware. However, it is functional on most systems lacking a dedicated audio accelerator.
-This function defines an audio projection cone which can be used to define the area under which a sound is audible
-A cone consists of an inner and an outer cone. While a listener is inside the inner cone, the sound is at full volume. While passing through the outer cone, the sound’s volume drops. Once outside the cone, the sound is at the level set by outsideconevolume
-orientationx, orientationy, and orientationz define a vector which sets the cone’s orientation
-InsideConeAngle, and OutsideConeAngle set the cone’s inside and outside angle
-outsidevolume sets the volume of the sound outside the cone. The value can range from 0 (no attenuation) to –10000 (complete silence)
Amplification is not supported
-Example:
AudioCone(0, -1, 0, 60, 60, -10000, helicopterID)
The helicopter sound is set:
-with an orientation vector of (0, -1, 0) to point the sound downward
-with an inner cone and outer cone angles of 60 degrees to have a 60 degree cone with no attenuation between outer and inner cone
-with a outside volume of –10000 so as to not be heard outside the cone
Implementation Guidelines
-The effectiveness of a 3d audio environment is highly dependent on the audio hardware and system resources.
-When handling a 3d audio effect function call, the system first attempts to process the call using the available audio hardware. If the audio hardware lacks sufficient processing resources, the effect is handled using software algorithms. If resources are inadequate to handle the call in software, the 3d audio effect function call is ignored. As a result, the sound is played back absent of any effects.
-To optimize playback on a system, never use stereo .wav files as 3d audio sources. The 3d audio subsystem automatically remixes all stereo sound files to a mono format resulting in substantial performance degradation. Also, on systems lacking hardware acceleration, it is best to format all 3d sounds as 22kHz 16-bit mono, or 22kHz -bit mono.
-The effects of noisy audio hardware are exaggerated when using calls to the 3d audio subsystem. Dedicated audio acceleration cards minimize these problems.
-Most pentium class PC's have adequate processing resources for processing volume change calls to 2d and 3d sound buffers as well as any audio positioning calls. Performance can degrade as the number of simultaneous 3d sounds played back increases. The number of 3d sounds that can be effectively spatialized is again a function of the CPU speed, RAM resources, and audio hardware on a particular system.