Scripts / 3D Sound effects?

Author
Message
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 13th Jun 2014 16:33
Hi all. I've been trying to get a sound effect to get louder and fainter as you get nearer or further away. For some reason I thought this was possible quite easily, but it seems there is no easy way to add a sound effect to an entity, or I have missed something obvious. So I though, okay I can probably work around it. So far, I have not got it to work though.
This script is what I have come up with so far.

It works exactly the opposite way I want it to. No surprise as it uses the distance to decide how loud to play. I'm struggling to get it to work in reverse, with my efforts failing to play anything or coming up with illegal sound volume levels. I thought all I need do is something like this. Just the idea rather than code.

Probably my newness to Lua causing me headaches. I can't be far away with that, but I couldn't get it going.



SPECS: Q6600 CPU. Nvidia 260GTX. 8 Gig Memory. Win 7.
Hockeykid
16
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 13th Jun 2014 17:14 Edited at: 13th Jun 2014 17:16
This seems to work (I didn't test it vigorously) :









EDIT: Interesting, the "PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));" line really got messed up in the code tags.



Sean

Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 13th Jun 2014 17:34
It seems the built-in LUA functions (like all from math library) are colored in white, same as code block background

The code is there, if you select that line you'll see it.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 13th Jun 2014 17:49
Yepp, that seema to work at least on an empty map and one object. Can't see any reason it won't work in a big map also though, bar bugs. Thanks!



SPECS: Q6600 CPU. Nvidia 260GTX. 8 Gig Memory. Win 7.
almightyhood
10
Years of Service
User Offline
Joined: 9th Oct 2013
Location:
Posted: 13th Jun 2014 17:53
well maybe its that range thing issue? (sorry not very technical was it). i have a script that works fine runs on my map with other scripts and such, but if i get so far into the level it stops working. i have seen tomjscott post somewhere about the hard coded range for scripts is 3000 or something? ( i don't really know what that = to in editor distance). but maybe its effecting you also?

evga GeForce gtx 750 ti boost2.0 2gb gddr5. win 8.1 quad core 4gb ram.
PM
BarZaTTacKS
10
Years of Service
User Offline
Joined: 3rd Feb 2014
Location:
Posted: 13th Jun 2014 19:46
Wouldnt setting it always on extend that range?
PM
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 15th Jun 2014 16:54
In the end this worked fine in a test scene but in my main map it caused the music to go down :0

Oddly enough I have noticed when you play a sound and move away from it it does actually fade anyway automatically, but not when you loop it. A good thing for music of course! I noticed Avram has posted a script for this but not checked it out yet. Still, ultimately we should be able to set a sound as 3D and not have to script this sort of thing as it's already built into DB.



SPECS: Q6600 CPU. Nvidia 260GTX. 8 Gig Memory. Win 7.
The Tall Man
9
Years of Service
User Offline
Joined: 24th May 2014
Location: Earth
Posted: 23rd Jun 2014 20:38
I just added a feature creep for 3D sound:
http://fpscrforum.thegamecreators.com/?m=forum_view&t=209112&b=5
PM
tomjscott
User Banned
Posted: 18th Aug 2014 22:40
You can do true 3D positional sound now in my Omega Core plugin if anyone is interested. I'll eventually add reverb effects and filters, but all basic 3D sound is working in the last version I released.

System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.0071
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 25th Sep 2014 20:49 Edited at: 25th Sep 2014 20:50
I saw a recent video of the additions to Unity's sound system and it made me jealous. You could add reverb effects and things like that based on what areas of the level you are in. Essentially once you enter various trigger zones.



There are so many possible things I'd love to see with audio in Reloaded's future.



EDIT:

Quote: "

You can do true 3D positional sound now in my Omega Core plugin if anyone is interested. I'll eventually add reverb effects and filters, but all basic 3D sound is working in the last version I released."




Some how I missed your post and its ironic you touch on the very things I'm looking for

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce 420 GT
tomjscott
User Banned
Posted: 26th Sep 2014 03:18
Quote: "Some how I missed your post and its ironic you touch on the very things I'm looking for"


Yeah, I'm beginning to think no one even wants to use it. I would have thought people would be dying to get their hands on 3D sound, but I haven't heard a peep from anyone even attempting to use this feature of my plugin. And it works quite well and isn't difficult at all.

System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.0085
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 29th Sep 2014 09:26
I think the November release for the next update might be the cause for lack of enthusiasm here, lately.

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce 420 GT
Old Larry
GameGuru TGC Backer
12
Years of Service
User Offline
Joined: 26th Apr 2012
Location: Bucharest, Romania
Posted: 1st Apr 2015 07:22 Edited at: 1st Apr 2015 07:41
You can use direct in game: Doppler, hall and more other special sound effects, without any script with the Cool Edit software then save it as wav.
Two examples made by me and free for use, in attachments...
Smile today, tomorrow could be worse

http://bestradiolarry.ro/fpsarea/

"The best forum, game software, operating system or web platform, it's that software which can give you most of the features and speed, not just amazing graphics."

Attachments

Login to view attachments
Tarkus1971
Audio Media Maker
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: England, UK
Posted: 2nd May 2015 17:55
is there anyway of checking the volume of the soundlevel before stopping the sound, as at the moment it just cuts off?

Login to post a reply

Server time is: 2024-05-07 14:10:01
Your offset time is: 2024-05-07 14:10:01