Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / so... i wanna try making 3d sounds

Author
Message
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 8th Jan 2016 15:56
I wanna try simulating some 3d sound in a 3d environment. I can use a 3d distance to calculate volume but what would the best method be for stereo pan?

I know from experience that angles can be tricky since it wraps at 360deg. Anyone got a good function to grab 2 angles and compare differences?

Sign up for NaGaCreMo!
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Jan 2016 16:02
Subtract 1 angle from the other, then wrap the result around a -180 to 180 value, and that would be the pan. It's easier in DBPro with it's WRAPVALUE command, but basically you're working out the difference then allowing for the 360 degrees rotation by converting to -180 to 180 instead.

I'm sure I can make a small example for you if your stuck.
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 8th Jan 2016 16:54
actually.... mabey im looking for something simular to normals....
except i need a 2d normal. i could try to calculate the direction im facing x,z and then just set the sound pan accordingly. Im going to lookup some 2d vector stuff right now.

i have the distance with volume working perfectly now.... just need to figure out sound balance.

Sign up for NaGaCreMo!
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 8th Jan 2016 22:44
AND, don't forget to slightly increase the frequency of the sample for sounds moving towards you, and reduce the frequency if moving away (based on speed). This should give a nice Doppler effect (and easy to do with SetSoundInstanceRate)
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 9th Jan 2016 05:15
humm... never thought of that.

would the sound rate be normal if it was closeup and lower rate as its moved away?
i have a mock up 3d sound working now with distance fall off (volume) and speaker balance.

Ill try that out and see how it sounds cheers!

Sign up for NaGaCreMo!
JohnStabler
AGK Bronze Backer
11
Years of Service
User Offline
Joined: 16th Aug 2013
Location: Cardiff, Wales, UK
Posted: 13th Jan 2016 16:44
A tip for fake 3D sound:

If you want to make something sound like it is behind you then play the same sound twice, but one of them at a slightly different rate. Works well unless it is a looped sound because they will eventually go out of sync and sound odd.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 14th Jan 2016 09:08
It really depends on how realistic you want the sound to be. The sound should hit each ear at a slightly different time depending on the direction it is coming from (the time it takes for the sound to reach one ear will be slightly different than the other unless the sound is directly in front or behind you). Also the sound should be brighter at the closest ear as it isn't beind muffled by your head. Sounds can also reflect off flat surfaces to create echos etc. I think for your average FPS, just getting louder the closer you get is probably good enough.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 29th Jan 2016 19:23
Yeah getting closer was easy to code. I did manage to get balance to also work based on distance from each side of your character. I set it up so it only verried 25 percent careful not to cut off 1 speaker entirely. It sounds good enough for what i was trying to do anyways.

Thanks for the tips

Sign up for NaGaCreMo!

Login to post a reply

Server time is: 2024-11-25 11:16:14
Your offset time is: 2024-11-25 11:16:14