Try my new website:
www.urcho.com
- the new SIMPLE social network
Sign up
|
284
members |
114
snippets
Search for:
ALL
POPULAR
File Controls
Multiplayer Code
2D Effects
3D Effects
Oldskool demos
Basic Functions
Maths/Physics
Sound
Tutorials
Misc
Username:
Password:
Sign up
PlaySound (better)
[
back
]
Author:
frostbyte
| Viewed:
912
times | Language:
BlitzMax
| Category:
Sound
Function PlaySoundBetter(sound:TSound,soundx:Int,soundy:Int,originx:Int,originy:Int,volspread:Float) Local channel:TChannel Local volume:Float Local panvalue:Float channel:TChannel = AllocChannel() ' allocate a channel volume# = (1 - ((GetDistance#(originx,originy,soundx,soundy) * (1 - volspread#)) / 100)) panvalue# = (2 * ((soundx / GraphicsWidth())) - 1) If panvalue# < -1 panvalue# = -1 If panvalue# > 1 panvalue# = 1 SetChannelRate(channel:TChannel,Rnd(.8,1.2)) ' make each sound original SetChannelVolume(channel:TChannel,volume#) SetChannelPan(channel:TChannel,panvalue#) If volume# > 0 PlaySound(sound:TSound,channel:TChannel) ' play sound End Function
Author Comments:
This function pans a given sound based on its x and y coordinates. It also changes the volume based on how far away it is from an origin point. Last, it has a volume spread that tells how fast the volume decreases by how far away it is from the origin point. * and you need the distance formula for this, sorry...
Login or
create an account
to comment on this snippet