Comments (4)
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.
@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.
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.
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)
- Jittery mouse movement with higher mouse sensitivities HOT 5
- [ddsview] Incorrect brightness found in ddsview HOT 1
- Windows not sending 'KSCATEGORY_AUDIO' notification for audio devices HOT 6
- Error on the mouse input HOT 1
- Sprite position issue HOT 17
- Retire legacy Xbox One XDK support
- NonPremultiplied has to be used in the Begin() function. HOT 1
- App.cpp and App.h for UWP DeviceResources HOT 1
- xaudio2 XAUDIO2_E_DEVICE_INVALIDATED HRESULT not handled HOT 16
- Make use of C++/WinRT when building for C++17
- ARM64 version of xwbtool HOT 3
- `MapGuard` undefined behavior after move HOT 3
- DirectX Tool Kit for DX9
- DrawLine line thickness HOT 1
- Mesh Outline Effect HOT 2
- Point Light Shader HOT 2
- Clarify required WinSDK version HOT 2
- Hard fps lock to refresh rate value in fullscreen games - Win11 22H2 (DX11) HOT 2
- XWBtool makes all wav files the same name after repackaging HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directxtk.