Skip to main content
gamedev.net
🔒 Locked

OpenAL distance scaling

Started by DrWhatsisname 0 replies 1.6k views
Original Post
DrWhatsisname
DrWhatsisname

I am working on a project in lwjgl which uses OpenAL for its audio. The library seems to be primarily built for 3D sound, but I am attempting to use it in a 2D game. I'm having an issue where OpenAL seems to be interpreting the distances and velocities that I give as much larger than they need to be.

j2g3nDW.png

The picture above is a screen shot from the game. Its a top-down shooter and the enemies really aren't that far away. I'm playing a firing sound from the location of each of the enemies you see on screen whenever they fire a shot, but when they do, it is essentially inaudible. If I turn up the volume and move towards or away from the enemies as they fire, the pitch of the sound will bend (due to the Doppler shift) outside of the audible range, or potentially the frequency range of my speakers.

I have tried explicitly setting the AL_REFERENCE_DISTANCE and AL_MAX_DISTANCE values to 1.0f and the max value of a float respectively which does nothing presumably since these are the default values. The problem could potentially have to do with the fact that my coordinates are in terms of pixels, so the enemies on screen are some 250 units away and the player is moving at 240 units per second. Is this a cause of the problem? How can I fix it?

Khatharr
Khatharr
Which distance model are you using and what is AL_ROLLOFF_FACTOR set to?
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.