Giter Club home page Giter Club logo

Comments (4)

walbourn avatar walbourn commented on May 27, 2024

You control this through the standard X3DAUDIO_LISTENER and X3DAUDIO_EMITTER structures. DirectX Tool Kit for Audio has derived helper classes AudioListener and AudioEmitter.

The fall-off curves are provided via the X3DAUDIO_EMITTER structure per Microsoft Learn.

  X3DAUDIO_DISTANCE_CURVE *pVolumeCurve;
  X3DAUDIO_DISTANCE_CURVE *pLFECurve;
  X3DAUDIO_DISTANCE_CURVE *pLPFDirectCurve;
  X3DAUDIO_DISTANCE_CURVE *pLPFReverbCurve;
  X3DAUDIO_DISTANCE_CURVE *pReverbCurve;

Default curves are used if these pointers are nullptr per the documentation which are generally 'square-of-distance'. There is a helper AudioEmitter::EnableDefaultCurves which will instead set a number of built-in curves which are consistent with those used by legacy XACT which uses linear falloff. You can also provide pointers to your own custom curves.

https://github.com/microsoft/DirectXTK/wiki/AudioEmitter#custom-distance-curves

from directxtk.

CallumCVM avatar CallumCVM commented on May 27, 2024

@walbourn I checked the function EnableDefaultCurves that you mentioned and it sets a volume curve that is 1.0f at a distance of both 0.0f AND 1.0f (aka max volume regardless of distance). Is this intentional? It doesn't seem to match the description you gave of it having linear falloff.

from directxtk.

walbourn avatar walbourn commented on May 27, 2024

EnableDefaultCurves is implemented based on this code from XACT:

        if (SUCCEEDED(hr)) {
            static X3DAUDIO_DISTANCE_CURVE_POINT DefaultCurvePoints[2] = { 0.0f, 1.0f, 1.0f, 1.0f };
            static X3DAUDIO_DISTANCE_CURVE       DefaultCurve          = { (X3DAUDIO_DISTANCE_CURVE_POINT*)&DefaultCurvePoints[0], 2 };
            if (pEmitter->pVolumeCurve == NULL) {
                pEmitter->pVolumeCurve = &DefaultCurve;
            }
            if (pEmitter->pLFECurve == NULL) {
                pEmitter->pLFECurve = &DefaultCurve;
            }

            X3DAudioCalculate(X3DInstance, pListener, pEmitter, (X3DAUDIO_CALCULATE_MATRIX | X3DAUDIO_CALCULATE_DOPPLER | X3DAUDIO_CALCULATE_EMITTER_ANGLE), pDSPSettings);
        }

I see that my description of the default curve is probably wrong since it seems to turn off distance attenuation as you note. I'm not sure why as its' difficult to locate the old XACT docs these days and when you go look at them, they aren't really that detailed.

That said, the easy fix is to just use X3DAudioDefault_LinearCurve from the x3daudio.h header. I'll look at adding a EnableLinearCurves helper as well.

from directxtk.

CallumCVM avatar CallumCVM commented on May 27, 2024

Thanks @walbourn, I did indeed implement it using the curves myself already as you suggested. Thanks for the help, issue resolved.

Possibly also worth noting that the default curves (those used when not calling EnableDefaultCurves or setting curves manually) do also not have any attenuation/falloff (that I could notice). Hope this helps.

from directxtk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.