-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup AddRadioEffect #737
base: master
Are you sure you want to change the base?
Conversation
Isolated the various FX being applied to separate Filter objects, that are now applied onto the input. This should make it easier to add new post process, as well as give a better understanding of how they stack together. Additionally, tweaked the Bandpass to be a single filter instead of multiple ones where the second would be essentially a noop.
_filters[0] = | ||
OnlineFilter.CreateBandpass(ImpulseResponse.Finite, AudioManager.OUTPUT_SAMPLE_RATE, 560, 3900); | ||
_filters[1] = | ||
OnlineFilter.CreateBandpass(ImpulseResponse.Finite, AudioManager.OUTPUT_SAMPLE_RATE, 100, 4500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two bandpasses were applied back to back: the first one at [560,3900], and the second [100,4500].
AFAICT, there's no need for the second, since all the frequencies in the range it covers were already cut off.
audio = (double)buffer[outputIndex]; | ||
} | ||
|
||
audio *= RadioFilter.BOOST; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this was here?
I'd rather work on having lower volumes for the FX?
{ | ||
var filter = _filters[j]; | ||
audio = filter.ProcessSample(audio); | ||
if (double.IsNaN(audio)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this to a single filter, at the end.
If there are NaN, we'll backfill with random values, as to make some audio glitches.
* CachedAudioFX filters start enabled by default. * Fixed null variables (woopsies) * Initialize AM collision FX before refresh settings is called.
Now using NAudio's SamplerProvider pipeline, for better composability.
Removed last previous Filter type.
|
||
namespace Ciribob.DCS.SimpleRadio.Standalone.Client.Audio.Providers | ||
{ | ||
namespace Wave |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now everything has been moved to follow the paradigm of ISampleProvider (a decorator-based approach) from NAudio.
public class ClientEffectsPipeline | ||
{ | ||
private readonly Random _random = new Random(); | ||
|
||
private OnlineFilter[] _filters; | ||
private IOnlineFilter _bandpassFilter = OnlineIirFilter.CreateBandpass(ImpulseResponse.Finite, AudioManager.OUTPUT_SAMPLE_RATE, 560, 3900); | ||
private Dictionary<CachedAudioEffect.AudioEffectTypes, VolumeCachedEffectProvider> _fxProviders = new Dictionary<CachedAudioEffect.AudioEffectTypes, VolumeCachedEffectProvider>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All FX moved to a dictionary, for ease of access
|
||
buffer[outputIndex] = (float) audio; | ||
private void AddRadioEffect(float[] buffer, int count, int offset, RadioInformation.Modulation modulation, double freq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the most composability, should embrace the ISampleProvider decorator approach and return the one we set up, and do a single Read() at the end to process them all.
But I had to find a stopping point somewhere.
Isolated the various FX being applied to separate Filter objects, that are now applied onto the input.
This should make it easier to add new post process, as well as give a better understanding of how they stack together.
Additionally, tweaked the Bandpass to be a single filter instead of multiple ones where the second would be essentially a noop.