Initial commit
This commit is contained in:
commit
262601edb8
2025 files changed
+218754
No files matched your search
@@ -0,0 +1,29 @@
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
/// <summary>
|
||||
/// Chorus Phase
|
||||
/// </summary>
|
||||
public enum ChorusPhase : int
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_PHASE_NEG_180
|
||||
/// </summary>
|
||||
Neg180 = 0,
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_PHASE_NEG_90
|
||||
/// </summary>
|
||||
Neg90 = 1,
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_PHASE_ZERO
|
||||
/// </summary>
|
||||
Zero = 2,
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_PHASE_90
|
||||
/// </summary>
|
||||
Pos90 = 3,
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_PHASE_180
|
||||
/// </summary>
|
||||
Pos180 = 4,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a553b6d507262b6bc988541846301a84
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
/// <summary>
|
||||
/// Chorus Wave Form
|
||||
/// </summary>
|
||||
public enum ChorusWaveForm : int
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_WAVE_TRIANGLE
|
||||
/// </summary>
|
||||
Triangle = 0,
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_WAVE_SIN
|
||||
/// </summary>
|
||||
Sin = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fce246c41d460e969920e44c79384b48
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,316 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
internal struct DsFxChorus
|
||||
{
|
||||
public float WetDryMix;
|
||||
public float Depth;
|
||||
public float FeedBack;
|
||||
public float Frequency;
|
||||
public ChorusWaveForm WaveForm;
|
||||
public float Delay;
|
||||
public ChorusPhase Phase;
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
System.Security.SuppressUnmanagedCodeSecurity,
|
||||
Guid("880842e3-145f-43e6-a934-a71806e50547"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface IDirectSoundFXChorus
|
||||
{
|
||||
[PreserveSig]
|
||||
int SetAllParameters([In] ref DsFxChorus param);
|
||||
|
||||
[PreserveSig]
|
||||
int GetAllParameters(out DsFxChorus param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DMO Chorus Effect
|
||||
/// </summary>
|
||||
public class DmoChorus : IDmoEffector<DmoChorus.Params>
|
||||
{
|
||||
/// <summary>
|
||||
/// DMO Chorus Params
|
||||
/// </summary>
|
||||
public struct Params
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_WETDRYMIX_MIN
|
||||
/// </summary>
|
||||
public const float WetDryMixMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_WETDRYMIX_MAX
|
||||
/// </summary>
|
||||
public const float WetDryMixMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_WETDRYMIX_DEFAULT
|
||||
/// </summary>
|
||||
public const float WetDrtMixDefault = 50.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_DEPTH_MIN
|
||||
/// </summary>
|
||||
public const float DepthMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_DEPTH_MAX
|
||||
/// </summary>
|
||||
public const float DepthMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_DEPTH_DEFAULT
|
||||
/// </summary>
|
||||
public const float DepthDefault = 10.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_FEEDBACK_MIN
|
||||
/// </summary>
|
||||
public const float FeedBackMin = -99.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_FEEDBACK_MAX
|
||||
/// </summary>
|
||||
public const float FeedBackMax = 99.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_FEEDBACK_DEFAULT
|
||||
/// </summary>
|
||||
public const float FeedBaclDefault = 25.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_FREQUENCY_MIN
|
||||
/// </summary>
|
||||
public const float FrequencyMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_FREQUENCY_MAX
|
||||
/// </summary>
|
||||
public const float FrequencyMax = 10.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_FREQUENCY_DEFAULT
|
||||
/// </summary>
|
||||
public const float FrequencyDefault = 1.1f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_WAVE_DEFAULT
|
||||
/// </summary>
|
||||
public const ChorusWaveForm WaveFormDefault = ChorusWaveForm.Sin;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_DELAY_MIN
|
||||
/// </summary>
|
||||
public const float DelayMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_DELAY_MAX
|
||||
/// </summary>
|
||||
public const float DelayMax = 20.0f;
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_DELAY_DEFAULT
|
||||
/// </summary>
|
||||
public const float DelayDefault = 16.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCHORUS_PHASE_DEFAULT
|
||||
/// </summary>
|
||||
public const ChorusPhase PhaseDefault = ChorusPhase.Pos90;
|
||||
|
||||
/// <summary>
|
||||
/// Ratio of wet (processed) signal to dry (unprocessed) signal.
|
||||
/// </summary>
|
||||
public float WetDryMix
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.WetDryMix;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.WetDryMix = Math.Max(Math.Min(WetDryMixMax, value), WetDryMixMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Percentage by which the delay time is modulated by the low-frequency oscillator,
|
||||
/// in hundredths of a percentage point.
|
||||
/// </summary>
|
||||
public float Depth
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Depth;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Depth = Math.Max(Math.Min(DepthMax, value), DepthMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Percentage of output signal to feed back into the effect's input.
|
||||
/// </summary>
|
||||
public float FeedBack
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.FeedBack;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.FeedBack = Math.Max(Math.Min(FeedBackMax, value), FeedBackMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Frequency of the LFO.
|
||||
/// </summary>
|
||||
public float Frequency
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Frequency;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Frequency = Math.Max(Math.Min(FrequencyMax, value), FrequencyMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waveform shape of the LFO.
|
||||
/// </summary>
|
||||
public ChorusWaveForm WaveForm
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.WaveForm;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
if (Enum.IsDefined(typeof(ChorusWaveForm), value))
|
||||
{
|
||||
param.WaveForm = value;
|
||||
}
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of milliseconds the input is delayed before it is played back.
|
||||
/// </summary>
|
||||
public float Delay
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Delay;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Delay = Math.Max(Math.Min(DelayMax, value), DelayMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Phase differential between left and right LFOs.
|
||||
/// </summary>
|
||||
public ChorusPhase Phase
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Phase;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
if (Enum.IsDefined(typeof(ChorusPhase), value))
|
||||
{
|
||||
param.Phase = value;
|
||||
}
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IDirectSoundFXChorus fxChorus;
|
||||
|
||||
internal Params(IDirectSoundFXChorus dsFxObject)
|
||||
{
|
||||
fxChorus = dsFxObject;
|
||||
}
|
||||
|
||||
private void SetAllParameters(DsFxChorus param)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxChorus.SetAllParameters(ref param));
|
||||
}
|
||||
|
||||
private DsFxChorus GetAllParameters()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxChorus.GetAllParameters(out var param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaObject mediaObject;
|
||||
private readonly MediaObjectInPlace mediaObjectInPlace;
|
||||
private readonly Params effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
public MediaObject MediaObject => mediaObject;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
public MediaObjectInPlace MediaObjectInPlace => mediaObjectInPlace;
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
public Params EffectParams => effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Create new DMO Chorus
|
||||
/// </summary>
|
||||
public DmoChorus()
|
||||
{
|
||||
var guidChorus = new Guid("EFE6629C-81F7-4281-BD91-C9D604A95AF6");
|
||||
|
||||
var targetDescriptor = DmoEnumerator.GetAudioEffectNames().First(descriptor =>
|
||||
Equals(descriptor.Clsid, guidChorus));
|
||||
|
||||
if (targetDescriptor != null)
|
||||
{
|
||||
var mediaComObject = Activator.CreateInstance(Type.GetTypeFromCLSID(targetDescriptor.Clsid));
|
||||
|
||||
mediaObject = new MediaObject((IMediaObject) mediaComObject);
|
||||
mediaObjectInPlace = new MediaObjectInPlace((IMediaObjectInPlace) mediaComObject);
|
||||
effectParams = new Params((IDirectSoundFXChorus) mediaComObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose code
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaObjectInPlace?.Dispose();
|
||||
mediaObject?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 897dbc9ec90e76383a66f873e33f7071
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,293 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
internal struct DsFxCompressor
|
||||
{
|
||||
public float Gain;
|
||||
public float Attack;
|
||||
public float Release;
|
||||
public float Threshold;
|
||||
public float Ratio;
|
||||
public float PreDelay;
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
System.Security.SuppressUnmanagedCodeSecurity,
|
||||
Guid("4bbd1154-62f6-4e2c-a15c-d3b6c417f7a0"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface IDirectSoundFXCompressor
|
||||
{
|
||||
[PreserveSig]
|
||||
int SetAllParameters([In] ref DsFxCompressor param);
|
||||
|
||||
[PreserveSig]
|
||||
int GetAllParameters(out DsFxCompressor param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DMO Compressor Effect
|
||||
/// </summary>
|
||||
public class DmoCompressor : IDmoEffector<DmoCompressor.Params>
|
||||
{
|
||||
/// <summary>
|
||||
/// DMO Compressor Params
|
||||
/// </summary>
|
||||
public struct Params
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_GAIN_MIN
|
||||
/// </summary>
|
||||
public const float GainMin = -60.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_GAIN_MAX
|
||||
/// </summary>
|
||||
public const float GainMax = 60.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_GAIN_DEFAULT
|
||||
/// </summary>
|
||||
public const float GainDefault = 0.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_ATTACK_MIN
|
||||
/// </summary>
|
||||
public const float AttackMin = 0.01f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_ATTACK_MAX
|
||||
/// </summary>
|
||||
public const float AttackMax = 500.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_ATTACK_DEFAULT
|
||||
/// </summary>
|
||||
public const float AttackDefault = 10.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_RELEASE_MIN
|
||||
/// </summary>
|
||||
public const float ReleaseMin = 50.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_RELEASE_MAX
|
||||
/// </summary>
|
||||
public const float ReleaseMax = 3000.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_RELEASE_DEFAULT
|
||||
/// </summary>
|
||||
public const float ReleaseDefault = 200.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_THRESHOLD_MIN
|
||||
/// </summary>
|
||||
public const float ThresholdMin = -60.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_THRESHOLD_MAX
|
||||
/// </summary>
|
||||
public const float ThresholdMax = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_THRESHOLD_DEFAULT
|
||||
/// </summary>
|
||||
public const float TjresholdDefault = -20.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_RATIO_MIN
|
||||
/// </summary>
|
||||
public const float RatioMin = 1.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_RATIO_MAX
|
||||
/// </summary>
|
||||
public const float RatioMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_RATIO_DEFAULT
|
||||
/// </summary>
|
||||
public const float RatioDefault = 3.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_PREDELAY_MIN
|
||||
/// </summary>
|
||||
public const float PreDelayMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_PREDELAY_MAX
|
||||
/// </summary>
|
||||
public const float PreDelayMax = 4.0f;
|
||||
/// <summary>
|
||||
/// DSFXCOMPRESSOR_PREDELAY_DEFAULT
|
||||
/// </summary>
|
||||
public const float PreDelayDefault = 4.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Output gain of signal after compression.
|
||||
/// </summary>
|
||||
public float Gain
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Gain;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Gain = Math.Max(Math.Min(GainMax, value), GainMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time before compression reaches its full value.
|
||||
/// </summary>
|
||||
public float Attack
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Attack;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Attack = Math.Max(Math.Min(AttackMax, value), AttackMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Speed at which compression is stopped after input drops below Threshold.
|
||||
/// </summary>
|
||||
public float Release
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Release;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Release = Math.Max(Math.Min(ReleaseMax, value), ReleaseMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Point at which compression begins, in decibels.
|
||||
/// </summary>
|
||||
public float Threshold
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Threshold;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Threshold = Math.Max(Math.Min(ThresholdMax, value), ThresholdMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compression ratio
|
||||
/// </summary>
|
||||
public float Ratio
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Ratio;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Ratio = Math.Max(Math.Min(RatioMax, value), RatioMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time after Threshold is reached before attack phase is started, in milliseconds.
|
||||
/// </summary>
|
||||
public float PreDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.PreDelay;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.PreDelay = Math.Max(Math.Min(PreDelayMax, value), PreDelayMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IDirectSoundFXCompressor fxCompressor;
|
||||
|
||||
internal Params(IDirectSoundFXCompressor dsFxObject)
|
||||
{
|
||||
fxCompressor = dsFxObject;
|
||||
}
|
||||
|
||||
private void SetAllParameters(DsFxCompressor param)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxCompressor.SetAllParameters(ref param));
|
||||
}
|
||||
|
||||
private DsFxCompressor GetAllParameters()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxCompressor.GetAllParameters(out var param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaObject mediaObject;
|
||||
private readonly MediaObjectInPlace mediaObjectInPlace;
|
||||
private readonly Params effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
public MediaObject MediaObject => mediaObject;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
public MediaObjectInPlace MediaObjectInPlace => mediaObjectInPlace;
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
public Params EffectParams => effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Create new DMO Compressor
|
||||
/// </summary>
|
||||
public DmoCompressor()
|
||||
{
|
||||
var guidChorus = new Guid("EF011F79-4000-406D-87AF-BFFB3FC39D57");
|
||||
|
||||
var targetDescriptor = DmoEnumerator.GetAudioEffectNames().First(descriptor =>
|
||||
Equals(descriptor.Clsid, guidChorus));
|
||||
|
||||
if (targetDescriptor != null)
|
||||
{
|
||||
var mediaComObject = Activator.CreateInstance(Type.GetTypeFromCLSID(targetDescriptor.Clsid));
|
||||
|
||||
mediaObject = new MediaObject((IMediaObject)mediaComObject);
|
||||
mediaObjectInPlace = new MediaObjectInPlace((IMediaObjectInPlace)mediaComObject);
|
||||
effectParams = new Params((IDirectSoundFXCompressor)mediaComObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose code
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaObjectInPlace?.Dispose();
|
||||
mediaObject?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15197c0a5d6e81c1b8728e05b60be587
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,261 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
internal struct DsFxDistortion
|
||||
{
|
||||
public float Gain;
|
||||
public float Edge;
|
||||
public float PostEqCenterFrequency;
|
||||
public float PostEqBandWidth;
|
||||
public float PreLowPassCutoff;
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
System.Security.SuppressUnmanagedCodeSecurity,
|
||||
Guid("8ecf4326-455f-4d8b-bda9-8d5d3e9e3e0b"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface IDirectSoundFXDistortion
|
||||
{
|
||||
[PreserveSig]
|
||||
int SetAllParameters([In] ref DsFxDistortion param);
|
||||
|
||||
[PreserveSig]
|
||||
int GetAllParameters(out DsFxDistortion param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DMO Distortion Effect
|
||||
/// </summary>
|
||||
public class DmoDistortion : IDmoEffector<DmoDistortion.Params>
|
||||
{
|
||||
/// <summary>
|
||||
/// DMO Distortion Params
|
||||
/// </summary>
|
||||
public struct Params
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_GAIN_MIN
|
||||
/// </summary>
|
||||
public const float GainMin = -60.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_GAIN_MAX
|
||||
/// </summary>
|
||||
public const float GainMax = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_GAIN_DEFAULT
|
||||
/// </summary>
|
||||
public const float GainDefault = -18.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_EDGE_MIN
|
||||
/// </summary>
|
||||
public const float EdgeMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_EDGE_MAX
|
||||
/// </summary>
|
||||
public const float EdgeMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_EDGE_DEFAULT
|
||||
/// </summary>
|
||||
public const float EdgeDefault = 15.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN
|
||||
/// </summary>
|
||||
public const float PostEqCenterFrequencyMin = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX
|
||||
/// </summary>
|
||||
public const float PostEqCenterFrequencyMax = 8000.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_POSTEQCENTERFREQUENCY_DEFAULT
|
||||
/// </summary>
|
||||
public const float PostEqCenterFrequencyDefault = 2400.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_POSTEQBANDWIDTH_MIN
|
||||
/// </summary>
|
||||
public const float PostEqBandWidthMin = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_POSTEQBANDWIDTH_MAX
|
||||
/// </summary>
|
||||
public const float PostEqBandWidthMax = 8000.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_POSTEQBANDWIDTH_DEFAULT
|
||||
/// </summary>
|
||||
public const float PostEqBandWidthDefault = 2400.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_PRELOWPASSCUTOFF_MIN
|
||||
/// </summary>
|
||||
public const float PreLowPassCutoffMin = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_PRELOWPASSCUTOFF_MAX
|
||||
/// </summary>
|
||||
public const float PreLowPassCutoffMax = 8000.0f;
|
||||
/// <summary>
|
||||
/// DSFXDISTORTION_PRELOWPASSCUTOFF_DEFAULT
|
||||
/// </summary>
|
||||
public const float PreLowPassCutoffDefault = 8000.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Amount of signal change after distortion.
|
||||
/// </summary>
|
||||
public float Gain
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Gain;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Gain = Math.Max(Math.Min(GainMax, value), GainMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Percentage of distortion intensity.
|
||||
/// </summary>
|
||||
public float Edge
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Edge;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Edge = Math.Max(Math.Min(EdgeMax, value), EdgeMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Center frequency of harmonic content addition.
|
||||
/// </summary>
|
||||
public float PostEqCenterFrequency
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.PostEqCenterFrequency;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.PostEqCenterFrequency = Math.Max(Math.Min(PostEqCenterFrequencyMax, value), PostEqCenterFrequencyMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width of frequency band that determines range of harmonic content addition.
|
||||
/// </summary>
|
||||
public float PostEqBandWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.PostEqBandWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.PostEqBandWidth = Math.Max(Math.Min(PostEqBandWidthMax, value), PostEqBandWidthMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filter cutoff for high-frequency harmonics attenuation.
|
||||
/// </summary>
|
||||
public float PreLowPassCutoff
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.PreLowPassCutoff;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.PreLowPassCutoff = Math.Max(Math.Min(PreLowPassCutoffMax, value), PreLowPassCutoffMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IDirectSoundFXDistortion fxDistortion;
|
||||
|
||||
internal Params(IDirectSoundFXDistortion dsFxObject)
|
||||
{
|
||||
fxDistortion = dsFxObject;
|
||||
}
|
||||
|
||||
private void SetAllParameters(DsFxDistortion param)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxDistortion.SetAllParameters(ref param));
|
||||
}
|
||||
|
||||
private DsFxDistortion GetAllParameters()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxDistortion.GetAllParameters(out var param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaObject mediaObject;
|
||||
private readonly MediaObjectInPlace mediaObjectInPlace;
|
||||
private readonly Params effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
public MediaObject MediaObject => mediaObject;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
public MediaObjectInPlace MediaObjectInPlace => mediaObjectInPlace;
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
public Params EffectParams => effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Create new DMO Distortion
|
||||
/// </summary>
|
||||
public DmoDistortion()
|
||||
{
|
||||
var guidDistortion = new Guid("EF114C90-CD1D-484E-96E5-09CFAF912A21");
|
||||
|
||||
var targetDescriptor = DmoEnumerator.GetAudioEffectNames().First(descriptor =>
|
||||
Equals(descriptor.Clsid, guidDistortion));
|
||||
|
||||
if (targetDescriptor != null)
|
||||
{
|
||||
var mediaComObject = Activator.CreateInstance(Type.GetTypeFromCLSID(targetDescriptor.Clsid));
|
||||
|
||||
mediaObject = new MediaObject((IMediaObject)mediaComObject);
|
||||
mediaObjectInPlace = new MediaObjectInPlace((IMediaObjectInPlace)mediaComObject);
|
||||
effectParams = new Params((IDirectSoundFXDistortion)mediaComObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose code
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaObjectInPlace?.Dispose();
|
||||
mediaObject?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82bef84e2279a7f39bd39be2dad09e3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,256 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
internal struct DsFxEcho
|
||||
{
|
||||
public float WetDryMix;
|
||||
public float FeedBack;
|
||||
public float LeftDelay;
|
||||
public float RightDelay;
|
||||
public EchoPanDelay PanDelay;
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
System.Security.SuppressUnmanagedCodeSecurity,
|
||||
Guid("8bd28edf-50db-4e92-a2bd-445488d1ed42"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface IDirectSoundFXEcho
|
||||
{
|
||||
[PreserveSig]
|
||||
int SetAllParameters([In] ref DsFxEcho param);
|
||||
|
||||
[PreserveSig]
|
||||
int GetAllParameters(out DsFxEcho param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dmo Echo Effect
|
||||
/// </summary>
|
||||
public class DmoEcho : IDmoEffector<DmoEcho.Params>
|
||||
{
|
||||
/// <summary>
|
||||
/// DMO Echo Params
|
||||
/// </summary>
|
||||
public struct Params
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXECHO_WETDRYMIX_MIN
|
||||
/// </summary>
|
||||
public const float WetDryMixMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXECHO_WETDRYMIX_MAX
|
||||
/// </summary>
|
||||
public const float WetDryMixMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXECHO_WETDRYMIX_DEFAULT
|
||||
/// </summary>
|
||||
public const float WetDeyMixDefault = 50.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXECHO_FEEDBACK_MIN
|
||||
/// </summary>
|
||||
public const float FeedBackMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXECHO_FEEDBACK_MAX
|
||||
/// </summary>
|
||||
public const float FeedBackMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXECHO_FEEDBACK_DEFAULT
|
||||
/// </summary>
|
||||
public const float FeedBackDefault = 50.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXECHO_LEFTDELAY_MIN
|
||||
/// </summary>
|
||||
public const float LeftDelayMin = 1.0f;
|
||||
/// <summary>
|
||||
/// DSFXECHO_LEFTDELAY_MAX
|
||||
/// </summary>
|
||||
public const float LeftDelayMax = 2000.0f;
|
||||
/// <summary>
|
||||
/// DSFXECHO_LEFTDELAY_DEFAULT
|
||||
/// </summary>
|
||||
public const float LeftDelayDefault = 500.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXECHO_RIGHTDELAY_MIN
|
||||
/// </summary>
|
||||
public const float RightDelayMin = 1.0f;
|
||||
/// <summary>
|
||||
/// DSFXECHO_RIGHTDELAY_MAX
|
||||
/// </summary>
|
||||
public const float RightDelayMax = 2000.0f;
|
||||
/// <summary>
|
||||
/// DSFXECHO_RIGHTDELAY_DEFAULT
|
||||
/// </summary>
|
||||
public const float RightDelayDefault = 500.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXECHO_PANDELAY_DEFAULT
|
||||
/// </summary>
|
||||
public const EchoPanDelay PanDelayDefault = EchoPanDelay.Off;
|
||||
|
||||
/// <summary>
|
||||
/// Ratio of wet (processed) signal to dry (unprocessed) signal.
|
||||
/// </summary>
|
||||
public float WetDryMix
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.WetDryMix;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.WetDryMix = Math.Max(Math.Min(WetDryMixMax, value), WetDryMixMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Percentage of output fed back into input.
|
||||
/// </summary>
|
||||
public float FeedBack
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.FeedBack;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.FeedBack = Math.Max(Math.Min(FeedBackMax, value), FeedBackMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delay for left channel, in milliseconds.
|
||||
/// </summary>
|
||||
public float LeftDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.LeftDelay;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.LeftDelay = Math.Max(Math.Min(LeftDelayMax, value), LeftDelayMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delay for right channel, in milliseconds.
|
||||
/// </summary>
|
||||
public float RightDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.RightDelay;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.RightDelay = Math.Max(Math.Min(RightDelayMax, value), RightDelayMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Value that specifies whether to swap left and right delays with each successive echo.
|
||||
/// </summary>
|
||||
public EchoPanDelay PanDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.PanDelay;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
if (Enum.IsDefined(typeof(EchoPanDelay), value))
|
||||
{
|
||||
param.PanDelay = value;
|
||||
}
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IDirectSoundFXEcho fxEcho;
|
||||
|
||||
internal Params(IDirectSoundFXEcho dsFxObject)
|
||||
{
|
||||
fxEcho = dsFxObject;
|
||||
}
|
||||
|
||||
private void SetAllParameters(DsFxEcho param)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxEcho.SetAllParameters(ref param));
|
||||
}
|
||||
|
||||
private DsFxEcho GetAllParameters()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxEcho.GetAllParameters(out var param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaObject mediaObject;
|
||||
private readonly MediaObjectInPlace mediaObjectInPlace;
|
||||
private readonly Params effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
public MediaObject MediaObject => mediaObject;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
public MediaObjectInPlace MediaObjectInPlace => mediaObjectInPlace;
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
public Params EffectParams => effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Create new DMO Echo
|
||||
/// </summary>
|
||||
public DmoEcho()
|
||||
{
|
||||
var guidEcho = new Guid("EF3E932C-D40B-4F51-8CCF-3F98F1B29D5D");
|
||||
|
||||
var targetDescriptor = DmoEnumerator.GetAudioEffectNames().First(descriptor =>
|
||||
Equals(descriptor.Clsid, guidEcho));
|
||||
|
||||
if (targetDescriptor != null)
|
||||
{
|
||||
var mediaComObject = Activator.CreateInstance(Type.GetTypeFromCLSID(targetDescriptor.Clsid));
|
||||
|
||||
mediaObject = new MediaObject((IMediaObject) mediaComObject);
|
||||
mediaObjectInPlace = new MediaObjectInPlace((IMediaObjectInPlace) mediaComObject);
|
||||
effectParams = new Params((IDirectSoundFXEcho) mediaComObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose code
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaObjectInPlace?.Dispose();
|
||||
mediaObject?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35464a832e72c83df9e9d3430d9725fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,316 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
internal struct DsFxFlanger
|
||||
{
|
||||
public float WetDryMix;
|
||||
public float Depth;
|
||||
public float FeedBack;
|
||||
public float Frequency;
|
||||
public FlangerWaveForm WaveForm;
|
||||
public float Delay;
|
||||
public FlangerPhase Phase;
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
System.Security.SuppressUnmanagedCodeSecurity,
|
||||
Guid("903e9878-2c92-4072-9b2c-ea68f5396783"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface IDirectSoundFXFlanger
|
||||
{
|
||||
[PreserveSig]
|
||||
int SetAllParameters([In] ref DsFxFlanger param);
|
||||
|
||||
[PreserveSig]
|
||||
int GetAllParameters(out DsFxFlanger param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DMO Flanger Effect
|
||||
/// </summary>
|
||||
public class DmoFlanger : IDmoEffector<DmoFlanger.Params>
|
||||
{
|
||||
/// <summary>
|
||||
/// DMO Flanger Params
|
||||
/// </summary>
|
||||
public struct Params
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_WETDRYMIX_MIN
|
||||
/// </summary>
|
||||
public const float WetDryMixMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_WETDRYMIX_MAX
|
||||
/// </summary>
|
||||
public const float WetDryMixMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_WETDRYMIX_DEFAULT
|
||||
/// </summary>
|
||||
public const float WetDrtMixDefault = 50.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_DEPTH_MIN
|
||||
/// </summary>
|
||||
public const float DepthMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_DEPTH_MAX
|
||||
/// </summary>
|
||||
public const float DepthMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_DEPTH_DEFAULT
|
||||
/// </summary>
|
||||
public const float DepthDefault = 100.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_FEEDBACK_MIN
|
||||
/// </summary>
|
||||
public const float FeedBackMin = -99.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_FEEDBACK_MAX
|
||||
/// </summary>
|
||||
public const float FeedBackMax = 99.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_FEEDBACK_DEFAULT
|
||||
/// </summary>
|
||||
public const float FeedBaclDefault = -50.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_FREQUENCY_MIN
|
||||
/// </summary>
|
||||
public const float FrequencyMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_FREQUENCY_MAX
|
||||
/// </summary>
|
||||
public const float FrequencyMax = 10.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_FREQUENCY_DEFAULT
|
||||
/// </summary>
|
||||
public const float FrequencyDefault = 0.25f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_WAVE_DEFAULT
|
||||
/// </summary>
|
||||
public const FlangerWaveForm WaveFormDefault = FlangerWaveForm.Sin;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_DELAY_MIN
|
||||
/// </summary>
|
||||
public const float DelayMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_DELAY_MAX
|
||||
/// </summary>
|
||||
public const float DelayMax = 4.0f;
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_DELAY_DEFAULT
|
||||
/// </summary>
|
||||
public const float DelayDefault = 2.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_PHASE_DEFAULT
|
||||
/// </summary>
|
||||
public const FlangerPhase PhaseDefault = FlangerPhase.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Ratio of wet (processed) signal to dry (unprocessed) signal.
|
||||
/// </summary>
|
||||
public float WetDryMix
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.WetDryMix;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.WetDryMix = Math.Max(Math.Min(WetDryMixMax, value), WetDryMixMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Percentage by which the delay time is modulated by the low-frequency oscillator,
|
||||
/// in hundredths of a percentage point.
|
||||
/// </summary>
|
||||
public float Depth
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Depth;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Depth = Math.Max(Math.Min(DepthMax, value), DepthMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Percentage of output signal to feed back into the effect's input.
|
||||
/// </summary>
|
||||
public float FeedBack
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.FeedBack;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.FeedBack = Math.Max(Math.Min(FeedBackMax, value), FeedBackMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Frequency of the LFO.
|
||||
/// </summary>
|
||||
public float Frequency
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Frequency;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Frequency = Math.Max(Math.Min(FrequencyMax, value), FrequencyMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waveform shape of the LFO.
|
||||
/// </summary>
|
||||
public FlangerWaveForm WaveForm
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.WaveForm;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
if (Enum.IsDefined(typeof(FlangerWaveForm), value))
|
||||
{
|
||||
param.WaveForm = value;
|
||||
}
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of milliseconds the input is delayed before it is played back.
|
||||
/// </summary>
|
||||
public float Delay
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Delay;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Delay = Math.Max(Math.Min(DelayMax, value), DelayMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Phase differential between left and right LFOs.
|
||||
/// </summary>
|
||||
public FlangerPhase Phase
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Phase;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
if (Enum.IsDefined(typeof(FlangerPhase), value))
|
||||
{
|
||||
param.Phase = value;
|
||||
}
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IDirectSoundFXFlanger fxFlanger;
|
||||
|
||||
internal Params(IDirectSoundFXFlanger dsFxObject)
|
||||
{
|
||||
fxFlanger = dsFxObject;
|
||||
}
|
||||
|
||||
private void SetAllParameters(DsFxFlanger param)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxFlanger.SetAllParameters(ref param));
|
||||
}
|
||||
|
||||
private DsFxFlanger GetAllParameters()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxFlanger.GetAllParameters(out var param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaObject mediaObject;
|
||||
private readonly MediaObjectInPlace mediaObjectInPlace;
|
||||
private readonly Params effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
public MediaObject MediaObject => mediaObject;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
public MediaObjectInPlace MediaObjectInPlace => mediaObjectInPlace;
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
public Params EffectParams => effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Create new DMO Flanger
|
||||
/// </summary>
|
||||
public DmoFlanger()
|
||||
{
|
||||
var guidFlanger = new Guid("EFCA3D92-DFD8-4672-A603-7420894BAD98");
|
||||
|
||||
var targetDescriptor = DmoEnumerator.GetAudioEffectNames().First(descriptor =>
|
||||
Equals(descriptor.Clsid, guidFlanger));
|
||||
|
||||
if (targetDescriptor != null)
|
||||
{
|
||||
var mediaComObject = Activator.CreateInstance(Type.GetTypeFromCLSID(targetDescriptor.Clsid));
|
||||
|
||||
mediaObject = new MediaObject((IMediaObject)mediaComObject);
|
||||
mediaObjectInPlace = new MediaObjectInPlace((IMediaObjectInPlace)mediaComObject);
|
||||
effectParams = new Params((IDirectSoundFXFlanger)mediaComObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose code
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaObjectInPlace?.Dispose();
|
||||
mediaObject?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5981fc4c9d48ec679b52fdeab055f02e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
internal struct DsFxGargle
|
||||
{
|
||||
public uint RateHz;
|
||||
public GargleWaveShape WaveShape;
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
System.Security.SuppressUnmanagedCodeSecurity,
|
||||
Guid("d616f352-d622-11ce-aac5-0020af0b99a3"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface IDirectSoundFXGargle
|
||||
{
|
||||
[PreserveSig]
|
||||
int SetAllParameters([In] ref DsFxGargle param);
|
||||
|
||||
[PreserveSig]
|
||||
int GetAllParameters(out DsFxGargle param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DMO Gargle Effect
|
||||
/// </summary>
|
||||
public class DmoGargle : IDmoEffector<DmoGargle.Params>
|
||||
{
|
||||
/// <summary>
|
||||
/// DMO Gargle Params
|
||||
/// </summary>
|
||||
public struct Params
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXGARGLE_RATEHZ_MIN
|
||||
/// </summary>
|
||||
public const uint RateHzMin = 1;
|
||||
/// <summary>
|
||||
/// DSFXGARGLE_RATEHZ_MAX
|
||||
/// </summary>
|
||||
public const uint RateHzMax = 1000;
|
||||
/// <summary>
|
||||
/// DSFXGARGLE_RATEHZ_DEFAULT
|
||||
/// </summary>
|
||||
public const uint RateHzDefault = 20;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXGARGLE_WAVE_DEFAULT
|
||||
/// </summary>
|
||||
public const GargleWaveShape WaveShapeDefault = GargleWaveShape.Triangle;
|
||||
|
||||
/// <summary>
|
||||
/// Rate of modulation in hz
|
||||
/// </summary>
|
||||
public uint RateHz
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.RateHz;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.RateHz = Math.Max(Math.Min(RateHzMax, value), RateHzMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gargle Wave Shape
|
||||
/// </summary>
|
||||
public GargleWaveShape WaveShape
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.WaveShape;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
if (Enum.IsDefined(typeof(GargleWaveShape), value))
|
||||
{
|
||||
param.WaveShape = value;
|
||||
}
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IDirectSoundFXGargle fxGargle;
|
||||
|
||||
internal Params(IDirectSoundFXGargle dsFxObject)
|
||||
{
|
||||
fxGargle = dsFxObject;
|
||||
}
|
||||
|
||||
private void SetAllParameters(DsFxGargle param)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxGargle.SetAllParameters(ref param));
|
||||
}
|
||||
|
||||
private DsFxGargle GetAllParameters()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxGargle.GetAllParameters(out var param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaObject mediaObject;
|
||||
private readonly MediaObjectInPlace mediaObjectInPlace;
|
||||
private readonly Params effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
public MediaObject MediaObject => mediaObject;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
public MediaObjectInPlace MediaObjectInPlace => mediaObjectInPlace;
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
public Params EffectParams => effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Create new DMO Gargle
|
||||
/// </summary>
|
||||
public DmoGargle()
|
||||
{
|
||||
var guidGargle = new Guid("DAFD8210-5711-4B91-9FE3-F75B7AE279BF");
|
||||
|
||||
var targetDescriptor = DmoEnumerator.GetAudioEffectNames().First(descriptor =>
|
||||
Equals(descriptor.Clsid, guidGargle));
|
||||
|
||||
if (targetDescriptor != null)
|
||||
{
|
||||
var mediaComObject = Activator.CreateInstance(Type.GetTypeFromCLSID(targetDescriptor.Clsid));
|
||||
|
||||
mediaObject = new MediaObject((IMediaObject) mediaComObject);
|
||||
mediaObjectInPlace = new MediaObjectInPlace((IMediaObjectInPlace) mediaComObject);
|
||||
effectParams = new Params((IDirectSoundFXGargle) mediaComObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose code
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaObjectInPlace?.Dispose();
|
||||
mediaObject?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f62f8be5d2d525c53bb45fb0bc0eac39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,543 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
internal struct DsFxI3Dl2Reverb
|
||||
{
|
||||
public int Room;
|
||||
public int RoomHf;
|
||||
public float RoomRollOffFactor;
|
||||
public float DecayTime;
|
||||
public float DecayHfRatio;
|
||||
public int Reflections;
|
||||
public float ReflectionsDelay;
|
||||
public int Reverb;
|
||||
public float ReverbDelay;
|
||||
public float Diffusion;
|
||||
public float Density;
|
||||
public float HfReference;
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
System.Security.SuppressUnmanagedCodeSecurity,
|
||||
Guid("4b166a6a-0d66-43f3-80e3-ee6280dee1a4"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface IDirectSoundFXI3DL2Reverb
|
||||
{
|
||||
[PreserveSig]
|
||||
int SetAllParameters([In] ref DsFxI3Dl2Reverb param);
|
||||
|
||||
[PreserveSig]
|
||||
int GetAllParameters(out DsFxI3Dl2Reverb param);
|
||||
|
||||
[PreserveSig]
|
||||
int SetPreset([In] uint preset);
|
||||
|
||||
[PreserveSig]
|
||||
int GetPreset(out uint preset);
|
||||
|
||||
[PreserveSig]
|
||||
int SetQuality([In] int quality);
|
||||
|
||||
[PreserveSig]
|
||||
int GetQuality(out int quality);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DMO I3DL2Reverb Effect
|
||||
/// </summary>
|
||||
public class DmoI3DL2Reverb : IDmoEffector<DmoI3DL2Reverb.Params>
|
||||
{
|
||||
/// <summary>
|
||||
/// DMO I3DL2Reverb Params
|
||||
/// </summary>
|
||||
public struct Params
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_ROOM_MIN
|
||||
/// </summary>
|
||||
public const int RoomMin = -10000;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_ROOM_MAX
|
||||
/// </summary>
|
||||
public const int RoomMax = 0;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_ROOM_DEFAULT
|
||||
/// </summary>
|
||||
public const int RoomDefault = -1000;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_ROOMHF_MIN
|
||||
/// </summary>
|
||||
public const int RoomHfMin = -10000;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_ROOMHF_MAX
|
||||
/// </summary>
|
||||
public const int RoomHfMax = 0;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_ROOMHF_DEFAULT
|
||||
/// </summary>
|
||||
public const int RoomHfDefault = -100;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MIN
|
||||
/// </summary>
|
||||
public const float RoomRollOffFactorMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MAX
|
||||
/// </summary>
|
||||
public const float RoomRollOffFactorMax = 10.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_DEFAULT
|
||||
/// </summary>
|
||||
public const float RoomRollOffFactorDefault = 0.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DECAYTIME_MIN
|
||||
/// </summary>
|
||||
public const float DecayTimeMin = 0.1f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DECAYTIME_MAX
|
||||
/// </summary>
|
||||
public const float DecayTimeMax = 20.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DECAYTIME_DEFAULT
|
||||
/// </summary>
|
||||
public const float DecayTimeDefault = 1.49f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DECAYHFRATIO_MIN
|
||||
/// </summary>
|
||||
public const float DecayHfRatioMin = 0.1f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DECAYHFRATIO_MAX
|
||||
/// </summary>
|
||||
public const float DecayHfRatioMax = 2.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DECAYHFRATIO_DEFAULT
|
||||
/// </summary>
|
||||
public const float DecayHfRatioDefault = 0.83f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REFLECTIONS_MIN
|
||||
/// </summary>
|
||||
public const int ReflectionsMin = -10000;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REFLECTIONS_MAX
|
||||
/// </summary>
|
||||
public const int ReflectionsMax = 1000;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REFLECTIONS_DEFAULT
|
||||
/// </summary>
|
||||
public const int ReflectionsDefault = -2602;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REFLECTIONSDELAY_MIN
|
||||
/// </summary>
|
||||
public const float ReflectionsDelayMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REFLECTIONSDELAY_MAX
|
||||
/// </summary>
|
||||
public const float ReflectionsDelayMax = 0.3f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REFLECTIONSDELAY_DEFAULT
|
||||
/// </summary>
|
||||
public const float ReflectionsDelayDefault = 0.007f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REVERB_MIN
|
||||
/// </summary>
|
||||
public const int ReverbMin = -10000;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REVERB_MAX
|
||||
/// </summary>
|
||||
public const int ReverbMax = 2000;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REVERB_DEFAULT
|
||||
/// </summary>
|
||||
public const int ReverbDefault = 200;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REVERBDELAY_MIN
|
||||
/// </summary>
|
||||
public const float ReverbDelayMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REVERBDELAY_MAX
|
||||
/// </summary>
|
||||
public const float ReverbDelayMax = 0.1f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_REVERBDELAY_DEFAULT
|
||||
/// </summary>
|
||||
public const float ReverbDelayDefault = 0.011f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DIFFUSION_MIN
|
||||
/// </summary>
|
||||
public const float DiffusionMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DIFFUSION_MAX
|
||||
/// </summary>
|
||||
public const float DiffusionMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DIFFUSION_DEFAULT
|
||||
/// </summary>
|
||||
public const float DiffusionDefault = 100.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DENSITY_MIN
|
||||
/// </summary>
|
||||
public const float DensityMin = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DENSITY_MAX
|
||||
/// </summary>
|
||||
public const float DensityMax = 100.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_DENSITY_DEFAULT
|
||||
/// </summary>
|
||||
public const float DensityDefault = 100.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_HFREFERENCE_MIN
|
||||
/// </summary>
|
||||
public const float HfReferenceMin = 20.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_HFREFERENCE_MAX
|
||||
/// </summary>
|
||||
public const float HfReferenceMax = 20000.0f;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_HFREFERENCE_DEFAULT
|
||||
/// </summary>
|
||||
public const float HfReferenceDefault = 5000.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_QUALITY_MIN
|
||||
/// </summary>
|
||||
public const int QualityMin = 0;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_QUALITY_MAX
|
||||
/// </summary>
|
||||
public const int QualityMax = 3;
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2REVERB_QUALITY_DEFAULT
|
||||
/// </summary>
|
||||
public const int QualityDefault = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Attenuation of the room effect, in millibels (mB)
|
||||
/// </summary>
|
||||
public int Room
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Room;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Room = Math.Max(Math.Min(RoomMax, value), RoomMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attenuation of the room high-frequency effect, in mB.
|
||||
/// </summary>
|
||||
public int RoomHf
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.RoomHf;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.RoomHf = Math.Max(Math.Min(RoomHfMax, value), RoomHfMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rolloff factor for the reflected signals.
|
||||
/// </summary>
|
||||
public float RoomRollOffFactor
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.RoomRollOffFactor;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.RoomRollOffFactor = Math.Max(Math.Min(RoomRollOffFactorMax, value), RoomRollOffFactorMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decay time, in seconds.
|
||||
/// </summary>
|
||||
public float DecayTime
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.DecayTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.DecayTime = Math.Max(Math.Min(DecayTimeMax, value), DecayTimeMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ratio of the decay time at high frequencies to the decay time at low frequencies.
|
||||
/// </summary>
|
||||
public float DecayHfRatio
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.DecayHfRatio;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.DecayHfRatio = Math.Max(Math.Min(DecayHfRatioMax, value), DecayHfRatioMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attenuation of early reflections relative to lRoom, in mB.
|
||||
/// </summary>
|
||||
public int Reflections
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Reflections;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Reflections = Math.Max(Math.Min(ReflectionsMax, value), ReflectionsMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delay time of the first reflection relative to the direct path, in seconds.
|
||||
/// </summary>
|
||||
public float ReflectionsDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.ReflectionsDelay;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.ReflectionsDelay = Math.Max(Math.Min(ReflectionsDelayMax, value), ReflectionsDelayMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attenuation of late reverberation relative to lRoom, in mB.
|
||||
/// </summary>
|
||||
public int Reverb
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Reverb;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Reverb = Math.Max(Math.Min(ReverbMax, value), ReverbMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time limit between the early reflections and the late reverberation relative to the time of the first reflection.
|
||||
/// </summary>
|
||||
public float ReverbDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.ReverbDelay;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.ReverbDelay = Math.Max(Math.Min(ReverbDelayMax, value), ReverbDelayMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Echo density in the late reverberation decay, in percent.
|
||||
/// </summary>
|
||||
public float Diffusion
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Diffusion;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Diffusion = Math.Max(Math.Min(DiffusionMax, value), DiffusionMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modal density in the late reverberation decay, in percent.
|
||||
/// </summary>
|
||||
public float Density
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Density;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Density = Math.Max(Math.Min(DensityMax, value), DensityMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reference high frequency, in hertz.
|
||||
/// </summary>
|
||||
public float HfReference
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.HfReference;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.HfReference = Math.Max(Math.Min(HfReferenceMax, value), HfReferenceMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the quality of the environmental reverberation effect. Higher values produce better quality at the expense of processing time.
|
||||
/// </summary>
|
||||
public int Quality
|
||||
{
|
||||
get
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxI3Dl2Reverb.GetQuality(out var quality));
|
||||
return quality;
|
||||
}
|
||||
set => Marshal.ThrowExceptionForHR(fxI3Dl2Reverb.SetQuality(value));
|
||||
}
|
||||
|
||||
private readonly IDirectSoundFXI3DL2Reverb fxI3Dl2Reverb;
|
||||
|
||||
internal Params(IDirectSoundFXI3DL2Reverb dsFxObject)
|
||||
{
|
||||
fxI3Dl2Reverb = dsFxObject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets standard reverberation parameters of a buffer.
|
||||
/// </summary>
|
||||
/// <param name="preset">I3DL2EnvironmentPreset</param>
|
||||
public void SetPreset(I3DL2EnvironmentPreset preset)
|
||||
{
|
||||
var p = (uint)preset;
|
||||
Marshal.ThrowExceptionForHR(fxI3Dl2Reverb.SetPreset(p));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// retrieves an identifier for standard reverberation parameters of a buffer.
|
||||
/// </summary>
|
||||
/// <returns>I3DL2EnvironmentPreset</returns>
|
||||
public I3DL2EnvironmentPreset GetPreset()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxI3Dl2Reverb.GetPreset(out var preset));
|
||||
return (I3DL2EnvironmentPreset)preset;
|
||||
}
|
||||
|
||||
private void SetAllParameters(DsFxI3Dl2Reverb param)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxI3Dl2Reverb.SetAllParameters(ref param));
|
||||
}
|
||||
|
||||
private DsFxI3Dl2Reverb GetAllParameters()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxI3Dl2Reverb.GetAllParameters(out var param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaObject mediaObject;
|
||||
private readonly MediaObjectInPlace mediaObjectInPlace;
|
||||
private readonly Params effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
public MediaObject MediaObject => mediaObject;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
public MediaObjectInPlace MediaObjectInPlace => mediaObjectInPlace;
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
public Params EffectParams => effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Create new DMO I3DL2Reverb
|
||||
/// </summary>
|
||||
public DmoI3DL2Reverb()
|
||||
{
|
||||
var guidi3Dl2Reverb = new Guid("EF985E71-D5C7-42D4-BA4D-2D073E2E96F4");
|
||||
|
||||
var targetDescriptor = DmoEnumerator.GetAudioEffectNames().First(descriptor =>
|
||||
Equals(descriptor.Clsid, guidi3Dl2Reverb));
|
||||
|
||||
if (targetDescriptor != null)
|
||||
{
|
||||
var mediaComObject = Activator.CreateInstance(Type.GetTypeFromCLSID(targetDescriptor.Clsid));
|
||||
|
||||
mediaObject = new MediaObject((IMediaObject)mediaComObject);
|
||||
mediaObjectInPlace = new MediaObjectInPlace((IMediaObjectInPlace)mediaComObject);
|
||||
effectParams = new Params((IDirectSoundFXI3DL2Reverb)mediaComObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose code
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaObjectInPlace?.Dispose();
|
||||
mediaObject?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 753587a000cdd04c1afb4056237cc01a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
internal struct DsFxParamEq
|
||||
{
|
||||
public float Center;
|
||||
public float BandWidth;
|
||||
public float Gain;
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
System.Security.SuppressUnmanagedCodeSecurity,
|
||||
Guid("c03ca9fe-fe90-4204-8078-82334cd177da"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface IDirectSoundFxParamEq
|
||||
{
|
||||
[PreserveSig]
|
||||
int SetAllParameters([In] ref DsFxParamEq param);
|
||||
|
||||
[PreserveSig]
|
||||
int GetAllParameters(out DsFxParamEq param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DMO Parametric Equalizer Effect
|
||||
/// </summary>
|
||||
public class DmoParamEq : IDmoEffector<DmoParamEq.Params>
|
||||
{
|
||||
/// <summary>
|
||||
/// DMO ParamEq Params
|
||||
/// </summary>
|
||||
public struct Params
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXPARAMEQ_CENTER_MIN
|
||||
/// </summary>
|
||||
public const float CenterMin = 80.0f;
|
||||
/// <summary>
|
||||
/// DSFXPARAMEQ_CENTER_MAX
|
||||
/// </summary>
|
||||
public const float CenterMax = 16000.0f;
|
||||
/// <summary>
|
||||
/// DSFXPARAMEQ_CENTER_DEFAULT
|
||||
/// </summary>
|
||||
public const float CenterDefault = 8000.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXPARAMEQ_BANDWIDTH_MIN
|
||||
/// </summary>
|
||||
public const float BandWidthMin = 1.0f;
|
||||
/// <summary>
|
||||
/// DSFXPARAMEQ_BANDWIDTH_MAX
|
||||
/// </summary>
|
||||
public const float BandWidthMax = 36.0f;
|
||||
/// <summary>
|
||||
/// DSFXPARAMEQ_BANDWIDTH_DEFAULT
|
||||
/// </summary>
|
||||
public const float BandWidthDefault = 12.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFXPARAMEQ_GAIN_MIN
|
||||
/// </summary>
|
||||
public const float GainMin = -15.0f;
|
||||
/// <summary>
|
||||
/// DSFXPARAMEQ_GAIN_MAX
|
||||
/// </summary>
|
||||
public const float GainMax = 15.0f;
|
||||
/// <summary>
|
||||
/// DSFXPARAMEQ_GAIN_DEFAULT
|
||||
/// </summary>
|
||||
public const float GainDefault = 0.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Center frequency, in hertz
|
||||
/// </summary>
|
||||
public float Center
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Center;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Center = Math.Max(Math.Min(CenterMax, value), CenterMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bandwidth, in semitones.
|
||||
/// </summary>
|
||||
public float BandWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.BandWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.BandWidth = Math.Max(Math.Min(BandWidthMax, value), BandWidthMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gain
|
||||
/// </summary>
|
||||
public float Gain
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.Gain;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.Gain = Math.Max(Math.Min(GainMax, value), GainMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IDirectSoundFxParamEq fxParamEq;
|
||||
|
||||
internal Params(IDirectSoundFxParamEq dsFxObject)
|
||||
{
|
||||
fxParamEq = dsFxObject;
|
||||
}
|
||||
|
||||
private void SetAllParameters(DsFxParamEq param)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxParamEq.SetAllParameters(ref param));
|
||||
}
|
||||
|
||||
private DsFxParamEq GetAllParameters()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxParamEq.GetAllParameters(out var param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaObject mediaObject;
|
||||
private readonly MediaObjectInPlace mediaObjectInPlace;
|
||||
private readonly Params effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
public MediaObject MediaObject => mediaObject;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
public MediaObjectInPlace MediaObjectInPlace => mediaObjectInPlace;
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
public Params EffectParams => effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Create new DMO ParamEq
|
||||
/// </summary>
|
||||
public DmoParamEq()
|
||||
{
|
||||
var guidParamEq = new Guid("120CED89-3BF4-4173-A132-3CB406CF3231");
|
||||
|
||||
var targetDescriptor = DmoEnumerator.GetAudioEffectNames().First(descriptor =>
|
||||
Equals(descriptor.Clsid, guidParamEq));
|
||||
|
||||
if (targetDescriptor != null)
|
||||
{
|
||||
var mediaComObject = Activator.CreateInstance(Type.GetTypeFromCLSID(targetDescriptor.Clsid));
|
||||
|
||||
mediaObject = new MediaObject((IMediaObject) mediaComObject);
|
||||
mediaObjectInPlace = new MediaObjectInPlace((IMediaObjectInPlace) mediaComObject);
|
||||
effectParams = new Params((IDirectSoundFxParamEq) mediaComObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose code
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaObjectInPlace?.Dispose();
|
||||
mediaObject?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faad6296756e163cda2bad38370c8244
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,229 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
internal struct DsFxWavesReverb
|
||||
{
|
||||
public float InGain;
|
||||
public float ReverbMix;
|
||||
public float ReverbTime;
|
||||
public float HighFreqRtRatio;
|
||||
}
|
||||
|
||||
[ComImport,
|
||||
System.Security.SuppressUnmanagedCodeSecurity,
|
||||
Guid("46858c3a-0dc6-45e3-b760-d4eef16cb325"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface IDirectSoundFXWavesReverb
|
||||
{
|
||||
[PreserveSig]
|
||||
int SetAllParameters([In] ref DsFxWavesReverb param);
|
||||
|
||||
[PreserveSig]
|
||||
int GetAllParameters(out DsFxWavesReverb param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DMO Reverb Effect
|
||||
/// </summary>
|
||||
public class DmoWavesReverb : IDmoEffector<DmoWavesReverb.Params>
|
||||
{
|
||||
/// <summary>
|
||||
/// DMO Reverb Params
|
||||
/// </summary>
|
||||
public struct Params
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_INGAIN_MIN
|
||||
/// </summary>
|
||||
public const float InGainMin = -96.0f;
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_INGAIN_MAX
|
||||
/// </summary>
|
||||
public const float InGainMax = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_INGAIN_DEFAULT
|
||||
/// </summary>
|
||||
public const float InGainDefault = 0.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_REVERBMIX_MIN
|
||||
/// </summary>
|
||||
public const float ReverbMixMin = -96.0f;
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_REVERBMIX_MAX
|
||||
/// </summary>
|
||||
public const float ReverbMixMax = 0.0f;
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_REVERBMIX_DEFAULT
|
||||
/// </summary>
|
||||
public const float ReverbMixDefault = 0.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_REVERBTIME_MIN
|
||||
/// </summary>
|
||||
public const float ReverbTimeMin = 0.001f;
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_REVERBTIME_MAX
|
||||
/// </summary>
|
||||
public const float ReverbTimeMax = 3000.0f;
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_REVERBTIME_DEFAULT
|
||||
/// </summary>
|
||||
public const float ReverbTimeDefault = 1000.0f;
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN
|
||||
/// </summary>
|
||||
public const float HighFreqRtRatioMin = 0.001f;
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX
|
||||
/// </summary>
|
||||
public const float HighFreqRtRatioMax = 0.999f;
|
||||
/// <summary>
|
||||
/// DSFX_WAVESREVERB_HIGHFREQRTRATIO_DEFAULT
|
||||
/// </summary>
|
||||
public const float HighFreqRtRatioDefault = 0.001f;
|
||||
|
||||
/// <summary>
|
||||
/// Input gain of signal, in decibels (dB).
|
||||
/// </summary>
|
||||
public float InGain
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.InGain;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.InGain = Math.Max(Math.Min(InGainMax, value), InGainMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reverb mix, in dB.
|
||||
/// </summary>
|
||||
public float ReverbMix
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.ReverbMix;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.ReverbMix = Math.Max(Math.Min(ReverbMixMax, value), ReverbMixMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reverb time, in milliseconds.
|
||||
/// </summary>
|
||||
public float ReverbTime
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.ReverbTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.ReverbTime = Math.Max(Math.Min(ReverbTimeMax, value), ReverbTimeMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// High-frequency reverb time ratio.
|
||||
/// </summary>
|
||||
public float HighFreqRtRatio
|
||||
{
|
||||
get
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
return param.HighFreqRtRatio;
|
||||
}
|
||||
set
|
||||
{
|
||||
var param = GetAllParameters();
|
||||
param.HighFreqRtRatio = Math.Max(Math.Min(HighFreqRtRatioMax, value), HighFreqRtRatioMin);
|
||||
SetAllParameters(param);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly IDirectSoundFXWavesReverb fxWavesReverb;
|
||||
|
||||
internal Params(IDirectSoundFXWavesReverb dsFxObject)
|
||||
{
|
||||
fxWavesReverb = dsFxObject;
|
||||
}
|
||||
|
||||
private void SetAllParameters(DsFxWavesReverb param)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxWavesReverb.SetAllParameters(ref param));
|
||||
}
|
||||
|
||||
private DsFxWavesReverb GetAllParameters()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(fxWavesReverb.GetAllParameters(out var param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MediaObject mediaObject;
|
||||
private readonly MediaObjectInPlace mediaObjectInPlace;
|
||||
private readonly Params effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
public MediaObject MediaObject => mediaObject;
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
public MediaObjectInPlace MediaObjectInPlace => mediaObjectInPlace;
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
public Params EffectParams => effectParams;
|
||||
|
||||
/// <summary>
|
||||
/// Create new DMO WavesReverb
|
||||
/// </summary>
|
||||
public DmoWavesReverb()
|
||||
{
|
||||
var guidWavesReverb = new Guid("87FC0268-9A55-4360-95AA-004A1D9DE26C");
|
||||
|
||||
var targetDescriptor = DmoEnumerator.GetAudioEffectNames().First(descriptor =>
|
||||
Equals(descriptor.Clsid, guidWavesReverb));
|
||||
|
||||
if (targetDescriptor != null)
|
||||
{
|
||||
var mediaComObject = Activator.CreateInstance(Type.GetTypeFromCLSID(targetDescriptor.Clsid));
|
||||
|
||||
mediaObject = new MediaObject((IMediaObject) mediaComObject);
|
||||
mediaObjectInPlace = new MediaObjectInPlace((IMediaObjectInPlace) mediaComObject);
|
||||
effectParams = new Params((IDirectSoundFXWavesReverb) mediaComObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose code
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
mediaObjectInPlace?.Dispose();
|
||||
mediaObject?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf9948b12879b17d69e14018ddd7d238
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXECHO_PANDELAY
|
||||
/// </summary>
|
||||
public enum EchoPanDelay : int
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXECHO_PANDELAY_MIN
|
||||
/// </summary>
|
||||
Off = 0,
|
||||
/// <summary>
|
||||
/// DSFXECHO_PANDELAY_MAX
|
||||
/// </summary>
|
||||
On = 1,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 207695cbc8055f7ba8a16a6169e4d8ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
/// <summary>
|
||||
/// Flanger Phase
|
||||
/// </summary>
|
||||
public enum FlangerPhase : int
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_PHASE_NEG_180
|
||||
/// </summary>
|
||||
Neg180 = 0,
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_PHASE_NEG_90
|
||||
/// </summary>
|
||||
Neg90 = 1,
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_PHASE_ZERO
|
||||
/// </summary>
|
||||
Zero = 2,
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_PHASE_90
|
||||
/// </summary>
|
||||
Pos90 = 3,
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_PHASE_180
|
||||
/// </summary>
|
||||
Pos180 = 4,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2374b998db717f493a937a2bf582ac62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
/// <summary>
|
||||
/// Flanger Wave Form
|
||||
/// </summary>
|
||||
public enum FlangerWaveForm : int
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_WAVE_TRIANGLE
|
||||
/// </summary>
|
||||
Triangle = 0,
|
||||
|
||||
/// <summary>
|
||||
/// DSFXFLANGER_WAVE_SIN
|
||||
/// </summary>
|
||||
Sin = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3695b357682ed595fa4aab2d736e545a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
/// <summary>
|
||||
/// Gargle Wave Shape
|
||||
/// </summary>
|
||||
public enum GargleWaveShape : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFXGARGLE_WAVE_TRIANGLE
|
||||
/// </summary>
|
||||
Triangle = 0,
|
||||
|
||||
/// <summary>
|
||||
/// DSFXGARGLE_WAVE_SQUARE
|
||||
/// </summary>
|
||||
Square = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db34a1a0aa9d5ecb58f8f7bb302b1813
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,158 @@
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
/// <summary>
|
||||
/// I3DL2 Reverberation Presets
|
||||
/// </summary>
|
||||
public enum I3DL2EnvironmentPreset
|
||||
{
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_DEFAULT
|
||||
/// </summary>
|
||||
Default = 0,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_GENERIC
|
||||
/// </summary>
|
||||
Generic = 1,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL
|
||||
/// </summary>
|
||||
PaddedCell = 2,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_ROOM
|
||||
/// </summary>
|
||||
Room= 3,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_BATHROOM
|
||||
/// </summary>
|
||||
Bathroom= 4,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM
|
||||
/// </summary>
|
||||
LivingRoom = 5,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_STONEROOM
|
||||
/// </summary>
|
||||
StoneRoom = 6,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM
|
||||
/// </summary>
|
||||
Auditorium = 7,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL
|
||||
/// </summary>
|
||||
ConcertHall = 8,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_CAVE
|
||||
/// </summary>
|
||||
Cave = 9,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_ARENA
|
||||
/// </summary>
|
||||
Arena = 10,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_HANGAR
|
||||
/// </summary>
|
||||
Hangar = 11,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY
|
||||
/// </summary>
|
||||
CarpetedHallway = 12,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_HALLWAY
|
||||
/// </summary>
|
||||
Hallway = 13,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR
|
||||
/// </summary>
|
||||
StoneCorridor = 14,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_ALLEY
|
||||
/// </summary>
|
||||
Alley = 15,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_FOREST
|
||||
/// </summary>
|
||||
Forest = 16,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_CITY
|
||||
/// </summary>
|
||||
City = 17,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS
|
||||
/// </summary>
|
||||
Mountains = 18,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_QUARRY
|
||||
/// </summary>
|
||||
Quarry = 19,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_PLAIN
|
||||
/// </summary>
|
||||
Plain = 20,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT
|
||||
/// </summary>
|
||||
ParkingLot = 21,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE
|
||||
/// </summary>
|
||||
SewerPipe = 22,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_UNDERWATER
|
||||
/// </summary>
|
||||
UnderWater = 23,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_SMALLROOM
|
||||
/// </summary>
|
||||
SmallRoom = 24,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM
|
||||
/// </summary>
|
||||
MediumRoom = 25,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEROOM
|
||||
/// </summary>
|
||||
LargeRoom = 26,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL
|
||||
/// </summary>
|
||||
MediumHall = 27,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEHALL
|
||||
/// </summary>
|
||||
LargeHall = 28,
|
||||
|
||||
/// <summary>
|
||||
/// DSFX_I3DL2_ENVIRONMENT_PRESET_PLATE
|
||||
/// </summary>
|
||||
Plate = 29
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5281e59ed24a4eb73bb04ac3ec7b9800
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio.Dmo.Effect
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface of DMO Effectors
|
||||
/// </summary>
|
||||
/// <typeparam name="TParameters">Parameters of the effect to be used</typeparam>
|
||||
public interface IDmoEffector<out TParameters> : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Media Object
|
||||
/// </summary>
|
||||
MediaObject MediaObject { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Media Object InPlace
|
||||
/// </summary>
|
||||
MediaObjectInPlace MediaObjectInPlace { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Effect Parameter
|
||||
/// </summary>
|
||||
TParameters EffectParams { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac81f091a0214974892737b5ff989061
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user