Initial commit

This commit is contained in:
Thastertyn committed 2024-06-07 00:47:07 +02:00
commit 262601edb8
2025 files changed
+218754

No files matched your search

@@ -0,0 +1,29 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// Contains the name and CLSID of a DirectX Media Object
/// </summary>
public class DmoDescriptor
{
/// <summary>
/// Name
/// </summary>
public string Name { get; private set; }
/// <summary>
/// CLSID
/// </summary>
public Guid Clsid { get; private set; }
/// <summary>
/// Initializes a new instance of DmoDescriptor
/// </summary>
public DmoDescriptor(string name, Guid clsid)
{
Name = name;
Clsid = clsid;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cf76518a294b1c3d7a7652ab2d829ac0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
using System;
namespace NAudio.Dmo
{
[Flags]
enum DmoEnumFlags
{
None,
DMO_ENUMF_INCLUDE_KEYED = 0x00000001
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2e504be0a5803a10cb0f805ec0af5e61
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// DirectX Media Object Enumerator
/// </summary>
public class DmoEnumerator
{
/// <summary>
/// Get audio effect names
/// </summary>
/// <returns>Audio effect names</returns>
public static IEnumerable<DmoDescriptor> GetAudioEffectNames()
{
return GetDmos(DmoGuids.DMOCATEGORY_AUDIO_EFFECT);
}
/// <summary>
/// Get audio encoder names
/// </summary>
/// <returns>Audio encoder names</returns>
public static IEnumerable<DmoDescriptor> GetAudioEncoderNames()
{
return GetDmos(DmoGuids.DMOCATEGORY_AUDIO_ENCODER);
}
/// <summary>
/// Get audio decoder names
/// </summary>
/// <returns>Audio decoder names</returns>
public static IEnumerable<DmoDescriptor> GetAudioDecoderNames()
{
return GetDmos(DmoGuids.DMOCATEGORY_AUDIO_DECODER);
}
private static IEnumerable<DmoDescriptor> GetDmos(Guid category)
{
IEnumDmo enumDmo;
var hresult = DmoInterop.DMOEnum(ref category, DmoEnumFlags.None, 0, null, 0, null, out enumDmo);
Marshal.ThrowExceptionForHR(hresult);
int itemsFetched;
do
{
Guid guid;
IntPtr namePointer;
enumDmo.Next(1, out guid, out namePointer, out itemsFetched);
if (itemsFetched == 1)
{
string name = Marshal.PtrToStringUni(namePointer);
Marshal.FreeCoTaskMem(namePointer);
yield return new DmoDescriptor(name, guid);
}
} while (itemsFetched > 0);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c34808f0a74cb31d5af94b04910ce150
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,31 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// DMO Guids for use with DMOEnum
/// dmoreg.h
/// </summary>
static class DmoGuids
{
public static readonly Guid DMOCATEGORY_AUDIO_DECODER = new Guid("57f2db8b-e6bb-4513-9d43-dcd2a6593125");
public static readonly Guid DMOCATEGORY_AUDIO_ENCODER = new Guid("33D9A761-90C8-11d0-BD43-00A0C911CE86");
public static readonly Guid DMOCATEGORY_VIDEO_DECODER = new Guid("4a69b442-28be-4991-969c-b500adf5d8a8");
public static readonly Guid DMOCATEGORY_VIDEO_ENCODER = new Guid("33D9A760-90C8-11d0-BD43-00A0C911CE86");
public static readonly Guid DMOCATEGORY_AUDIO_EFFECT = new Guid("f3602b3f-0592-48df-a4cd-674721e7ebeb");
public static readonly Guid DMOCATEGORY_VIDEO_EFFECT = new Guid("d990ee14-776c-4723-be46-3da2f56f10b9");
public static readonly Guid DMOCATEGORY_AUDIO_CAPTURE_EFFECT = new Guid("f665aaba-3e09-4920-aa5f-219811148f09");
}
static class DmoMediaTypeGuids
{
public static readonly Guid FORMAT_None = new Guid("0F6417D6-C318-11D0-A43F-00A0C9223196");
public static readonly Guid FORMAT_VideoInfo = new Guid("05589f80-c356-11ce-bf01-00aa0055595a");
public static readonly Guid FORMAT_VideoInfo2 = new Guid("F72A76A0-EB0A-11d0-ACE4-0000C0CC16BA");
public static readonly Guid FORMAT_WaveFormatEx = new Guid("05589f81-c356-11ce-bf01-00aa0055595a");
public static readonly Guid FORMAT_MPEGVideo = new Guid("05589f82-c356-11ce-bf01-00aa0055595a");
public static readonly Guid FORMAT_MPEGStreams = new Guid("05589f83-c356-11ce-bf01-00aa0055595a");
public static readonly Guid FORMAT_DvInfo = new Guid("05589f84-c356-11ce-bf01-00aa0055595a");
public static readonly Guid FORMAT_525WSS = new Guid("C7ECF04D-4582-4869-9ABB-BFB523B62EDF");
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 72670d8bfb85821a6b1d70300ce7b0a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// MediaErr.h
/// </summary>
enum DmoHResults
{
DMO_E_INVALIDSTREAMINDEX = unchecked((int)0x80040201),
DMO_E_INVALIDTYPE = unchecked((int)0x80040202),
DMO_E_TYPE_NOT_SET = unchecked((int)0x80040203),
DMO_E_NOTACCEPTING = unchecked((int)0x80040204),
DMO_E_TYPE_NOT_ACCEPTED = unchecked((int)0x80040205),
DMO_E_NO_MORE_ITEMS = unchecked((int)0x80040206),
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8e651510ddb1f52e188ecefd280707eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,20 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// DMO Inplace Process Flags
/// </summary>
[Flags]
public enum DmoInPlaceProcessFlags
{
/// <summary>
/// DMO_INPLACE_NORMAL
/// </summary>
Normal = 0,
/// <summary>
/// DMO_INPLACE_ZERO
/// </summary>
Zero = 0x1
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2b79d153f33e68f2eaca4979efa2d5aa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
namespace NAudio.Dmo
{
/// <summary>
/// Return value when Process is executed with IMediaObjectInPlace
/// </summary>
public enum DmoInPlaceProcessReturn
{
/// <summary>
/// Success. There is no remaining data to process.
/// </summary>
Normal = 0x0,
/// <summary>
/// Success. There is still data to process.
/// </summary>
HasEffectTail = 0x1,
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0089423704213ab668032695e0beb2a1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,28 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// DMO Input Data Buffer Flags
/// </summary>
[Flags]
public enum DmoInputDataBufferFlags
{
/// <summary>
/// None
/// </summary>
None,
/// <summary>
/// DMO_INPUT_DATA_BUFFERF_SYNCPOINT
/// </summary>
SyncPoint = 0x00000001,
/// <summary>
/// DMO_INPUT_DATA_BUFFERF_TIME
/// </summary>
Time = 0x00000002,
/// <summary>
/// DMO_INPUT_DATA_BUFFERF_TIMELENGTH
/// </summary>
TimeLength = 0x00000004
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d4989d423ebade3fab507674bdb6433
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
using System;
namespace NAudio.Dmo
{
[Flags]
enum DmoInputStatusFlags
{
None,
DMO_INPUT_STATUSF_ACCEPT_DATA = 0x1
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 30981fab14b91315bad1a65afafb7c3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
static class DmoInterop
{
[DllImport("msdmo.dll")]
public static extern int DMOEnum(
[In] ref Guid guidCategory,
DmoEnumFlags flags,
int inTypes,
[In] DmoPartialMediaType[] inTypesArray,
int outTypes,
[In] DmoPartialMediaType[] outTypesArray,
out IEnumDmo enumDmo);
[DllImport("msdmo.dll")]
public static extern int MoFreeMediaType(
[In] ref DmoMediaType mediaType);
[DllImport("msdmo.dll")]
public static extern int MoInitMediaType(
[In,Out] ref DmoMediaType mediaType, int formatBlockBytes);
[DllImport("msdmo.dll")]
public static extern int DMOGetName([In] ref Guid clsidDMO,
// preallocate 80 characters
[Out] StringBuilder name);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 54388459e39ee784f922c0db618c8a32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,141 @@
using System;
using NAudio.Wave;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// http://msdn.microsoft.com/en-us/library/aa929922.aspx
/// DMO_MEDIA_TYPE
/// </summary>
public struct DmoMediaType
{
Guid majortype;
Guid subtype;
bool bFixedSizeSamples;
bool bTemporalCompression;
int lSampleSize;
Guid formattype;
IntPtr pUnk; // not used
int cbFormat;
IntPtr pbFormat;
/// <summary>
/// Major type
/// </summary>
public Guid MajorType => majortype;
/// <summary>
/// Major type name
/// </summary>
public string MajorTypeName => MediaTypes.GetMediaTypeName(majortype);
/// <summary>
/// Subtype
/// </summary>
public Guid SubType => subtype;
/// <summary>
/// Subtype name
/// </summary>
public string SubTypeName
{
get
{
if (majortype == MediaTypes.MEDIATYPE_Audio)
{
return AudioMediaSubtypes.GetAudioSubtypeName(subtype);
}
return subtype.ToString();
}
}
/// <summary>
/// Fixed size samples
/// </summary>
public bool FixedSizeSamples => bFixedSizeSamples;
/// <summary>
/// Sample size
/// </summary>
public int SampleSize => lSampleSize;
/// <summary>
/// Format type
/// </summary>
public Guid FormatType => formattype;
/// <summary>
/// Format type name
/// </summary>
public string FormatTypeName
{
get
{
if(formattype == DmoMediaTypeGuids.FORMAT_None)
{
return "None";
}
if (formattype == Guid.Empty)
{
return "Null";
}
if(formattype == DmoMediaTypeGuids.FORMAT_WaveFormatEx)
{
return "WaveFormatEx";
}
return FormatType.ToString();
}
}
/// <summary>
/// Gets the structure as a Wave format (if it is one)
/// </summary>
public WaveFormat GetWaveFormat()
{
if (formattype == DmoMediaTypeGuids.FORMAT_WaveFormatEx)
{
return WaveFormat.MarshalFromPtr(pbFormat);
}
throw new InvalidOperationException("Not a WaveFormat type");
}
/// <summary>
/// Sets this object up to point to a wave format
/// </summary>
/// <param name="waveFormat">Wave format structure</param>
public void SetWaveFormat(WaveFormat waveFormat)
{
majortype = MediaTypes.MEDIATYPE_Audio;
var wfe = waveFormat as WaveFormatExtensible;
if (wfe != null)
{
subtype = wfe.SubFormat;
}
else
{
switch (waveFormat.Encoding)
{
case WaveFormatEncoding.Pcm:
subtype = AudioMediaSubtypes.MEDIASUBTYPE_PCM;
break;
case WaveFormatEncoding.IeeeFloat:
subtype = AudioMediaSubtypes.MEDIASUBTYPE_IEEE_FLOAT;
break;
case WaveFormatEncoding.MpegLayer3:
subtype = AudioMediaSubtypes.WMMEDIASUBTYPE_MP3;
break;
default:
throw new ArgumentException($"Not a supported encoding {waveFormat.Encoding}");
}
}
bFixedSizeSamples = SubType == AudioMediaSubtypes.MEDIASUBTYPE_PCM || SubType == AudioMediaSubtypes.MEDIASUBTYPE_IEEE_FLOAT;
formattype = DmoMediaTypeGuids.FORMAT_WaveFormatEx;
if (cbFormat < Marshal.SizeOf(waveFormat))
throw new InvalidOperationException("Not enough memory assigned for a WaveFormat structure");
//Debug.Assert(cbFormat >= ,"Not enough space");
Marshal.StructureToPtr(waveFormat, pbFormat, false);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d853b22ffe503ad4e9cc5619c1e48e4f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,109 @@
using System;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// DMO Output Data Buffer
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack=8)]
public struct DmoOutputDataBuffer : IDisposable
{
[MarshalAs(UnmanagedType.Interface)]
IMediaBuffer pBuffer;
DmoOutputDataBufferFlags dwStatus;
long rtTimestamp;
long referenceTimeDuration;
/// <summary>
/// Creates a new DMO Output Data Buffer structure
/// </summary>
/// <param name="maxBufferSize">Maximum buffer size</param>
public DmoOutputDataBuffer(int maxBufferSize)
{
pBuffer = new MediaBuffer(maxBufferSize);
dwStatus = DmoOutputDataBufferFlags.None;
rtTimestamp = 0;
referenceTimeDuration = 0;
}
/// <summary>
/// Dispose
/// </summary>
public void Dispose()
{
if (pBuffer != null)
{
((MediaBuffer)pBuffer).Dispose();
pBuffer = null;
GC.SuppressFinalize(this);
}
}
/// <summary>
/// Media Buffer
/// </summary>
public IMediaBuffer MediaBuffer
{
get { return pBuffer; }
internal set { pBuffer = value; }
}
/// <summary>
/// Length of data in buffer
/// </summary>
public int Length
{
get { return ((MediaBuffer)pBuffer).Length; }
}
/// <summary>
/// Status Flags
/// </summary>
public DmoOutputDataBufferFlags StatusFlags
{
get { return dwStatus; }
internal set { dwStatus = value; }
}
/// <summary>
/// Timestamp
/// </summary>
public long Timestamp
{
get { return rtTimestamp; }
internal set { rtTimestamp = value; }
}
/// <summary>
/// Duration
/// </summary>
public long Duration
{
get { return referenceTimeDuration; }
internal set { referenceTimeDuration = value; }
}
/// <summary>
/// Retrives the data in this buffer
/// </summary>
/// <param name="data">Buffer to receive data</param>
/// <param name="offset">Offset into buffer</param>
public void RetrieveData(byte[] data, int offset)
{
((MediaBuffer)pBuffer).RetrieveData(data, offset);
}
/// <summary>
/// Is more data available
/// If true, ProcessOuput should be called again
/// </summary>
public bool MoreDataAvailable
{
get
{
return (StatusFlags & DmoOutputDataBufferFlags.Incomplete) == DmoOutputDataBufferFlags.Incomplete;
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 15a84cf5b307d1a0a9a45a5bc1a6b830
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// DMO Output Data Buffer Flags
/// </summary>
[Flags]
public enum DmoOutputDataBufferFlags
{
/// <summary>
/// None
/// </summary>
None,
/// <summary>
/// DMO_OUTPUT_DATA_BUFFERF_SYNCPOINT
/// </summary>
SyncPoint = 0x00000001,
/// <summary>
/// DMO_OUTPUT_DATA_BUFFERF_TIME
/// </summary>
Time = 0x00000002,
/// <summary>
/// DMO_OUTPUT_DATA_BUFFERF_TIMELENGTH
/// </summary>
TimeLength = 0x00000004,
/// <summary>
/// DMO_OUTPUT_DATA_BUFFERF_INCOMPLETE
/// </summary>
Incomplete = 0x01000000
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e3ef66871a5cb199289b1760a58e2fe5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,25 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// DMO_PARTIAL_MEDIATYPE
/// </summary>
struct DmoPartialMediaType
{
Guid type;
Guid subtype;
public Guid Type
{
get { return type; }
internal set { type = value; }
}
public Guid Subtype
{
get { return subtype; }
internal set { subtype = value; }
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4ba7a211df38b565d99996dd25a00141
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,20 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// DMO Process Output Flags
/// </summary>
[Flags]
public enum DmoProcessOutputFlags
{
/// <summary>
/// None
/// </summary>
None,
/// <summary>
/// DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER
/// </summary>
DiscardWhenNoBuffer = 0x00000001
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ebd2da65df8036cdd97c75d4ff61189d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
using System;
namespace NAudio.Dmo
{
[Flags]
enum DmoSetTypeFlags
{
None,
DMO_SET_TYPEF_TEST_ONLY = 0x00000001,
DMO_SET_TYPEF_CLEAR = 0x00000002
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ca01e76ee78ce922f988601deaa41e00
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e61cc0619e62502c68c02a726268c1d2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -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:
@@ -0,0 +1,21 @@
using System;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
[Guid("2c3cd98a-2bfa-4a53-9c27-5249ba64ba0f"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
ComImport]
interface IEnumDmo
{
// int Next(int itemsToFetch, CLSID[] clsids, string[] names, out int itemsFetched);
// lets do one at a time to keep it simple - don't call with itemsToFetch > 1
int Next(int itemsToFetch, out Guid clsid, out IntPtr name, out int itemsFetched);
int Skip(int itemsToSkip);
int Reset();
int Clone(out IEnumDmo enumPointer);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cba01a77002424092a5056050a8397a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,42 @@
using System;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// IMediaBuffer Interface
/// </summary>
[ComImport,
#if !WINDOWS_UWP
System.Security.SuppressUnmanagedCodeSecurity,
#endif
Guid("59eff8b9-938c-4a26-82f2-95cb84cdc837"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMediaBuffer
{
/// <summary>
/// Set Length
/// </summary>
/// <param name="length">Length</param>
/// <returns>HRESULT</returns>
[PreserveSig]
int SetLength(int length);
/// <summary>
/// Get Max Length
/// </summary>
/// <param name="maxLength">Max Length</param>
/// <returns>HRESULT</returns>
[PreserveSig]
int GetMaxLength(out int maxLength);
/// <summary>
/// Get Buffer and Length
/// </summary>
/// <param name="bufferPointerPointer">Pointer to variable into which to write the Buffer Pointer </param>
/// <param name="validDataLengthPointer">Pointer to variable into which to write the Valid Data Length</param>
/// <returns>HRESULT</returns>
[PreserveSig]
int GetBufferAndLength(IntPtr bufferPointerPointer, IntPtr validDataLengthPointer);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b722f575493227f69e761f8cebe96c4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
using System;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// defined in mediaobj.h
/// </summary>
[ComImport,
#if !WINDOWS_UWP
System.Security.SuppressUnmanagedCodeSecurity,
#endif
Guid("d8ad0f58-5494-4102-97c5-ec798e59bcf4"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IMediaObject
{
[PreserveSig]
int GetStreamCount(out int inputStreams, out int outputStreams);
[PreserveSig]
int GetInputStreamInfo(int inputStreamIndex, out InputStreamInfoFlags flags);
[PreserveSig]
int GetOutputStreamInfo(int outputStreamIndex, out OutputStreamInfoFlags flags);
[PreserveSig]
int GetInputType(int inputStreamIndex, int typeIndex, out DmoMediaType mediaType);
[PreserveSig]
int GetOutputType(int outputStreamIndex, int typeIndex, out DmoMediaType mediaType);
[PreserveSig]
int SetInputType(int inputStreamIndex, [In] ref DmoMediaType mediaType, DmoSetTypeFlags flags);
[PreserveSig]
int SetOutputType(int outputStreamIndex, [In] ref DmoMediaType mediaType, DmoSetTypeFlags flags);
[PreserveSig]
int GetInputCurrentType(int inputStreamIndex, out DmoMediaType mediaType);
[PreserveSig]
int GetOutputCurrentType(int outputStreamIndex, out DmoMediaType mediaType);
[PreserveSig]
int GetInputSizeInfo(int inputStreamIndex, out int size, out int maxLookahead, out int alignment);
[PreserveSig]
int GetOutputSizeInfo(int outputStreamIndex, out int size, out int alignment);
[PreserveSig]
int GetInputMaxLatency(int inputStreamIndex, out long referenceTimeMaxLatency);
[PreserveSig]
int SetInputMaxLatency(int inputStreamIndex, long referenceTimeMaxLatency);
[PreserveSig]
int Flush();
[PreserveSig]
int Discontinuity(int inputStreamIndex);
[PreserveSig]
int AllocateStreamingResources();
[PreserveSig]
int FreeStreamingResources();
[PreserveSig]
int GetInputStatus(int inputStreamIndex, out DmoInputStatusFlags flags);
[PreserveSig]
int ProcessInput(int inputStreamIndex, [In] IMediaBuffer mediaBuffer, DmoInputDataBufferFlags flags,
long referenceTimeTimestamp, long referenceTimeDuration);
[PreserveSig]
int ProcessOutput(DmoProcessOutputFlags flags,
int outputBufferCount,
[In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] DmoOutputDataBuffer[] outputBuffers,
out int statusReserved);
[PreserveSig]
int Lock(bool acquireLock);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 732c248ab6e2c4e4abb02927fc8b7a17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,28 @@
using System;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// defined in mediaobj.h
/// </summary>
[ComImport,
System.Security.SuppressUnmanagedCodeSecurity,
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("651B9AD0-0FC7-4AA9-9538-D89931010741")]
internal interface IMediaObjectInPlace
{
[PreserveSig]
int Process(
[In] int size,
[In] IntPtr data,
[In] long refTimeStart,
[In] DmoInPlaceProcessFlags dwFlags);
[PreserveSig]
int Clone([MarshalAs(UnmanagedType.Interface)] out IMediaObjectInPlace mediaObjectInPlace);
[PreserveSig]
int GetLatency(out long latencyTime);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6bf9a4fc24fca50e8a5c5720924685e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,35 @@
using System;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// defined in Medparam.h
/// </summary>
[ComImport,
#if !WINDOWS_UWP
System.Security.SuppressUnmanagedCodeSecurity,
#endif
Guid("6d6cbb60-a223-44aa-842f-a2f06750be6d"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
interface IMediaParamInfo
{
[PreserveSig]
int GetParamCount(out int paramCount);
[PreserveSig] // MP_PARAMINFO
int GetParamInfo(int paramIndex, ref MediaParamInfo paramInfo);
[PreserveSig]
int GetParamText(int paramIndex, out IntPtr paramText);
[PreserveSig]
int GetNumTimeFormats(out int numTimeFormats);
[PreserveSig]
int GetSupportedTimeFormat(int formatIndex, out Guid guidTimeFormat);
[PreserveSig] // MP_TIMEDATA is a DWORD
int GetCurrentTimeFormat(out Guid guidTimeFormat, out int mediaTimeData);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b75f475d8401263e987d09f4e3b8462c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,25 @@
using System;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// Windows Media Resampler Props
/// wmcodecdsp.h
/// </summary>
[Guid("E7E9984F-F09F-4da4-903F-6E2E0EFE56B5"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
ComImport]
interface IWMResamplerProps
{
/// <summary>
/// Range is 1 to 60
/// </summary>
int SetHalfFilterLength(int outputQuality);
/// <summary>
/// Specifies the channel matrix.
/// </summary>
int SetUserChannelMtx([In] float[] channelConversionMatrix);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f5add792cbbba201a8470362b394fe3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
using System;
namespace NAudio.Dmo
{
[Flags]
enum InputStreamInfoFlags
{
None,
DMO_INPUT_STREAMF_WHOLE_SAMPLES = 0x00000001,
DMO_INPUT_STREAMF_SINGLE_SAMPLE_PER_BUFFER = 0x00000002,
DMO_INPUT_STREAMF_FIXED_SAMPLE_SIZE = 0x00000004,
DMO_INPUT_STREAMF_HOLDS_BUFFERS = 0x00000008
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 42169c0b527cad3488e7d3a8a0926ec6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,142 @@
using System;
using System.Runtime.InteropServices;
using NAudio.Utils;
namespace NAudio.Dmo
{
/// <summary>
/// Attempting to implement the COM IMediaBuffer interface as a .NET object
/// Not sure what will happen when I pass this to an unmanaged object
/// </summary>
public class MediaBuffer : IMediaBuffer, IDisposable
{
private IntPtr buffer;
private int length;
private readonly int maxLength;
/// <summary>
/// Creates a new Media Buffer
/// </summary>
/// <param name="maxLength">Maximum length in bytes</param>
public MediaBuffer(int maxLength)
{
buffer = Marshal.AllocCoTaskMem(maxLength);
this.maxLength = maxLength;
}
/// <summary>
/// Dispose and free memory for buffer
/// </summary>
public void Dispose()
{
if (buffer != IntPtr.Zero)
{
Marshal.FreeCoTaskMem(buffer);
buffer = IntPtr.Zero;
GC.SuppressFinalize(this);
}
}
/// <summary>
/// Finalizer
/// </summary>
~MediaBuffer()
{
Dispose();
}
#region IMediaBuffer Members
/// <summary>
/// Set length of valid data in the buffer
/// </summary>
/// <param name="length">length</param>
/// <returns>HRESULT</returns>
int IMediaBuffer.SetLength(int length)
{
//System.Diagnostics.Debug.WriteLine(String.Format("Set Length {0}", length));
if (length > maxLength)
{
return HResult.E_INVALIDARG;
}
this.length = length;
return HResult.S_OK;
}
/// <summary>
/// Gets the maximum length of the buffer
/// </summary>
/// <param name="maxLength">Max length (output parameter)</param>
/// <returns>HRESULT</returns>
int IMediaBuffer.GetMaxLength(out int maxLength)
{
//System.Diagnostics.Debug.WriteLine("Get Max Length");
maxLength = this.maxLength;
return HResult.S_OK;
}
/// <summary>
/// Gets buffer and / or length
/// </summary>
/// <param name="bufferPointerPointer">Pointer to variable into which buffer pointer should be written</param>
/// <param name="validDataLengthPointer">Pointer to variable into which valid data length should be written</param>
/// <returns>HRESULT</returns>
int IMediaBuffer.GetBufferAndLength(IntPtr bufferPointerPointer, IntPtr validDataLengthPointer)
{
//System.Diagnostics.Debug.WriteLine(String.Format("Get Buffer and Length {0},{1}",
// bufferPointerPointer,validDataLengthPointer));
if (bufferPointerPointer != IntPtr.Zero)
{
Marshal.WriteIntPtr(bufferPointerPointer, this.buffer);
}
if (validDataLengthPointer != IntPtr.Zero)
{
Marshal.WriteInt32(validDataLengthPointer, this.length);
}
//System.Diagnostics.Debug.WriteLine("Finished Getting Buffer and Length");
return HResult.S_OK;
}
#endregion
/// <summary>
/// Length of data in the media buffer
/// </summary>
public int Length
{
get { return length; }
set
{
if (length > maxLength)
{
throw new ArgumentException("Cannot be greater than maximum buffer size");
}
length = value;
}
}
/// <summary>
/// Loads data into this buffer
/// </summary>
/// <param name="data">Data to load</param>
/// <param name="bytes">Number of bytes to load</param>
public void LoadData(byte[] data, int bytes)
{
this.Length = bytes;
Marshal.Copy(data, 0, buffer, bytes);
}
/// <summary>
/// Retrieves the data in the output buffer
/// </summary>
/// <param name="data">buffer to retrieve into</param>
/// <param name="offset">offset within that buffer</param>
public void RetrieveData(byte[] data, int offset)
{
Marshal.Copy(buffer, data, offset, Length);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2ab5c74444d865b1f8c8d42473eeeb8d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,491 @@
using System;
using System.Collections.Generic;
using NAudio.Utils;
using System.Runtime.InteropServices;
using NAudio.Wave;
using System.Diagnostics;
namespace NAudio.Dmo
{
/// <summary>
/// Media Object
/// </summary>
public class MediaObject : IDisposable
{
private IMediaObject mediaObject;
private readonly int inputStreams;
private readonly int outputStreams;
#region Construction
/// <summary>
/// Creates a new Media Object
/// </summary>
/// <param name="mediaObject">Media Object COM interface</param>
internal MediaObject(IMediaObject mediaObject)
{
this.mediaObject = mediaObject;
mediaObject.GetStreamCount(out inputStreams, out outputStreams);
}
#endregion
#region Public Properties
/// <summary>
/// Number of input streams
/// </summary>
public int InputStreamCount
{
get { return inputStreams; }
}
/// <summary>
/// Number of output streams
/// </summary>
public int OutputStreamCount
{
get { return outputStreams; }
}
#endregion
#region Get Input and Output Types
/// <summary>
/// Gets the input media type for the specified input stream
/// </summary>
/// <param name="inputStream">Input stream index</param>
/// <param name="inputTypeIndex">Input type index</param>
/// <returns>DMO Media Type or null if there are no more input types</returns>
public DmoMediaType? GetInputType(int inputStream, int inputTypeIndex)
{
try
{
DmoMediaType mediaType;
int hresult = mediaObject.GetInputType(inputStream, inputTypeIndex, out mediaType);
if (hresult == HResult.S_OK)
{
// this frees the format (if present)
// we should therefore come up with a way of marshaling the format
// into a completely managed structure
DmoInterop.MoFreeMediaType(ref mediaType);
return mediaType;
}
}
catch (COMException e)
{
if (e.GetHResult() != (int)DmoHResults.DMO_E_NO_MORE_ITEMS)
{
throw;
}
}
return null;
}
/// <summary>
/// Gets the DMO Media Output type
/// </summary>
/// <param name="outputStream">The output stream</param>
/// <param name="outputTypeIndex">Output type index</param>
/// <returns>DMO Media Type or null if no more available</returns>
public DmoMediaType? GetOutputType(int outputStream, int outputTypeIndex)
{
try
{
DmoMediaType mediaType;
int hresult = mediaObject.GetOutputType(outputStream, outputTypeIndex, out mediaType);
if (hresult == HResult.S_OK)
{
// this frees the format (if present)
// we should therefore come up with a way of marshaling the format
// into a completely managed structure
DmoInterop.MoFreeMediaType(ref mediaType);
return mediaType;
}
}
catch (COMException e)
{
if (e.GetHResult() != (int)DmoHResults.DMO_E_NO_MORE_ITEMS)
{
throw;
}
}
return null;
}
/// <summary>
/// retrieves the media type that was set for an output stream, if any
/// </summary>
/// <param name="outputStreamIndex">Output stream index</param>
/// <returns>DMO Media Type or null if no more available</returns>
public DmoMediaType GetOutputCurrentType(int outputStreamIndex)
{
DmoMediaType mediaType;
int hresult = mediaObject.GetOutputCurrentType(outputStreamIndex, out mediaType);
if (hresult == HResult.S_OK)
{
// this frees the format (if present)
// we should therefore come up with a way of marshaling the format
// into a completely managed structure
DmoInterop.MoFreeMediaType(ref mediaType);
return mediaType;
}
else
{
if (hresult == (int)DmoHResults.DMO_E_TYPE_NOT_SET)
{
throw new InvalidOperationException("Media type was not set.");
}
else
{
throw Marshal.GetExceptionForHR(hresult);
}
}
}
/// <summary>
/// Enumerates the supported input types
/// </summary>
/// <param name="inputStreamIndex">Input stream index</param>
/// <returns>Enumeration of input types</returns>
public IEnumerable<DmoMediaType> GetInputTypes(int inputStreamIndex)
{
int typeIndex = 0;
DmoMediaType? mediaType;
while ((mediaType = GetInputType(inputStreamIndex,typeIndex)) != null)
{
yield return mediaType.Value;
typeIndex++;
}
}
/// <summary>
/// Enumerates the output types
/// </summary>
/// <param name="outputStreamIndex">Output stream index</param>
/// <returns>Enumeration of supported output types</returns>
public IEnumerable<DmoMediaType> GetOutputTypes(int outputStreamIndex)
{
int typeIndex = 0;
DmoMediaType? mediaType;
while ((mediaType = GetOutputType(outputStreamIndex, typeIndex)) != null)
{
yield return mediaType.Value;
typeIndex++;
}
}
#endregion
#region Set Input Type
/// <summary>
/// Querys whether a specified input type is supported
/// </summary>
/// <param name="inputStreamIndex">Input stream index</param>
/// <param name="mediaType">Media type to check</param>
/// <returns>true if supports</returns>
public bool SupportsInputType(int inputStreamIndex, DmoMediaType mediaType)
{
return SetInputType(inputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY);
}
/// <summary>
/// Sets the input type helper method
/// </summary>
/// <param name="inputStreamIndex">Input stream index</param>
/// <param name="mediaType">Media type</param>
/// <param name="flags">Flags (can be used to test rather than set)</param>
private bool SetInputType(int inputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
{
int hResult = mediaObject.SetInputType(inputStreamIndex, ref mediaType, flags);
if (hResult != HResult.S_OK)
{
if (hResult == (int)DmoHResults.DMO_E_INVALIDSTREAMINDEX)
{
throw new ArgumentException("Invalid stream index");
}
if (hResult == (int)DmoHResults.DMO_E_TYPE_NOT_ACCEPTED)
{
Debug.WriteLine("Media type was not accepted");
}
return false;
}
return true;
}
/// <summary>
/// Sets the input type
/// </summary>
/// <param name="inputStreamIndex">Input stream index</param>
/// <param name="mediaType">Media Type</param>
public void SetInputType(int inputStreamIndex, DmoMediaType mediaType)
{
if(!SetInputType(inputStreamIndex,mediaType,DmoSetTypeFlags.None))
{
throw new ArgumentException("Media Type not supported");
}
}
/// <summary>
/// Sets the input type to the specified Wave format
/// </summary>
/// <param name="inputStreamIndex">Input stream index</param>
/// <param name="waveFormat">Wave format</param>
public void SetInputWaveFormat(int inputStreamIndex, WaveFormat waveFormat)
{
DmoMediaType mediaType = CreateDmoMediaTypeForWaveFormat(waveFormat);
bool set = SetInputType(inputStreamIndex, mediaType, DmoSetTypeFlags.None);
DmoInterop.MoFreeMediaType(ref mediaType);
if (!set)
{
throw new ArgumentException("Media Type not supported");
}
}
/// <summary>
/// Requests whether the specified Wave format is supported as an input
/// </summary>
/// <param name="inputStreamIndex">Input stream index</param>
/// <param name="waveFormat">Wave format</param>
/// <returns>true if supported</returns>
public bool SupportsInputWaveFormat(int inputStreamIndex, WaveFormat waveFormat)
{
DmoMediaType mediaType = CreateDmoMediaTypeForWaveFormat(waveFormat);
bool supported = SetInputType(inputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY);
DmoInterop.MoFreeMediaType(ref mediaType);
return supported;
}
/// <summary>
/// Helper function to make a DMO Media Type to represent a particular WaveFormat
/// </summary>
private DmoMediaType CreateDmoMediaTypeForWaveFormat(WaveFormat waveFormat)
{
DmoMediaType mediaType = new DmoMediaType();
int waveFormatExSize = Marshal.SizeOf(waveFormat); // 18 + waveFormat.ExtraSize;
DmoInterop.MoInitMediaType(ref mediaType, waveFormatExSize);
mediaType.SetWaveFormat(waveFormat);
return mediaType;
}
#endregion
#region Set Output Type
/// <summary>
/// Checks if a specified output type is supported
/// n.b. you may need to set the input type first
/// </summary>
/// <param name="outputStreamIndex">Output stream index</param>
/// <param name="mediaType">Media type</param>
/// <returns>True if supported</returns>
public bool SupportsOutputType(int outputStreamIndex, DmoMediaType mediaType)
{
return SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY);
}
/// <summary>
/// Tests if the specified Wave Format is supported for output
/// n.b. may need to set the input type first
/// </summary>
/// <param name="outputStreamIndex">Output stream index</param>
/// <param name="waveFormat">Wave format</param>
/// <returns>True if supported</returns>
public bool SupportsOutputWaveFormat(int outputStreamIndex, WaveFormat waveFormat)
{
DmoMediaType mediaType = CreateDmoMediaTypeForWaveFormat(waveFormat);
bool supported = SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.DMO_SET_TYPEF_TEST_ONLY);
DmoInterop.MoFreeMediaType(ref mediaType);
return supported;
}
/// <summary>
/// Helper method to call SetOutputType
/// </summary>
private bool SetOutputType(int outputStreamIndex, DmoMediaType mediaType, DmoSetTypeFlags flags)
{
int hresult = mediaObject.SetOutputType(outputStreamIndex, ref mediaType, flags);
if (hresult == (int)DmoHResults.DMO_E_TYPE_NOT_ACCEPTED)
{
return false;
}
else if (hresult == HResult.S_OK)
{
return true;
}
else
{
throw Marshal.GetExceptionForHR(hresult);
}
}
/// <summary>
/// Sets the output type
/// n.b. may need to set the input type first
/// </summary>
/// <param name="outputStreamIndex">Output stream index</param>
/// <param name="mediaType">Media type to set</param>
public void SetOutputType(int outputStreamIndex, DmoMediaType mediaType)
{
if (!SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.None))
{
throw new ArgumentException("Media Type not supported");
}
}
/// <summary>
/// Set output type to the specified wave format
/// n.b. may need to set input type first
/// </summary>
/// <param name="outputStreamIndex">Output stream index</param>
/// <param name="waveFormat">Wave format</param>
public void SetOutputWaveFormat(int outputStreamIndex, WaveFormat waveFormat)
{
DmoMediaType mediaType = CreateDmoMediaTypeForWaveFormat(waveFormat);
bool succeeded = SetOutputType(outputStreamIndex, mediaType, DmoSetTypeFlags.None);
DmoInterop.MoFreeMediaType(ref mediaType);
if (!succeeded)
{
throw new ArgumentException("Media Type not supported");
}
}
#endregion
#region Get Input and Output Size Info
/// <summary>
/// Get Input Size Info
/// </summary>
/// <param name="inputStreamIndex">Input Stream Index</param>
/// <returns>Input Size Info</returns>
public MediaObjectSizeInfo GetInputSizeInfo(int inputStreamIndex)
{
int size;
int maxLookahead;
int alignment;
Marshal.ThrowExceptionForHR(mediaObject.GetInputSizeInfo(inputStreamIndex, out size, out maxLookahead, out alignment));
return new MediaObjectSizeInfo(size, maxLookahead, alignment);
}
/// <summary>
/// Get Output Size Info
/// </summary>
/// <param name="outputStreamIndex">Output Stream Index</param>
/// <returns>Output Size Info</returns>
public MediaObjectSizeInfo GetOutputSizeInfo(int outputStreamIndex)
{
int size;
int alignment;
Marshal.ThrowExceptionForHR(mediaObject.GetOutputSizeInfo(outputStreamIndex, out size, out alignment));
return new MediaObjectSizeInfo(size, 0, alignment);
}
#endregion
#region Buffer Processing
/// <summary>
/// Process Input
/// </summary>
/// <param name="inputStreamIndex">Input Stream index</param>
/// <param name="mediaBuffer">Media Buffer</param>
/// <param name="flags">Flags</param>
/// <param name="timestamp">Timestamp</param>
/// <param name="duration">Duration</param>
public void ProcessInput(int inputStreamIndex, IMediaBuffer mediaBuffer, DmoInputDataBufferFlags flags,
long timestamp, long duration)
{
Marshal.ThrowExceptionForHR(mediaObject.ProcessInput(inputStreamIndex, mediaBuffer, flags, timestamp, duration));
}
/// <summary>
/// Process Output
/// </summary>
/// <param name="flags">Flags</param>
/// <param name="outputBufferCount">Output buffer count</param>
/// <param name="outputBuffers">Output buffers</param>
public void ProcessOutput(DmoProcessOutputFlags flags, int outputBufferCount, DmoOutputDataBuffer[] outputBuffers)
{
int reserved;
Marshal.ThrowExceptionForHR(mediaObject.ProcessOutput(flags, outputBufferCount, outputBuffers, out reserved));
}
#endregion
/// <summary>
/// Gives the DMO a chance to allocate any resources needed for streaming
/// </summary>
public void AllocateStreamingResources()
{
Marshal.ThrowExceptionForHR(mediaObject.AllocateStreamingResources());
}
/// <summary>
/// Tells the DMO to free any resources needed for streaming
/// </summary>
public void FreeStreamingResources()
{
Marshal.ThrowExceptionForHR(mediaObject.FreeStreamingResources());
}
/// <summary>
/// Gets maximum input latency
/// </summary>
/// <param name="inputStreamIndex">input stream index</param>
/// <returns>Maximum input latency as a ref-time</returns>
public long GetInputMaxLatency(int inputStreamIndex)
{
long maxLatency;
Marshal.ThrowExceptionForHR(mediaObject.GetInputMaxLatency(inputStreamIndex, out maxLatency));
return maxLatency;
}
/// <summary>
/// Flushes all buffered data
/// </summary>
public void Flush()
{
Marshal.ThrowExceptionForHR(mediaObject.Flush());
}
/// <summary>
/// Report a discontinuity on the specified input stream
/// </summary>
/// <param name="inputStreamIndex">Input Stream index</param>
public void Discontinuity(int inputStreamIndex)
{
Marshal.ThrowExceptionForHR(mediaObject.Discontinuity(inputStreamIndex));
}
/// <summary>
/// Is this input stream accepting data?
/// </summary>
/// <param name="inputStreamIndex">Input Stream index</param>
/// <returns>true if accepting data</returns>
public bool IsAcceptingData(int inputStreamIndex)
{
DmoInputStatusFlags flags;
int hresult = mediaObject.GetInputStatus(inputStreamIndex, out flags);
Marshal.ThrowExceptionForHR(hresult);
return (flags & DmoInputStatusFlags.DMO_INPUT_STATUSF_ACCEPT_DATA) == DmoInputStatusFlags.DMO_INPUT_STATUSF_ACCEPT_DATA;
}
// TODO: there are still several IMediaObject functions to be wrapped
#region IDisposable Members
/// <summary>
/// Experimental code, not currently being called
/// Not sure if it is necessary anyway
/// </summary>
public void Dispose()
{
if (mediaObject != null)
{
Marshal.ReleaseComObject(mediaObject);
mediaObject = null;
}
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9cf19be77f18a21d9a44f2ffd62cfc0d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,87 @@
using System;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// Media Object InPlace
/// </summary>
public class MediaObjectInPlace : IDisposable
{
private IMediaObjectInPlace mediaObjectInPlace;
/// <summary>
/// Creates a new Media Object InPlace
/// </summary>
/// <param name="mediaObjectInPlace">Media Object InPlace COM Interface</param>
internal MediaObjectInPlace(IMediaObjectInPlace mediaObjectInPlace)
{
this.mediaObjectInPlace = mediaObjectInPlace;
}
/// <summary>
/// Processes a block of data.
/// The application supplies a pointer to a block of input data. The DMO processes the data in place.
/// </summary>
/// <param name="size">Size of the data, in bytes.</param>
/// <param name="offset">offset into buffer</param>
/// <param name="data">In/Out Data Buffer</param>
/// <param name="timeStart">Start time of the data.</param>
/// <param name="inPlaceFlag">DmoInplaceProcessFlags</param>
/// <returns>Return value when Process is executed with IMediaObjectInPlace</returns>
public DmoInPlaceProcessReturn Process(int size, int offset, byte[] data, long timeStart, DmoInPlaceProcessFlags inPlaceFlag)
{
var pointer = Marshal.AllocHGlobal(size);
Marshal.Copy(data, offset, pointer, size);
var result = mediaObjectInPlace.Process(size, pointer, timeStart, inPlaceFlag);
Marshal.ThrowExceptionForHR(result);
Marshal.Copy(pointer, data, offset, size);
Marshal.FreeHGlobal(pointer);
return (DmoInPlaceProcessReturn) result;
}
/// <summary>
/// Creates a copy of the DMO in its current state.
/// </summary>
/// <returns>Copyed MediaObjectInPlace</returns>
public MediaObjectInPlace Clone()
{
Marshal.ThrowExceptionForHR(this.mediaObjectInPlace.Clone(out var cloneObj));
return new MediaObjectInPlace(cloneObj);
}
/// <summary>
/// Retrieves the latency introduced by this DMO.
/// </summary>
/// <returns>The latency, in 100-nanosecond units</returns>
public long GetLatency()
{
Marshal.ThrowExceptionForHR(this.mediaObjectInPlace.GetLatency(out var latencyTime));
return latencyTime;
}
/// <summary>
/// Get Media Object
/// </summary>
/// <returns>Media Object</returns>
public MediaObject GetMediaObject()
{
return new MediaObject((IMediaObject) mediaObjectInPlace);
}
/// <summary>
/// Dispose code
/// </summary>
public void Dispose()
{
if (mediaObjectInPlace != null)
{
Marshal.ReleaseComObject(mediaObjectInPlace);
mediaObjectInPlace = null;
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ae8ce3663e8de93e5b0c316607ab168c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,44 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// Media Object Size Info
/// </summary>
public class MediaObjectSizeInfo
{
/// <summary>
/// Minimum Buffer Size, in bytes
/// </summary>
public int Size { get; private set; }
/// <summary>
/// Max Lookahead
/// </summary>
public int MaxLookahead { get; }
/// <summary>
/// Alignment
/// </summary>
public int Alignment { get; }
/// <summary>
/// Media Object Size Info
/// </summary>
public MediaObjectSizeInfo(int size, int maxLookahead, int alignment)
{
Size = size;
MaxLookahead = maxLookahead;
Alignment = alignment;
}
/// <summary>
/// ToString
/// </summary>
public override string ToString()
{
return $"Size: {Size}, Alignment {Alignment}, MaxLookahead {MaxLookahead}";
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e0248885c30d4cd4991ac25b67f3b507
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,64 @@
using System;
using System.Runtime.InteropServices;
namespace NAudio.Dmo
{
/// <summary>
/// MP_PARAMINFO
/// </summary>
struct MediaParamInfo
{
#pragma warning disable 0649
public MediaParamType mpType;
public MediaParamCurveType mopCaps;
public float mpdMinValue; // MP_DATA is a float
public float mpdMaxValue;
public float mpdNeutralValue;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string szUnitText;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string szLabel;
#pragma warning restore 0649
}
/// <summary>
/// MP_TYPE
/// </summary>
enum MediaParamType
{
/// <summary>
/// MPT_INT
/// </summary>
Int,
/// <summary>
/// MPT_FLOAT
/// </summary>
Float,
/// <summary>
/// MPT_BOOL
/// </summary>
Bool,
/// <summary>
/// MPT_ENUM
/// </summary>
Enum,
/// <summary>
/// MPT_MAX
/// </summary>
Max,
}
/// <summary>
/// MP_CURVE_TYPE
/// </summary>
[Flags]
internal enum MediaParamCurveType
{
MP_CURVE_JUMP = 0x1,
MP_CURVE_LINEAR = 0x2,
MP_CURVE_SQUARE = 0x4,
MP_CURVE_INVSQUARE = 0x8,
MP_CURVE_SINE = 0x10
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 14b99da6613e7f1089aa701d10f9e087
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,72 @@
using System;
namespace NAudio.Dmo
{
/// <summary>
/// uuids.h, ksuuids.h
/// </summary>
static class MediaTypes
{
public static readonly Guid MEDIATYPE_AnalogAudio = new Guid("0482DEE1-7817-11cf-8a03-00aa006ecb65"); // Analog audio.
public static readonly Guid MEDIATYPE_AnalogVideo = new Guid("0482DDE1-7817-11cf-8A03-00AA006ECB65"); // Analog video.
public static readonly Guid MEDIATYPE_Audio = new Guid("73647561-0000-0010-8000-00AA00389B71"); // Audio.
public static readonly Guid MEDIATYPE_AUXLine21Data = new Guid("670AEA80-3A82-11d0-B79B-00AA003767A7"); // Line 21 data. Used by closed captions.
public static readonly Guid MEDIATYPE_File = new Guid("656c6966-0000-0010-8000-00AA00389B71"); // File. (Obsolete)
public static readonly Guid MEDIATYPE_Interleaved = new Guid("73766169-0000-0010-8000-00AA00389B71"); // Interleaved audio and video. Used for Digital Video (DV).
public static readonly Guid MEDIATYPE_Midi = new Guid("7364696D-0000-0010-8000-00AA00389B71"); // MIDI format.
// public static readonly Guid MEDIATYPE_MPEG2_PES MPEG-2 PES packets.
// public static readonly Guid MEDIATYPE_MPEG2_SECTIONS MPEG-2 section data
public static readonly Guid MEDIATYPE_ScriptCommand = new Guid("73636d64-0000-0010-8000-00AA00389B71"); // Data is a script command, used by closed captions.
public static readonly Guid MEDIATYPE_Stream = new Guid("e436eb83-524f-11ce-9f53-0020af0ba770"); // Byte stream with no time stamps.
public static readonly Guid MEDIATYPE_Text = new Guid("73747874-0000-0010-8000-00AA00389B71"); // Text.
public static readonly Guid MEDIATYPE_Timecode = new Guid("0482DEE3-7817-11cf-8a03-00aa006ecb65"); // Timecode data. Note: DirectShow does not provide any filters that support this media type.
public static readonly Guid MEDIATYPE_Video = new Guid("73646976-0000-0010-8000-00AA00389B71"); // Video.
public static readonly Guid[] MajorTypes = new Guid[]
{
MEDIATYPE_AnalogAudio,
MEDIATYPE_AnalogVideo,
MEDIATYPE_Audio,
MEDIATYPE_AUXLine21Data,
MEDIATYPE_File,
MEDIATYPE_Interleaved,
MEDIATYPE_Midi,
MEDIATYPE_ScriptCommand,
MEDIATYPE_Stream,
MEDIATYPE_Text,
MEDIATYPE_Timecode,
MEDIATYPE_Video,
};
public static readonly string[] MajorTypeNames = new string[]
{
"Analog Audio",
"Analog Video",
"Audio",
"AUXLine21Data",
"File",
"Interleaved",
"Midi",
"ScriptCommand",
"Stream",
"Text",
"Timecode",
"Video",
};
public static string GetMediaTypeName(Guid majorType)
{
for (int index = 0; index < MajorTypes.Length; index++)
{
if (majorType == MajorTypes[index])
{
return MajorTypeNames[index];
}
}
throw new ArgumentException("Major Type not found");
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2d00baed247aaf06fa0974c81f0edb08
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
using System;
namespace NAudio.Dmo
{
[Flags]
enum OutputStreamInfoFlags
{
DMO_OUTPUT_STREAMF_WHOLE_SAMPLES = 0x00000001,
DMO_OUTPUT_STREAMF_SINGLE_SAMPLE_PER_BUFFER = 0x00000002,
DMO_OUTPUT_STREAMF_FIXED_SAMPLE_SIZE = 0x00000004,
DMO_OUTPUT_STREAMF_DISCARDABLE = 0x00000008,
DMO_OUTPUT_STREAMF_OPTIONAL = 0x00000010
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4adc696038ab3e3b8b483930316564c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,80 @@
using System;
using System.Runtime.InteropServices;
using NAudio.CoreAudioApi.Interfaces;
namespace NAudio.Dmo
{
/// <summary>
/// From wmcodecsdp.h
/// Implements:
/// - IMediaObject
/// - IMFTransform (Media foundation - we will leave this for now as there is loads of MF stuff)
/// - IPropertyStore
/// - IWMResamplerProps
/// Can resample PCM or IEEE
/// </summary>
[ComImport, Guid("f447b69e-1884-4a7e-8055-346f74d6edb3")]
class ResamplerMediaComObject
{
}
/// <summary>
/// DMO Resampler
/// </summary>
public class DmoResampler : IDisposable
{
MediaObject mediaObject;
IPropertyStore propertyStoreInterface;
IWMResamplerProps resamplerPropsInterface;
ResamplerMediaComObject mediaComObject;
/// <summary>
/// Creates a new Resampler based on the DMO Resampler
/// </summary>
public DmoResampler()
{
mediaComObject = new ResamplerMediaComObject();
mediaObject = new MediaObject((IMediaObject)mediaComObject);
propertyStoreInterface = (IPropertyStore)mediaComObject;
resamplerPropsInterface = (IWMResamplerProps)mediaComObject;
}
/// <summary>
/// Media Object
/// </summary>
public MediaObject MediaObject => mediaObject;
#region IDisposable Members
/// <summary>
/// Dispose code - experimental at the moment
/// Was added trying to track down why Resampler crashes NUnit
/// This code not currently being called by ResamplerDmoStream
/// </summary>
public void Dispose()
{
if(propertyStoreInterface != null)
{
Marshal.ReleaseComObject(propertyStoreInterface);
propertyStoreInterface = null;
}
if(resamplerPropsInterface != null)
{
Marshal.ReleaseComObject(resamplerPropsInterface);
resamplerPropsInterface = null;
}
if (mediaObject != null)
{
mediaObject.Dispose();
mediaObject = null;
}
if (mediaComObject != null)
{
Marshal.ReleaseComObject(mediaComObject);
mediaComObject = null;
}
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2dd4d0cd273c4927c9d3fbde6f81713b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,88 @@
using System;
using System.Runtime.InteropServices;
using NAudio.CoreAudioApi.Interfaces;
namespace NAudio.Dmo
{
// http://msdn.microsoft.com/en-us/library/ff819509%28VS.85%29.aspx
// CLSID_CMP3DecMediaObject
/// <summary>
/// implements IMediaObject (DirectX Media Object)
/// implements IMFTransform (Media Foundation Transform)
/// On Windows XP, it is always an MM (if present at all)
/// </summary>
[ComImport, Guid("bbeea841-0a63-4f52-a7ab-a9b3a84ed38a")]
class WindowsMediaMp3DecoderComObject
{
}
/// <summary>
/// Windows Media MP3 Decoder (as a DMO)
/// WORK IN PROGRESS - DO NOT USE!
/// </summary>
public class WindowsMediaMp3Decoder : IDisposable
{
MediaObject mediaObject;
IPropertyStore propertyStoreInterface;
//IWMResamplerProps resamplerPropsInterface;
WindowsMediaMp3DecoderComObject mediaComObject;
/// <summary>
/// Creates a new Resampler based on the DMO Resampler
/// </summary>
public WindowsMediaMp3Decoder()
{
mediaComObject = new WindowsMediaMp3DecoderComObject();
mediaObject = new MediaObject((IMediaObject)mediaComObject);
propertyStoreInterface = (IPropertyStore)mediaComObject;
//resamplerPropsInterface = (IWMResamplerProps)mediaComObject;
}
/// <summary>
/// Media Object
/// </summary>
public MediaObject MediaObject
{
get
{
return mediaObject;
}
}
#region IDisposable Members
/// <summary>
/// Dispose code - experimental at the moment
/// Was added trying to track down why Resampler crashes NUnit
/// This code not currently being called by ResamplerDmoStream
/// </summary>
public void Dispose()
{
if(propertyStoreInterface != null)
{
Marshal.ReleaseComObject(propertyStoreInterface);
propertyStoreInterface = null;
}
/*if(resamplerPropsInterface != null)
{
Marshal.ReleaseComObject(resamplerPropsInterface);
resamplerPropsInterface = null;
}*/
if (mediaObject != null)
{
mediaObject.Dispose();
mediaObject = null;
}
if (mediaComObject != null)
{
Marshal.ReleaseComObject(mediaComObject);
mediaComObject = null;
}
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b90b2c5020c6991d0b8fed5c598950ec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: