Results 1 to 6 of 6

Thread: [OpenAL] Maximum distance at which sound can be heard

  1. #1

    [OpenAL] Maximum distance at which sound can be heard

    How exactly do i set the max distance at which the sound can be heard? i checked out AL_MAX_DISTANCE, but the default constant for that is max float which makes little sense to me, i just want to make the sound play in 1:1 gain at distance up to 1, and then fade out completely at distance of 2, how is this stuff set up in openal?
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  2. #2

    [OpenAL] Maximum distance at which sound can be heard

    Look at the following functions:

    SetListenerGain
    0 is not heard
    1 is no attenuation
    values between 0..1 give attenuation

    Also use SetDistanceModel to set the proper distance model.
    None
    Bypasses distance attenuation for all sound sources.

    InverseDistance
    Inverse distance attenuation described by the following formula:

    Gain = ReferenceDistance / (ReferenceDistance + RolloffFactor * (Distance – ReferenceDistance)

    InverseDistanceClamped
    Essentially the InverseDistance model extended to guarantee that for distances below the ReferenceDistance, gain is clamped.

    But there is more:
    SetSoundReferenceDistance
    SetSoundRolloffFactor
    SetSoundMaxDistance

    Do have a read on the manual that comes with the creative sdk. That is better capeable of explaining this.
    http://3das.noeska.com - create adventure games without programming

  3. #3
    For the record, solution is:

    1. use a proper distance model.

    alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);

    2. sources need AL_MAX_DISTANCE - you can also add AL_REFERENCE_DISTANCE and AL_ROLLOFF_FACTOR for good measure to have better effects.

    3. AL_ORIENTATION must be correctly set on listener!!

    Yes, i'm replying to my own thread from 2008, i only now correctly solved this properly.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  4. #4
    Quote Originally Posted by JernejL View Post
    Yes, i'm replying to my own thread from 2008, i only now correctly solved this properly.
    There is nothing wrong about this. Your answer may help others to spend so much time looking for correct solution as you did

  5. #5
    Exactly this thread actually popped up in google when searching, so i hope it helps someone.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  6. #6
    Thank you for sharing the solution after all these years, it helped my friend !


    Mini Militia App Lock 7Zip
    Last edited by casanova; 05-12-2019 at 02:00 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •