Add FAudioCreateCollector to create a FAPO that captures samples into a buffer #377
No reviewers
Labels
No labels
Bug
Extensions
New Feature
Not our bug - SDL2
Not our bug - WMA
Utilities
Wine
X3DAudio Accuracy
XACT Accuracy
XAudio2 Accuracy
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-FNA-XNA/FAudio!377
Loading…
Reference in a new issue
No description provided.
Delete branch "collector"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Simple and easy to use. Hand it a ring buffer and it will fill it with mono samples (so you don't need to think about how many channels there are), and you can feed that into an FFT or something else in order to do a realtime spectrum analyzer, etc.
I previously did this with a custom callback from outside but Collector makes it much easier and eliminates the possibility of crashing/hanging the mixer thread.
Overall looks good - let's add this as a full extension and add a text document in the extensions/ folder.
Do you think it's necessary to have some sort of mechanism to allow the user to figure out where the write position is so they can avoid processing the same data twice? I had that originally but it felt like unnecessary complication, so I stripped it out.
Another option would be to have two buffers and a flag that tells you which one is "ready", I guess.
Do we have any documentation on the extension process anywhere? I'm not sure if I need to do anything beyond documenting it.
I think VolumeMeter has something similar but if not I wouldn't worry about it. I usually just copy another extension file when making a new one, it's usually pretty short unless there's something super finicky about how it works.
Updated with an extension description txt along with some other stuff I overlooked. Not sure I got everything.
Finally was able to sit down and look at this in more detail - the write position should be done with
FAudioVoice_GetEffectParametersinstead of a new export since that will avoid race conditions on the XAPO's internal variable:This may also be a better place to fill a user buffer, for basically the same reason - I think this is why VolumeMeter has its own ring buffer internally.
There shouldn't be a race condition with the existing way. I'm not sure I see the advantage of this change, is it just for consistency?
The audio thread may be modifying data at the time that the new function is being called - note the lock we have in the GetEffectParameters implementation.
Updated based on feedback. I updated the C# bindings and the extension .txt file, and tested it manually in my game.