[aquaria] [patch] Positional audio support
    False.Genesis 
    false.genesis at googlemail.com
       
    Sat Nov 26 15:33:27 EST 2011
    
    
  
This patch adds support for sound panning, distance volume control, and 
pitch shifting. This affects the following cases:
Internal:
- shot fire/impact sounds
- Entity::sound(): death sounds, entity_checkSplash sound, and some 
other cases
Lua:
- entity_sound (now deprecated - but correctly plays positional audio, 
at least)
- entity_soundFreq (now an alias for entity_sound)
- playSfx (added optional x,y position and max distance)
- entity_playSfx (now with many additional parameters in the same style 
as playSfx)
Fun fact: Most of the code was there, and *would* have worked if there 
were no float->int truncations all over the place, and the actual 
Channel::setPan/setFrequency() calls had been there.
Support for this could probably be improved in various places of the 
code, but i am happy enough with what already works.
The effect of this patch is very noticeable with moneye entities - their 
thrust sound was cut off after a distance of 1024, now it gets more and 
more muffled with an increasing distance.
And audible feedback from which direction a shot is coming - try this in 
a fight with a greenseadragon.
Attached is an entity script for quick sound testing - it sticks to the 
mouse and produces sound with random pitch.
I figured it would be necessary to split stereo OGGs into mono to suport 
L/R panning, because OpenAL outright refuses to apply distance to stereo 
tracks (At least my OpenALSoft/win32 version does).
But since that would require 2 channels per stereo sound, additional 
hackery to split each sample pair into seperate buffers for L & R, and 
the sound system is not made for more than one channel per playback 
instance, i didn't attempt to implement this. At least the volume fades 
with the distance.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: soundcheck.lua
URL: <http://icculus.org/pipermail/aquaria/attachments/20111126/fbb88176/attachment.diff>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: positionalsound.patch
URL: <http://icculus.org/pipermail/aquaria/attachments/20111126/fbb88176/attachment-0001.diff>
    
    
More information about the aquaria
mailing list