Replace naudio.dll with code
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44144d1b105863e4ab0d1a121b916482
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,355 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an installed ACM Driver
|
||||
/// </summary>
|
||||
public class AcmDriver : IDisposable
|
||||
{
|
||||
private static List<AcmDriver> drivers;
|
||||
private AcmDriverDetails details;
|
||||
private IntPtr driverId;
|
||||
private IntPtr driverHandle;
|
||||
private List<AcmFormatTag> formatTags;
|
||||
private List<AcmFormat> tempFormatsList; // used by enumerator
|
||||
private IntPtr localDllHandle;
|
||||
|
||||
/// <summary>
|
||||
/// Helper function to determine whether a particular codec is installed
|
||||
/// </summary>
|
||||
/// <param name="shortName">The short name of the function</param>
|
||||
/// <returns>Whether the codec is installed</returns>
|
||||
public static bool IsCodecInstalled(string shortName)
|
||||
{
|
||||
foreach (AcmDriver driver in EnumerateAcmDrivers())
|
||||
{
|
||||
if (driver.ShortName == shortName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to add a new ACM driver from a file
|
||||
/// </summary>
|
||||
/// <param name="driverFile">Full path of the .acm or dll file containing the driver</param>
|
||||
/// <returns>Handle to the driver</returns>
|
||||
public static AcmDriver AddLocalDriver(string driverFile)
|
||||
{
|
||||
IntPtr handle = NativeMethods.LoadLibrary(driverFile);
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
throw new ArgumentException("Failed to load driver file");
|
||||
}
|
||||
var driverProc = NativeMethods.GetProcAddress(handle, "DriverProc");
|
||||
if (driverProc == IntPtr.Zero)
|
||||
{
|
||||
NativeMethods.FreeLibrary(handle);
|
||||
throw new ArgumentException("Failed to discover DriverProc");
|
||||
}
|
||||
IntPtr driverHandle;
|
||||
var result = AcmInterop.acmDriverAdd(out driverHandle,
|
||||
handle, driverProc, 0, AcmDriverAddFlags.Function);
|
||||
if (result != MmResult.NoError)
|
||||
{
|
||||
NativeMethods.FreeLibrary(handle);
|
||||
throw new MmException(result, "acmDriverAdd");
|
||||
}
|
||||
var driver = new AcmDriver(driverHandle);
|
||||
// long name seems to be missing when we use acmDriverAdd
|
||||
if (string.IsNullOrEmpty(driver.details.longName))
|
||||
{
|
||||
driver.details.longName = "Local driver: " + Path.GetFileName(driverFile);
|
||||
driver.localDllHandle = handle;
|
||||
}
|
||||
return driver;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a driver previously added using AddLocalDriver
|
||||
/// </summary>
|
||||
/// <param name="localDriver">Local driver to remove</param>
|
||||
public static void RemoveLocalDriver(AcmDriver localDriver)
|
||||
{
|
||||
if (localDriver.localDllHandle == IntPtr.Zero)
|
||||
{
|
||||
throw new ArgumentException("Please pass in the AcmDriver returned by the AddLocalDriver method");
|
||||
}
|
||||
var removeResult = AcmInterop.acmDriverRemove(localDriver.driverId, 0); // gets stored as a driver Id
|
||||
NativeMethods.FreeLibrary(localDriver.localDllHandle);
|
||||
MmException.Try(removeResult, "acmDriverRemove");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show Format Choose Dialog
|
||||
/// </summary>
|
||||
/// <param name="ownerWindowHandle">Owner window handle, can be null</param>
|
||||
/// <param name="windowTitle">Window title</param>
|
||||
/// <param name="enumFlags">Enumeration flags. None to get everything</param>
|
||||
/// <param name="enumFormat">Enumeration format. Only needed with certain enumeration flags</param>
|
||||
/// <param name="selectedFormat">The selected format</param>
|
||||
/// <param name="selectedFormatDescription">Textual description of the selected format</param>
|
||||
/// <param name="selectedFormatTagDescription">Textual description of the selected format tag</param>
|
||||
/// <returns>True if a format was selected</returns>
|
||||
public static bool ShowFormatChooseDialog(
|
||||
IntPtr ownerWindowHandle,
|
||||
string windowTitle,
|
||||
AcmFormatEnumFlags enumFlags,
|
||||
WaveFormat enumFormat,
|
||||
out WaveFormat selectedFormat,
|
||||
out string selectedFormatDescription,
|
||||
out string selectedFormatTagDescription)
|
||||
{
|
||||
AcmFormatChoose formatChoose = new AcmFormatChoose();
|
||||
formatChoose.structureSize = Marshal.SizeOf(formatChoose);
|
||||
formatChoose.styleFlags = AcmFormatChooseStyleFlags.None;
|
||||
formatChoose.ownerWindowHandle = ownerWindowHandle;
|
||||
int maxFormatSize = 200; // guess
|
||||
formatChoose.selectedWaveFormatPointer = Marshal.AllocHGlobal(maxFormatSize);
|
||||
formatChoose.selectedWaveFormatByteSize = maxFormatSize;
|
||||
formatChoose.title = windowTitle;
|
||||
formatChoose.name = null;
|
||||
formatChoose.formatEnumFlags = enumFlags;//AcmFormatEnumFlags.None;
|
||||
formatChoose.waveFormatEnumPointer = IntPtr.Zero;
|
||||
if (enumFormat != null)
|
||||
{
|
||||
IntPtr enumPointer = Marshal.AllocHGlobal(Marshal.SizeOf(enumFormat));
|
||||
Marshal.StructureToPtr(enumFormat,enumPointer,false);
|
||||
formatChoose.waveFormatEnumPointer = enumPointer;
|
||||
}
|
||||
formatChoose.instanceHandle = IntPtr.Zero;
|
||||
formatChoose.templateName = null;
|
||||
|
||||
MmResult result = AcmInterop.acmFormatChoose(ref formatChoose);
|
||||
selectedFormat = null;
|
||||
selectedFormatDescription = null;
|
||||
selectedFormatTagDescription = null;
|
||||
if (result == MmResult.NoError)
|
||||
{
|
||||
selectedFormat = WaveFormat.MarshalFromPtr(formatChoose.selectedWaveFormatPointer);
|
||||
selectedFormatDescription = formatChoose.formatDescription;
|
||||
selectedFormatTagDescription = formatChoose.formatTagDescription;
|
||||
}
|
||||
|
||||
Marshal.FreeHGlobal(formatChoose.waveFormatEnumPointer);
|
||||
Marshal.FreeHGlobal(formatChoose.selectedWaveFormatPointer);
|
||||
if(result != MmResult.AcmCancelled && result != MmResult.NoError)
|
||||
{
|
||||
throw new MmException(result, "acmFormatChoose");
|
||||
}
|
||||
return result == MmResult.NoError;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum size needed to store a WaveFormat for ACM interop functions
|
||||
/// </summary>
|
||||
public int MaxFormatSize
|
||||
{
|
||||
get
|
||||
{
|
||||
int maxFormatSize;
|
||||
MmException.Try(AcmInterop.acmMetrics(driverHandle, AcmMetrics.MaxSizeFormat, out maxFormatSize), "acmMetrics");
|
||||
return maxFormatSize;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds a Driver by its short name
|
||||
/// </summary>
|
||||
/// <param name="shortName">Short Name</param>
|
||||
/// <returns>The driver, or null if not found</returns>
|
||||
public static AcmDriver FindByShortName(string shortName)
|
||||
{
|
||||
foreach (AcmDriver driver in AcmDriver.EnumerateAcmDrivers())
|
||||
{
|
||||
if (driver.ShortName == shortName)
|
||||
{
|
||||
return driver;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of the ACM Drivers installed
|
||||
/// </summary>
|
||||
public static IEnumerable<AcmDriver> EnumerateAcmDrivers()
|
||||
{
|
||||
drivers = new List<AcmDriver>();
|
||||
MmException.Try(AcmInterop.acmDriverEnum(new AcmInterop.AcmDriverEnumCallback(DriverEnumCallback), IntPtr.Zero, 0), "acmDriverEnum");
|
||||
return drivers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The callback for acmDriverEnum
|
||||
/// </summary>
|
||||
private static bool DriverEnumCallback(IntPtr hAcmDriver, IntPtr dwInstance, AcmDriverDetailsSupportFlags flags)
|
||||
{
|
||||
drivers.Add(new AcmDriver(hAcmDriver));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new ACM Driver object
|
||||
/// </summary>
|
||||
/// <param name="hAcmDriver">Driver handle</param>
|
||||
private AcmDriver(IntPtr hAcmDriver)
|
||||
{
|
||||
driverId = hAcmDriver;
|
||||
details = new AcmDriverDetails();
|
||||
details.structureSize = Marshal.SizeOf(details);
|
||||
MmException.Try(AcmInterop.acmDriverDetails(hAcmDriver, ref details, 0), "acmDriverDetails");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The short name of this driver
|
||||
/// </summary>
|
||||
public string ShortName
|
||||
{
|
||||
get
|
||||
{
|
||||
return details.shortName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The full name of this driver
|
||||
/// </summary>
|
||||
public string LongName
|
||||
{
|
||||
get
|
||||
{
|
||||
return details.longName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The driver ID
|
||||
/// </summary>
|
||||
public IntPtr DriverId
|
||||
{
|
||||
get
|
||||
{
|
||||
return driverId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ToString
|
||||
/// </summary>
|
||||
public override string ToString()
|
||||
{
|
||||
return LongName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The list of FormatTags for this ACM Driver
|
||||
/// </summary>
|
||||
public IEnumerable<AcmFormatTag> FormatTags
|
||||
{
|
||||
get
|
||||
{
|
||||
if (formatTags == null)
|
||||
{
|
||||
if (driverHandle == IntPtr.Zero)
|
||||
{
|
||||
throw new InvalidOperationException("Driver must be opened first");
|
||||
}
|
||||
formatTags = new List<AcmFormatTag>();
|
||||
AcmFormatTagDetails formatTagDetails = new AcmFormatTagDetails();
|
||||
formatTagDetails.structureSize = Marshal.SizeOf(formatTagDetails);
|
||||
MmException.Try(AcmInterop.acmFormatTagEnum(this.driverHandle, ref formatTagDetails, AcmFormatTagEnumCallback, IntPtr.Zero, 0), "acmFormatTagEnum");
|
||||
}
|
||||
return formatTags;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the supported formats for a given format tag
|
||||
/// </summary>
|
||||
/// <param name="formatTag">Format tag</param>
|
||||
/// <returns>Supported formats</returns>
|
||||
public IEnumerable<AcmFormat> GetFormats(AcmFormatTag formatTag)
|
||||
{
|
||||
if (driverHandle == IntPtr.Zero)
|
||||
{
|
||||
throw new InvalidOperationException("Driver must be opened first");
|
||||
}
|
||||
tempFormatsList = new List<AcmFormat>();
|
||||
var formatDetails = new AcmFormatDetails();
|
||||
formatDetails.structSize = Marshal.SizeOf(formatDetails);
|
||||
// need to make sure we have enough space for a waveFormat. formatTag.FormatSize isn't reliable,
|
||||
// and some codecs MaxFormatSize isn't either
|
||||
formatDetails.waveFormatByteSize = 1024;
|
||||
formatDetails.waveFormatPointer = Marshal.AllocHGlobal(formatDetails.waveFormatByteSize);
|
||||
formatDetails.formatTag = (int)formatTag.FormatTag; // (int)WaveFormatEncoding.Unknown
|
||||
var result = AcmInterop.acmFormatEnum(driverHandle,
|
||||
ref formatDetails, AcmFormatEnumCallback, IntPtr.Zero,
|
||||
AcmFormatEnumFlags.None);
|
||||
Marshal.FreeHGlobal(formatDetails.waveFormatPointer);
|
||||
MmException.Try(result,"acmFormatEnum");
|
||||
return tempFormatsList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens this driver
|
||||
/// </summary>
|
||||
public void Open()
|
||||
{
|
||||
if (driverHandle == IntPtr.Zero)
|
||||
{
|
||||
MmException.Try(AcmInterop.acmDriverOpen(out driverHandle, DriverId, 0), "acmDriverOpen");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes this driver
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
if(driverHandle != IntPtr.Zero)
|
||||
{
|
||||
MmException.Try(AcmInterop.acmDriverClose(driverHandle, 0),"acmDriverClose");
|
||||
driverHandle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
private bool AcmFormatTagEnumCallback(IntPtr hAcmDriverId, ref AcmFormatTagDetails formatTagDetails, IntPtr dwInstance, AcmDriverDetailsSupportFlags flags)
|
||||
{
|
||||
formatTags.Add(new AcmFormatTag(formatTagDetails));
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool AcmFormatEnumCallback(IntPtr hAcmDriverId, ref AcmFormatDetails formatDetails, IntPtr dwInstance, AcmDriverDetailsSupportFlags flags)
|
||||
{
|
||||
tempFormatsList.Add(new AcmFormat(formatDetails));
|
||||
return true;
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (driverHandle != IntPtr.Zero)
|
||||
{
|
||||
Close();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b27e189f9487e254eba601c5a229b693
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// Flags for use with acmDriverAdd
|
||||
/// </summary>
|
||||
enum AcmDriverAddFlags
|
||||
{
|
||||
// also ACM_DRIVERADDF_TYPEMASK = 0x00000007;
|
||||
|
||||
/// <summary>
|
||||
/// ACM_DRIVERADDF_LOCAL
|
||||
/// </summary>
|
||||
Local = 0,
|
||||
/// <summary>
|
||||
/// ACM_DRIVERADDF_GLOBAL
|
||||
/// </summary>
|
||||
Global = 8,
|
||||
/// <summary>
|
||||
/// ACM_DRIVERADDF_FUNCTION
|
||||
/// </summary>
|
||||
Function = 3,
|
||||
/// <summary>
|
||||
/// ACM_DRIVERADDF_NOTIFYHWND
|
||||
/// </summary>
|
||||
NotifyWindowHandle = 4,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c765ad7c86a0f94e913f0f3a401ae4a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// Interop structure for ACM driver details (ACMDRIVERDETAILS)
|
||||
/// http://msdn.microsoft.com/en-us/library/dd742889%28VS.85%29.aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack=2)]
|
||||
struct AcmDriverDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// DWORD cbStruct
|
||||
/// </summary>
|
||||
public int structureSize;
|
||||
/// <summary>
|
||||
/// FOURCC fccType
|
||||
/// </summary>
|
||||
public UInt32 fccType;
|
||||
/// <summary>
|
||||
/// FOURCC fccComp
|
||||
/// </summary>
|
||||
public UInt32 fccComp;
|
||||
/// <summary>
|
||||
/// WORD wMid;
|
||||
/// </summary>
|
||||
public UInt16 manufacturerId;
|
||||
/// <summary>
|
||||
/// WORD wPid
|
||||
/// </summary>
|
||||
public UInt16 productId;
|
||||
/// <summary>
|
||||
/// DWORD vdwACM
|
||||
/// </summary>
|
||||
public UInt32 acmVersion;
|
||||
/// <summary>
|
||||
/// DWORD vdwDriver
|
||||
/// </summary>
|
||||
public UInt32 driverVersion;
|
||||
/// <summary>
|
||||
/// DWORD fdwSupport;
|
||||
/// </summary>
|
||||
public AcmDriverDetailsSupportFlags supportFlags;
|
||||
/// <summary>
|
||||
/// DWORD cFormatTags
|
||||
/// </summary>
|
||||
public int formatTagsCount;
|
||||
/// <summary>
|
||||
/// DWORD cFilterTags
|
||||
/// </summary>
|
||||
public int filterTagsCount;
|
||||
/// <summary>
|
||||
/// HICON hicon
|
||||
/// </summary>
|
||||
public IntPtr hicon;
|
||||
/// <summary>
|
||||
/// TCHAR szShortName[ACMDRIVERDETAILS_SHORTNAME_CHARS];
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = ShortNameChars)]
|
||||
public string shortName;
|
||||
/// <summary>
|
||||
/// TCHAR szLongName[ACMDRIVERDETAILS_LONGNAME_CHARS];
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LongNameChars)]
|
||||
public string longName;
|
||||
/// <summary>
|
||||
/// TCHAR szCopyright[ACMDRIVERDETAILS_COPYRIGHT_CHARS];
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CopyrightChars)]
|
||||
public string copyright;
|
||||
/// <summary>
|
||||
/// TCHAR szLicensing[ACMDRIVERDETAILS_LICENSING_CHARS];
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = LicensingChars)]
|
||||
public string licensing;
|
||||
/// <summary>
|
||||
/// TCHAR szFeatures[ACMDRIVERDETAILS_FEATURES_CHARS];
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = FeaturesChars)]
|
||||
public string features;
|
||||
|
||||
/// <summary>
|
||||
/// ACMDRIVERDETAILS_SHORTNAME_CHARS
|
||||
/// </summary>
|
||||
private const int ShortNameChars = 32;
|
||||
/// <summary>
|
||||
/// ACMDRIVERDETAILS_LONGNAME_CHARS
|
||||
/// </summary>
|
||||
private const int LongNameChars = 128;
|
||||
/// <summary>
|
||||
/// ACMDRIVERDETAILS_COPYRIGHT_CHARS
|
||||
/// </summary>
|
||||
private const int CopyrightChars = 80;
|
||||
/// <summary>
|
||||
/// ACMDRIVERDETAILS_LICENSING_CHARS
|
||||
/// </summary>
|
||||
private const int LicensingChars = 128;
|
||||
/// <summary>
|
||||
/// ACMDRIVERDETAILS_FEATURES_CHARS
|
||||
/// </summary>
|
||||
private const int FeaturesChars = 512;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38cba6e5109e264409e18ccc2d44f322
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// Flags indicating what support a particular ACM driver has
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum AcmDriverDetailsSupportFlags
|
||||
{
|
||||
/// <summary>ACMDRIVERDETAILS_SUPPORTF_CODEC - Codec</summary>
|
||||
Codec = 0x00000001,
|
||||
/// <summary>ACMDRIVERDETAILS_SUPPORTF_CONVERTER - Converter</summary>
|
||||
Converter = 0x00000002,
|
||||
/// <summary>ACMDRIVERDETAILS_SUPPORTF_FILTER - Filter</summary>
|
||||
Filter = 0x00000004,
|
||||
/// <summary>ACMDRIVERDETAILS_SUPPORTF_HARDWARE - Hardware</summary>
|
||||
Hardware = 0x00000008,
|
||||
/// <summary>ACMDRIVERDETAILS_SUPPORTF_ASYNC - Async</summary>
|
||||
Async = 0x00000010,
|
||||
/// <summary>ACMDRIVERDETAILS_SUPPORTF_LOCAL - Local</summary>
|
||||
Local = 0x40000000,
|
||||
/// <summary>ACMDRIVERDETAILS_SUPPORTF_DISABLED - Disabled</summary>
|
||||
Disabled = unchecked((int)0x80000000),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1daf4548b2f072c46b283d2048f9ca3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
[Flags]
|
||||
enum AcmDriverEnumFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// ACM_DRIVERENUMF_NOLOCAL, Only global drivers should be included in the enumeration
|
||||
/// </summary>
|
||||
NoLocal = 0x40000000,
|
||||
/// <summary>
|
||||
/// ACM_DRIVERENUMF_DISABLED, Disabled ACM drivers should be included in the enumeration
|
||||
/// </summary>
|
||||
Disabled = unchecked((int)0x80000000),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11b8c09b55c53eb48a604073c7a0b243
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// ACM Format
|
||||
/// </summary>
|
||||
public class AcmFormat
|
||||
{
|
||||
private readonly AcmFormatDetails formatDetails;
|
||||
private readonly WaveFormat waveFormat;
|
||||
|
||||
internal AcmFormat(AcmFormatDetails formatDetails)
|
||||
{
|
||||
this.formatDetails = formatDetails;
|
||||
waveFormat = WaveFormat.MarshalFromPtr(formatDetails.waveFormatPointer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format Index
|
||||
/// </summary>
|
||||
public int FormatIndex
|
||||
{
|
||||
get { return formatDetails.formatIndex; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format Tag
|
||||
/// </summary>
|
||||
public WaveFormatEncoding FormatTag
|
||||
{
|
||||
get { return (WaveFormatEncoding)formatDetails.formatTag; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Support Flags
|
||||
/// </summary>
|
||||
public AcmDriverDetailsSupportFlags SupportFlags
|
||||
{
|
||||
get { return formatDetails.supportFlags; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WaveFormat
|
||||
/// </summary>
|
||||
public WaveFormat WaveFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
return waveFormat;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WaveFormat Size
|
||||
/// </summary>
|
||||
public int WaveFormatByteSize
|
||||
{
|
||||
get { return formatDetails.waveFormatByteSize; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format Description
|
||||
/// </summary>
|
||||
public string FormatDescription
|
||||
{
|
||||
get { return formatDetails.formatDescription; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6edf4213f217bda48aa9b82a1dd88533
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// ACMFORMATCHOOSE
|
||||
/// http://msdn.microsoft.com/en-us/library/dd742911%28VS.85%29.aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Auto)]
|
||||
struct AcmFormatChoose
|
||||
{
|
||||
/// <summary>
|
||||
/// DWORD cbStruct;
|
||||
/// </summary>
|
||||
public int structureSize;
|
||||
/// <summary>
|
||||
/// DWORD fdwStyle;
|
||||
/// </summary>
|
||||
public AcmFormatChooseStyleFlags styleFlags;
|
||||
/// <summary>
|
||||
/// HWND hwndOwner;
|
||||
/// </summary>
|
||||
public IntPtr ownerWindowHandle;
|
||||
/// <summary>
|
||||
/// LPWAVEFORMATEX pwfx;
|
||||
/// </summary>
|
||||
public IntPtr selectedWaveFormatPointer;
|
||||
/// <summary>
|
||||
/// DWORD cbwfx;
|
||||
/// </summary>
|
||||
public int selectedWaveFormatByteSize;
|
||||
/// <summary>
|
||||
/// LPCTSTR pszTitle;
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string title;
|
||||
/// <summary>
|
||||
/// TCHAR szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=AcmFormatTagDetails.FormatTagDescriptionChars)]
|
||||
public string formatTagDescription;
|
||||
/// <summary>
|
||||
/// TCHAR szFormat[ACMFORMATDETAILS_FORMAT_CHARS];
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = AcmFormatDetails.FormatDescriptionChars)]
|
||||
public string formatDescription;
|
||||
/// <summary>
|
||||
/// LPTSTR pszName;
|
||||
/// n.b. can be written into
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string name;
|
||||
/// <summary>
|
||||
/// DWORD cchName
|
||||
/// Should be at least 128 unless name is zero
|
||||
/// </summary>
|
||||
public int nameByteSize;
|
||||
/// <summary>
|
||||
/// DWORD fdwEnum;
|
||||
/// </summary>
|
||||
public AcmFormatEnumFlags formatEnumFlags;
|
||||
/// <summary>
|
||||
/// LPWAVEFORMATEX pwfxEnum;
|
||||
/// </summary>
|
||||
public IntPtr waveFormatEnumPointer;
|
||||
/// <summary>
|
||||
/// HINSTANCE hInstance;
|
||||
/// </summary>
|
||||
public IntPtr instanceHandle;
|
||||
/// <summary>
|
||||
/// LPCTSTR pszTemplateName;
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string templateName;
|
||||
/// <summary>
|
||||
/// LPARAM lCustData;
|
||||
/// </summary>
|
||||
public IntPtr customData;
|
||||
/// <summary>
|
||||
/// ACMFORMATCHOOSEHOOKPROC pfnHook;
|
||||
/// </summary>
|
||||
public AcmInterop.AcmFormatChooseHookProc windowCallbackFunction;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23c74eb950aa6e247976f491044c5a8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
[Flags]
|
||||
enum AcmFormatChooseStyleFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// None
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// ACMFORMATCHOOSE_STYLEF_SHOWHELP
|
||||
/// </summary>
|
||||
ShowHelp = 0x00000004,
|
||||
/// <summary>
|
||||
/// ACMFORMATCHOOSE_STYLEF_ENABLEHOOK
|
||||
/// </summary>
|
||||
EnableHook = 0x00000008,
|
||||
/// <summary>
|
||||
/// ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATE
|
||||
/// </summary>
|
||||
EnableTemplate = 0x00000010,
|
||||
/// <summary>
|
||||
/// ACMFORMATCHOOSE_STYLEF_ENABLETEMPLATEHANDLE
|
||||
/// </summary>
|
||||
EnableTemplateHandle = 0x00000020,
|
||||
/// <summary>
|
||||
/// ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT
|
||||
/// </summary>
|
||||
InitToWfxStruct = 0x00000040,
|
||||
/// <summary>
|
||||
/// ACMFORMATCHOOSE_STYLEF_CONTEXTHELP
|
||||
/// </summary>
|
||||
ContextHelp = 0x00000080
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc98d85834af4ab4da4e527ebea92d4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// ACMFORMATDETAILS
|
||||
/// http://msdn.microsoft.com/en-us/library/dd742913%28VS.85%29.aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack=4)]
|
||||
struct AcmFormatDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// DWORD cbStruct;
|
||||
/// </summary>
|
||||
public int structSize;
|
||||
/// <summary>
|
||||
/// DWORD dwFormatIndex;
|
||||
/// </summary>
|
||||
public int formatIndex;
|
||||
/// <summary>
|
||||
/// DWORD dwFormatTag;
|
||||
/// </summary>
|
||||
public int formatTag;
|
||||
/// <summary>
|
||||
/// DWORD fdwSupport;
|
||||
/// </summary>
|
||||
public AcmDriverDetailsSupportFlags supportFlags;
|
||||
/// <summary>
|
||||
/// LPWAVEFORMATEX pwfx;
|
||||
/// </summary>
|
||||
public IntPtr waveFormatPointer;
|
||||
/// <summary>
|
||||
/// DWORD cbwfx;
|
||||
/// </summary>
|
||||
public int waveFormatByteSize;
|
||||
/// <summary>
|
||||
/// TCHAR szFormat[ACMFORMATDETAILS_FORMAT_CHARS];
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = FormatDescriptionChars)]
|
||||
public string formatDescription;
|
||||
|
||||
/// <summary>
|
||||
/// ACMFORMATDETAILS_FORMAT_CHARS
|
||||
/// </summary>
|
||||
public const int FormatDescriptionChars = 128;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6449e4d3b2456364daa2a0e0daf35dcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// Format Enumeration Flags
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum AcmFormatEnumFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// None
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// ACM_FORMATENUMF_CONVERT
|
||||
/// The WAVEFORMATEX structure pointed to by the pwfx member of the ACMFORMATDETAILS structure is valid. The enumerator will only enumerate destination formats that can be converted from the given pwfx format.
|
||||
/// </summary>
|
||||
Convert = 0x00100000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATENUMF_HARDWARE
|
||||
/// The enumerator should only enumerate formats that are supported as native input or output formats on one or more of the installed waveform-audio devices. This flag provides a way for an application to choose only formats native to an installed waveform-audio device. This flag must be used with one or both of the ACM_FORMATENUMF_INPUT and ACM_FORMATENUMF_OUTPUT flags. Specifying both ACM_FORMATENUMF_INPUT and ACM_FORMATENUMF_OUTPUT will enumerate only formats that can be opened for input or output. This is true regardless of whether this flag is specified.
|
||||
/// </summary>
|
||||
Hardware = 0x00400000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATENUMF_INPUT
|
||||
/// Enumerator should enumerate only formats that are supported for input (recording).
|
||||
/// </summary>
|
||||
Input = 0x00800000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATENUMF_NCHANNELS
|
||||
/// The nChannels member of the WAVEFORMATEX structure pointed to by the pwfx member of the ACMFORMATDETAILS structure is valid. The enumerator will enumerate only a format that conforms to this attribute.
|
||||
/// </summary>
|
||||
Channels = 0x00020000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATENUMF_NSAMPLESPERSEC
|
||||
/// The nSamplesPerSec member of the WAVEFORMATEX structure pointed to by the pwfx member of the ACMFORMATDETAILS structure is valid. The enumerator will enumerate only a format that conforms to this attribute.
|
||||
/// </summary>
|
||||
SamplesPerSecond = 0x00040000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATENUMF_OUTPUT
|
||||
/// Enumerator should enumerate only formats that are supported for output (playback).
|
||||
/// </summary>
|
||||
Output = 0x01000000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATENUMF_SUGGEST
|
||||
/// The WAVEFORMATEX structure pointed to by the pwfx member of the ACMFORMATDETAILS structure is valid. The enumerator will enumerate all suggested destination formats for the given pwfx format. This mechanism can be used instead of the acmFormatSuggest function to allow an application to choose the best suggested format for conversion. The dwFormatIndex member will always be set to zero on return.
|
||||
/// </summary>
|
||||
Suggest = 0x00200000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATENUMF_WBITSPERSAMPLE
|
||||
/// The wBitsPerSample member of the WAVEFORMATEX structure pointed to by the pwfx member of the ACMFORMATDETAILS structure is valid. The enumerator will enumerate only a format that conforms to this attribute.
|
||||
/// </summary>
|
||||
BitsPerSample = 0x00080000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATENUMF_WFORMATTAG
|
||||
/// The wFormatTag member of the WAVEFORMATEX structure pointed to by the pwfx member of the ACMFORMATDETAILS structure is valid. The enumerator will enumerate only a format that conforms to this attribute. The dwFormatTag member of the ACMFORMATDETAILS structure must be equal to the wFormatTag member.
|
||||
/// </summary>
|
||||
FormatTag = 0x00010000,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80c682d79298bf647ba622b043f289d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
[Flags]
|
||||
enum AcmFormatSuggestFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// ACM_FORMATSUGGESTF_WFORMATTAG
|
||||
/// </summary>
|
||||
FormatTag = 0x00010000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATSUGGESTF_NCHANNELS
|
||||
/// </summary>
|
||||
Channels = 0x00020000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATSUGGESTF_NSAMPLESPERSEC
|
||||
/// </summary>
|
||||
SamplesPerSecond = 0x00040000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATSUGGESTF_WBITSPERSAMPLE
|
||||
/// </summary>
|
||||
BitsPerSample = 0x00080000,
|
||||
/// <summary>
|
||||
/// ACM_FORMATSUGGESTF_TYPEMASK
|
||||
/// </summary>
|
||||
TypeMask = 0x00FF0000,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e44cacb0644994f4baef4d503af7f1be
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// ACM Format Tag
|
||||
/// </summary>
|
||||
public class AcmFormatTag
|
||||
{
|
||||
private AcmFormatTagDetails formatTagDetails;
|
||||
|
||||
internal AcmFormatTag(AcmFormatTagDetails formatTagDetails)
|
||||
{
|
||||
this.formatTagDetails = formatTagDetails;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format Tag Index
|
||||
/// </summary>
|
||||
public int FormatTagIndex
|
||||
{
|
||||
get { return formatTagDetails.formatTagIndex; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format Tag
|
||||
/// </summary>
|
||||
public WaveFormatEncoding FormatTag
|
||||
{
|
||||
get { return (WaveFormatEncoding)formatTagDetails.formatTag; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format Size
|
||||
/// </summary>
|
||||
public int FormatSize
|
||||
{
|
||||
get { return formatTagDetails.formatSize; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Support Flags
|
||||
/// </summary>
|
||||
public AcmDriverDetailsSupportFlags SupportFlags
|
||||
{
|
||||
get { return formatTagDetails.supportFlags; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Standard Formats Count
|
||||
/// </summary>
|
||||
public int StandardFormatsCount
|
||||
{
|
||||
get { return formatTagDetails.standardFormatsCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format Description
|
||||
/// </summary>
|
||||
public string FormatDescription
|
||||
{
|
||||
get { return formatTagDetails.formatDescription; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07f376bd8de561c49895bf1ce94e892e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
struct AcmFormatTagDetails
|
||||
{
|
||||
/// <summary>
|
||||
/// DWORD cbStruct;
|
||||
/// </summary>
|
||||
public int structureSize;
|
||||
/// <summary>
|
||||
/// DWORD dwFormatTagIndex;
|
||||
/// </summary>
|
||||
public int formatTagIndex;
|
||||
/// <summary>
|
||||
/// DWORD dwFormatTag;
|
||||
/// </summary>
|
||||
public int formatTag;
|
||||
/// <summary>
|
||||
/// DWORD cbFormatSize;
|
||||
/// </summary>
|
||||
public int formatSize;
|
||||
/// <summary>
|
||||
/// DWORD fdwSupport;
|
||||
/// </summary>
|
||||
public AcmDriverDetailsSupportFlags supportFlags;
|
||||
/// <summary>
|
||||
/// DWORD cStandardFormats;
|
||||
/// </summary>
|
||||
public int standardFormatsCount;
|
||||
/// <summary>
|
||||
/// TCHAR szFormatTag[ACMFORMATTAGDETAILS_FORMATTAG_CHARS];
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = FormatTagDescriptionChars)]
|
||||
public string formatDescription;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ACMFORMATTAGDETAILS_FORMATTAG_CHARS
|
||||
/// </summary>
|
||||
public const int FormatTagDescriptionChars = 48;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ba63b2b0e600fc46881d7fba9769013
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// Interop definitions for Windows ACM (Audio Compression Manager) API
|
||||
/// </summary>
|
||||
class AcmInterop
|
||||
{
|
||||
// http://msdn.microsoft.com/en-us/library/dd742891%28VS.85%29.aspx
|
||||
public delegate bool AcmDriverEnumCallback(IntPtr hAcmDriverId, IntPtr instance, AcmDriverDetailsSupportFlags flags);
|
||||
|
||||
public delegate bool AcmFormatEnumCallback(IntPtr hAcmDriverId, ref AcmFormatDetails formatDetails, IntPtr dwInstance, AcmDriverDetailsSupportFlags flags);
|
||||
|
||||
public delegate bool AcmFormatTagEnumCallback(IntPtr hAcmDriverId, ref AcmFormatTagDetails formatTagDetails, IntPtr dwInstance, AcmDriverDetailsSupportFlags flags);
|
||||
|
||||
/// <summary>
|
||||
/// http://msdn.microsoft.com/en-us/library/dd742910%28VS.85%29.aspx
|
||||
/// UINT ACMFORMATCHOOSEHOOKPROC acmFormatChooseHookProc(
|
||||
/// HWND hwnd,
|
||||
/// UINT uMsg,
|
||||
/// WPARAM wParam,
|
||||
/// LPARAM lParam
|
||||
/// </summary>
|
||||
public delegate bool AcmFormatChooseHookProc(IntPtr windowHandle, int message, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
// not done:
|
||||
// acmDriverAdd
|
||||
// acmDriverID
|
||||
// acmDriverMessage
|
||||
// acmDriverRemove
|
||||
// acmFilterChoose
|
||||
// acmFilterChooseHookProc
|
||||
// acmFilterDetails
|
||||
// acmFilterEnum -acmFilterEnumCallback
|
||||
// acmFilterTagDetails
|
||||
// acmFilterTagEnum
|
||||
// acmFormatDetails
|
||||
// acmFormatTagDetails
|
||||
// acmGetVersion
|
||||
// acmStreamMessage
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd742885%28v=vs.85%29.aspx
|
||||
// MMRESULT acmDriverAdd(
|
||||
// LPHACMDRIVERID phadid,
|
||||
// HINSTANCE hinstModule,
|
||||
// LPARAM lParam,
|
||||
// DWORD dwPriority,
|
||||
// DWORD fdwAdd)
|
||||
[DllImport("msacm32.dll")]
|
||||
public static extern MmResult acmDriverAdd(out IntPtr driverHandle,
|
||||
IntPtr driverModule,
|
||||
IntPtr driverFunctionAddress,
|
||||
int priority,
|
||||
AcmDriverAddFlags flags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd742897%28v=vs.85%29.aspx
|
||||
[DllImport("msacm32.dll")]
|
||||
public static extern MmResult acmDriverRemove(IntPtr driverHandle,
|
||||
int removeFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742886%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmDriverClose(IntPtr hAcmDriver, int closeFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742890%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmDriverEnum(AcmDriverEnumCallback fnCallback, IntPtr dwInstance, AcmDriverEnumFlags flags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742887%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmDriverDetails(IntPtr hAcmDriver, ref AcmDriverDetails driverDetails, int reserved);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742894%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmDriverOpen(out IntPtr pAcmDriver, IntPtr hAcmDriverId, int openFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742909%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll", EntryPoint = "acmFormatChooseW")]
|
||||
public static extern MmResult acmFormatChoose(ref AcmFormatChoose formatChoose);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742914%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmFormatEnum(IntPtr hAcmDriver, ref AcmFormatDetails formatDetails, AcmFormatEnumCallback callback, IntPtr instance, AcmFormatEnumFlags flags);
|
||||
|
||||
/// <summary>
|
||||
/// http://msdn.microsoft.com/en-us/library/dd742916%28VS.85%29.aspx
|
||||
/// MMRESULT acmFormatSuggest(
|
||||
/// HACMDRIVER had,
|
||||
/// LPWAVEFORMATEX pwfxSrc,
|
||||
/// LPWAVEFORMATEX pwfxDst,
|
||||
/// DWORD cbwfxDst,
|
||||
/// DWORD fdwSuggest);
|
||||
/// </summary>
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmFormatSuggest(
|
||||
IntPtr hAcmDriver,
|
||||
[In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "NAudio.Wave.WaveFormatCustomMarshaler")]
|
||||
WaveFormat sourceFormat,
|
||||
[In, Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "NAudio.Wave.WaveFormatCustomMarshaler")]
|
||||
WaveFormat destFormat,
|
||||
int sizeDestFormat,
|
||||
AcmFormatSuggestFlags suggestFlags);
|
||||
|
||||
[DllImport("Msacm32.dll",EntryPoint="acmFormatSuggest")]
|
||||
public static extern MmResult acmFormatSuggest2(
|
||||
IntPtr hAcmDriver,
|
||||
IntPtr sourceFormatPointer,
|
||||
IntPtr destFormatPointer,
|
||||
int sizeDestFormat,
|
||||
AcmFormatSuggestFlags suggestFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742919%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmFormatTagEnum(IntPtr hAcmDriver, ref AcmFormatTagDetails formatTagDetails, AcmFormatTagEnumCallback callback, IntPtr instance, int reserved);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742922%28VS.85%29.aspx
|
||||
// this version of the prototype is for metrics that output a single integer
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmMetrics(IntPtr hAcmObject, AcmMetrics metric, out int output);
|
||||
|
||||
/// <summary>
|
||||
/// http://msdn.microsoft.com/en-us/library/dd742928%28VS.85%29.aspx
|
||||
/// MMRESULT acmStreamOpen(
|
||||
/// LPHACMSTREAM phas,
|
||||
/// HACMDRIVER had,
|
||||
/// LPWAVEFORMATEX pwfxSrc,
|
||||
/// LPWAVEFORMATEX pwfxDst,
|
||||
/// LPWAVEFILTER pwfltr,
|
||||
/// DWORD_PTR dwCallback,
|
||||
/// DWORD_PTR dwInstance,
|
||||
/// DWORD fdwOpen
|
||||
/// </summary>
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmStreamOpen(
|
||||
out IntPtr hAcmStream,
|
||||
IntPtr hAcmDriver,
|
||||
[In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "NAudio.Wave.WaveFormatCustomMarshaler")]
|
||||
WaveFormat sourceFormat,
|
||||
[In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "NAudio.Wave.WaveFormatCustomMarshaler")]
|
||||
WaveFormat destFormat,
|
||||
[In] WaveFilter waveFilter,
|
||||
IntPtr callback,
|
||||
IntPtr instance,
|
||||
AcmStreamOpenFlags openFlags);
|
||||
|
||||
/// <summary>
|
||||
/// A version with pointers for troubleshooting
|
||||
/// </summary>
|
||||
[DllImport("Msacm32.dll",EntryPoint="acmStreamOpen")]
|
||||
public static extern MmResult acmStreamOpen2(
|
||||
out IntPtr hAcmStream,
|
||||
IntPtr hAcmDriver,
|
||||
IntPtr sourceFormatPointer,
|
||||
IntPtr destFormatPointer,
|
||||
[In] WaveFilter waveFilter,
|
||||
IntPtr callback,
|
||||
IntPtr instance,
|
||||
AcmStreamOpenFlags openFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742923%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmStreamClose(IntPtr hAcmStream, int closeFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742924%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmStreamConvert(IntPtr hAcmStream, [In, Out] AcmStreamHeaderStruct streamHeader, AcmStreamConvertFlags streamConvertFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742929%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmStreamPrepareHeader(IntPtr hAcmStream, [In, Out] AcmStreamHeaderStruct streamHeader, int prepareFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742929%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmStreamReset(IntPtr hAcmStream, int resetFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742931%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmStreamSize(IntPtr hAcmStream, int inputBufferSize, out int outputBufferSize, AcmStreamSizeFlags flags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd742932%28VS.85%29.aspx
|
||||
[DllImport("Msacm32.dll")]
|
||||
public static extern MmResult acmStreamUnprepareHeader(IntPtr hAcmStream, [In, Out] AcmStreamHeaderStruct streamHeader, int flags);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 408266e0fb9a4b84baa3c9e17c1f7dba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
enum AcmMetrics
|
||||
{
|
||||
/// <summary>ACM_METRIC_COUNT_DRIVERS</summary>
|
||||
CountDrivers = 1,
|
||||
/// <summary>ACM_METRIC_COUNT_CODECS</summary>
|
||||
CountCodecs = 2,
|
||||
/// <summary>ACM_METRIC_COUNT_CONVERTERS</summary>
|
||||
CountConverters = 3,
|
||||
/// <summary>ACM_METRIC_COUNT_FILTERS</summary>
|
||||
CountFilters = 4,
|
||||
/// <summary>ACM_METRIC_COUNT_DISABLED</summary>
|
||||
CountDisabled = 5,
|
||||
/// <summary>ACM_METRIC_COUNT_HARDWARE</summary>
|
||||
CountHardware = 6,
|
||||
/// <summary>ACM_METRIC_COUNT_LOCAL_DRIVERS</summary>
|
||||
CountLocalDrivers = 20,
|
||||
/// <summary>ACM_METRIC_COUNT_LOCAL_CODECS</summary>
|
||||
CountLocalCodecs = 21,
|
||||
/// <summary>ACM_METRIC_COUNT_LOCAL_CONVERTERS</summary>
|
||||
CountLocalConverters = 22,
|
||||
/// <summary>ACM_METRIC_COUNT_LOCAL_FILTERS</summary>
|
||||
CountLocalFilters = 23,
|
||||
/// <summary>ACM_METRIC_COUNT_LOCAL_DISABLED</summary>
|
||||
CountLocalDisabled = 24,
|
||||
/// <summary>ACM_METRIC_HARDWARE_WAVE_INPUT</summary>
|
||||
HardwareWaveInput = 30,
|
||||
/// <summary>ACM_METRIC_HARDWARE_WAVE_OUTPUT</summary>
|
||||
HardwareWaveOutput = 31,
|
||||
/// <summary>ACM_METRIC_MAX_SIZE_FORMAT</summary>
|
||||
MaxSizeFormat = 50,
|
||||
/// <summary>ACM_METRIC_MAX_SIZE_FILTER</summary>
|
||||
MaxSizeFilter = 51,
|
||||
/// <summary>ACM_METRIC_DRIVER_SUPPORT</summary>
|
||||
DriverSupport = 100,
|
||||
/// <summary>ACM_METRIC_DRIVER_PRIORITY</summary>
|
||||
DriverPriority = 101,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b76c14e4996a674c8a10b83a3de4e56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,237 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// AcmStream encapsulates an Audio Compression Manager Stream
|
||||
/// used to convert audio from one format to another
|
||||
/// </summary>
|
||||
public class AcmStream : IDisposable
|
||||
{
|
||||
private IntPtr streamHandle;
|
||||
private IntPtr driverHandle;
|
||||
private AcmStreamHeader streamHeader;
|
||||
private readonly WaveFormat sourceFormat;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new ACM stream to convert one format to another. Note that
|
||||
/// not all conversions can be done in one step
|
||||
/// </summary>
|
||||
/// <param name="sourceFormat">The source audio format</param>
|
||||
/// <param name="destFormat">The destination audio format</param>
|
||||
public AcmStream(WaveFormat sourceFormat, WaveFormat destFormat)
|
||||
{
|
||||
try
|
||||
{
|
||||
streamHandle = IntPtr.Zero;
|
||||
this.sourceFormat = sourceFormat;
|
||||
int sourceBufferSize = Math.Max(65536, sourceFormat.AverageBytesPerSecond);
|
||||
sourceBufferSize -= (sourceBufferSize % sourceFormat.BlockAlign);
|
||||
MmException.Try(AcmInterop.acmStreamOpen(out streamHandle, IntPtr.Zero, sourceFormat, destFormat, null, IntPtr.Zero, IntPtr.Zero, AcmStreamOpenFlags.NonRealTime), "acmStreamOpen");
|
||||
|
||||
int destBufferSize = SourceToDest(sourceBufferSize);
|
||||
streamHeader = new AcmStreamHeader(streamHandle, sourceBufferSize, destBufferSize);
|
||||
driverHandle = IntPtr.Zero;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// suppress the finalise and clean up resources
|
||||
Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new ACM stream to convert one format to another, using a
|
||||
/// specified driver identified and wave filter
|
||||
/// </summary>
|
||||
/// <param name="driverId">the driver identifier</param>
|
||||
/// <param name="sourceFormat">the source format</param>
|
||||
/// <param name="waveFilter">the wave filter</param>
|
||||
public AcmStream(IntPtr driverId, WaveFormat sourceFormat, WaveFilter waveFilter)
|
||||
{
|
||||
int sourceBufferSize = Math.Max(16384, sourceFormat.AverageBytesPerSecond);
|
||||
this.sourceFormat = sourceFormat;
|
||||
sourceBufferSize -= (sourceBufferSize % sourceFormat.BlockAlign);
|
||||
MmException.Try(AcmInterop.acmDriverOpen(out driverHandle, driverId, 0), "acmDriverOpen");
|
||||
MmException.Try(AcmInterop.acmStreamOpen(out streamHandle, driverHandle,
|
||||
sourceFormat, sourceFormat, waveFilter, IntPtr.Zero, IntPtr.Zero, AcmStreamOpenFlags.NonRealTime), "acmStreamOpen");
|
||||
streamHeader = new AcmStreamHeader(streamHandle, sourceBufferSize, SourceToDest(sourceBufferSize));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of output bytes for a given number of input bytes
|
||||
/// </summary>
|
||||
/// <param name="source">Number of input bytes</param>
|
||||
/// <returns>Number of output bytes</returns>
|
||||
public int SourceToDest(int source)
|
||||
{
|
||||
if (source == 0) // zero is an invalid parameter to acmStreamSize
|
||||
return 0;
|
||||
int convertedBytes;
|
||||
var mmResult = AcmInterop.acmStreamSize(streamHandle, source, out convertedBytes, AcmStreamSizeFlags.Source);
|
||||
MmException.Try(mmResult, "acmStreamSize");
|
||||
return convertedBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of source bytes for a given number of destination bytes
|
||||
/// </summary>
|
||||
/// <param name="dest">Number of destination bytes</param>
|
||||
/// <returns>Number of source bytes</returns>
|
||||
public int DestToSource(int dest)
|
||||
{
|
||||
if (dest == 0) // zero is an invalid parameter to acmStreamSize
|
||||
return 0;
|
||||
int convertedBytes;
|
||||
MmException.Try(AcmInterop.acmStreamSize(streamHandle, dest, out convertedBytes, AcmStreamSizeFlags.Destination), "acmStreamSize");
|
||||
return convertedBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Suggests an appropriate PCM format that the compressed format can be converted
|
||||
/// to in one step
|
||||
/// </summary>
|
||||
/// <param name="compressedFormat">The compressed format</param>
|
||||
/// <returns>The PCM format</returns>
|
||||
public static WaveFormat SuggestPcmFormat(WaveFormat compressedFormat)
|
||||
{
|
||||
// create a PCM format
|
||||
WaveFormat suggestedFormat = new WaveFormat(compressedFormat.SampleRate, 16, compressedFormat.Channels);
|
||||
MmException.Try(AcmInterop.acmFormatSuggest(IntPtr.Zero, compressedFormat, suggestedFormat, Marshal.SizeOf(suggestedFormat), AcmFormatSuggestFlags.FormatTag), "acmFormatSuggest");
|
||||
|
||||
/*IntPtr suggestedFormatPointer = WaveFormat.MarshalToPtr(suggestedFormat);
|
||||
IntPtr compressedFormatPointer = WaveFormat.MarshalToPtr(compressedFormat);
|
||||
MmResult result = AcmInterop.acmFormatSuggest2(IntPtr.Zero, compressedFormatPointer, suggestedFormatPointer, Marshal.SizeOf(suggestedFormat), AcmFormatSuggestFlags.FormatTag);
|
||||
suggestedFormat = WaveFormat.MarshalFromPtr(suggestedFormatPointer);
|
||||
Marshal.FreeHGlobal(suggestedFormatPointer);
|
||||
Marshal.FreeHGlobal(compressedFormatPointer);
|
||||
MmException.Try(result, "acmFormatSuggest");*/
|
||||
|
||||
|
||||
return suggestedFormat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Source Buffer. Fill this with data prior to calling convert
|
||||
/// </summary>
|
||||
public byte[] SourceBuffer => streamHeader.SourceBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Destination buffer. This will contain the converted data
|
||||
/// after a successful call to Convert
|
||||
/// </summary>
|
||||
public byte[] DestBuffer => streamHeader.DestBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// Report that we have repositioned in the source stream
|
||||
/// </summary>
|
||||
public void Reposition()
|
||||
{
|
||||
streamHeader.Reposition();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the contents of the SourceBuffer into the DestinationBuffer
|
||||
/// </summary>
|
||||
/// <param name="bytesToConvert">The number of bytes in the SourceBuffer
|
||||
/// that need to be converted</param>
|
||||
/// <param name="sourceBytesConverted">The number of source bytes actually converted</param>
|
||||
/// <returns>The number of converted bytes in the DestinationBuffer</returns>
|
||||
public int Convert(int bytesToConvert, out int sourceBytesConverted)
|
||||
{
|
||||
if (bytesToConvert % sourceFormat.BlockAlign != 0)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(String.Format("Not a whole number of blocks: {0} ({1})", bytesToConvert, sourceFormat.BlockAlign));
|
||||
bytesToConvert -= (bytesToConvert % sourceFormat.BlockAlign);
|
||||
}
|
||||
|
||||
return streamHeader.Convert(bytesToConvert, out sourceBytesConverted);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the contents of the SourceBuffer into the DestinationBuffer
|
||||
/// </summary>
|
||||
/// <param name="bytesToConvert">The number of bytes in the SourceBuffer
|
||||
/// that need to be converted</param>
|
||||
/// <returns>The number of converted bytes in the DestinationBuffer</returns>
|
||||
[Obsolete("Call the version returning sourceBytesConverted instead")]
|
||||
public int Convert(int bytesToConvert)
|
||||
{
|
||||
int sourceBytesConverted;
|
||||
int destBytes = Convert(bytesToConvert, out sourceBytesConverted);
|
||||
if (sourceBytesConverted != bytesToConvert)
|
||||
{
|
||||
throw new MmException(MmResult.NotSupported, "AcmStreamHeader.Convert didn't convert everything");
|
||||
}
|
||||
return destBytes;
|
||||
}
|
||||
|
||||
/* Relevant only for async conversion streams
|
||||
public void Reset()
|
||||
{
|
||||
MmException.Try(AcmInterop.acmStreamReset(streamHandle,0),"acmStreamReset");
|
||||
}
|
||||
*/
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
/// <summary>
|
||||
/// Frees resources associated with this ACM Stream
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Frees resources associated with this ACM Stream
|
||||
/// </summary>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// Free other state (managed objects).
|
||||
if (streamHeader != null)
|
||||
{
|
||||
streamHeader.Dispose();
|
||||
streamHeader = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Free your own state (unmanaged objects).
|
||||
|
||||
if (streamHandle != IntPtr.Zero)
|
||||
{
|
||||
MmResult result = AcmInterop.acmStreamClose(streamHandle, 0);
|
||||
streamHandle = IntPtr.Zero;
|
||||
if (result != MmResult.NoError)
|
||||
{
|
||||
throw new MmException(result, "acmStreamClose");
|
||||
}
|
||||
|
||||
}
|
||||
// Set large fields to null.
|
||||
if (driverHandle != IntPtr.Zero)
|
||||
{
|
||||
AcmInterop.acmDriverClose(driverHandle, 0);
|
||||
driverHandle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Frees resources associated with this ACM Stream
|
||||
/// </summary>
|
||||
~AcmStream()
|
||||
{
|
||||
// Simply call Dispose(false).
|
||||
System.Diagnostics.Debug.Assert(false, "AcmStream Dispose was not called");
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e48bb2590ede1e04d9d7023b61ea25f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
[Flags]
|
||||
enum AcmStreamConvertFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// ACM_STREAMCONVERTF_BLOCKALIGN
|
||||
/// </summary>
|
||||
BlockAlign = 0x00000004,
|
||||
/// <summary>
|
||||
/// ACM_STREAMCONVERTF_START
|
||||
/// </summary>
|
||||
Start = 0x00000010,
|
||||
/// <summary>
|
||||
/// ACM_STREAMCONVERTF_END
|
||||
/// </summary>
|
||||
End = 0x00000020,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d2ff230262920e4c8f868501971a4e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
class AcmStreamHeader : IDisposable
|
||||
{
|
||||
private AcmStreamHeaderStruct streamHeader;
|
||||
private byte[] sourceBuffer;
|
||||
private GCHandle hSourceBuffer;
|
||||
private byte[] destBuffer;
|
||||
private GCHandle hDestBuffer;
|
||||
private IntPtr streamHandle;
|
||||
private bool firstTime;
|
||||
|
||||
public AcmStreamHeader(IntPtr streamHandle, int sourceBufferLength, int destBufferLength)
|
||||
{
|
||||
streamHeader = new AcmStreamHeaderStruct();
|
||||
sourceBuffer = new byte[sourceBufferLength];
|
||||
hSourceBuffer = GCHandle.Alloc(sourceBuffer, GCHandleType.Pinned);
|
||||
|
||||
destBuffer = new byte[destBufferLength];
|
||||
hDestBuffer = GCHandle.Alloc(destBuffer, GCHandleType.Pinned);
|
||||
|
||||
this.streamHandle = streamHandle;
|
||||
firstTime = true;
|
||||
//Prepare();
|
||||
}
|
||||
|
||||
private void Prepare()
|
||||
{
|
||||
streamHeader.cbStruct = Marshal.SizeOf(streamHeader);
|
||||
streamHeader.sourceBufferLength = sourceBuffer.Length;
|
||||
streamHeader.sourceBufferPointer = hSourceBuffer.AddrOfPinnedObject();
|
||||
streamHeader.destBufferLength = destBuffer.Length;
|
||||
streamHeader.destBufferPointer = hDestBuffer.AddrOfPinnedObject();
|
||||
MmException.Try(AcmInterop.acmStreamPrepareHeader(streamHandle, streamHeader, 0), "acmStreamPrepareHeader");
|
||||
}
|
||||
|
||||
private void Unprepare()
|
||||
{
|
||||
streamHeader.sourceBufferLength = sourceBuffer.Length;
|
||||
streamHeader.sourceBufferPointer = hSourceBuffer.AddrOfPinnedObject();
|
||||
streamHeader.destBufferLength = destBuffer.Length;
|
||||
streamHeader.destBufferPointer = hDestBuffer.AddrOfPinnedObject();
|
||||
|
||||
MmResult result = AcmInterop.acmStreamUnprepareHeader(streamHandle, streamHeader, 0);
|
||||
if (result != MmResult.NoError)
|
||||
{
|
||||
//if (result == MmResult.AcmHeaderUnprepared)
|
||||
throw new MmException(result, "acmStreamUnprepareHeader");
|
||||
}
|
||||
}
|
||||
|
||||
public void Reposition()
|
||||
{
|
||||
firstTime = true;
|
||||
}
|
||||
|
||||
public int Convert(int bytesToConvert, out int sourceBytesConverted)
|
||||
{
|
||||
Prepare();
|
||||
try
|
||||
{
|
||||
streamHeader.sourceBufferLength = bytesToConvert;
|
||||
streamHeader.sourceBufferLengthUsed = bytesToConvert;
|
||||
AcmStreamConvertFlags flags = firstTime ? (AcmStreamConvertFlags.Start | AcmStreamConvertFlags.BlockAlign) : AcmStreamConvertFlags.BlockAlign;
|
||||
MmException.Try(AcmInterop.acmStreamConvert(streamHandle, streamHeader, flags), "acmStreamConvert");
|
||||
firstTime = false;
|
||||
System.Diagnostics.Debug.Assert(streamHeader.destBufferLength == destBuffer.Length, "Codecs should not change dest buffer length");
|
||||
sourceBytesConverted = streamHeader.sourceBufferLengthUsed;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Unprepare();
|
||||
}
|
||||
|
||||
return streamHeader.destBufferLengthUsed;
|
||||
}
|
||||
|
||||
public byte[] SourceBuffer
|
||||
{
|
||||
get
|
||||
{
|
||||
return sourceBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] DestBuffer
|
||||
{
|
||||
get
|
||||
{
|
||||
return destBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
bool disposed = false;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposed)
|
||||
{
|
||||
//Unprepare();
|
||||
sourceBuffer = null;
|
||||
destBuffer = null;
|
||||
hSourceBuffer.Free();
|
||||
hDestBuffer.Free();
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
~AcmStreamHeader()
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(false, "AcmStreamHeader dispose was not called");
|
||||
Dispose(false);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 261fe8295a476084fb3bfd509210ebbf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
[Flags]
|
||||
enum AcmStreamHeaderStatusFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// ACMSTREAMHEADER_STATUSF_DONE
|
||||
/// </summary>
|
||||
Done = 0x00010000,
|
||||
/// <summary>
|
||||
/// ACMSTREAMHEADER_STATUSF_PREPARED
|
||||
/// </summary>
|
||||
Prepared = 0x00020000,
|
||||
/// <summary>
|
||||
/// ACMSTREAMHEADER_STATUSF_INQUEUE
|
||||
/// </summary>
|
||||
InQueue = 0x00100000,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41679d6153312f34e8a904a3b0689923
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// Interop structure for ACM stream headers.
|
||||
/// ACMSTREAMHEADER
|
||||
/// http://msdn.microsoft.com/en-us/library/dd742926%28VS.85%29.aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Size = 128)] // explicit size to make it work for x64
|
||||
class AcmStreamHeaderStruct
|
||||
{
|
||||
public int cbStruct;
|
||||
public AcmStreamHeaderStatusFlags fdwStatus = 0;
|
||||
public IntPtr userData;
|
||||
public IntPtr sourceBufferPointer;
|
||||
public int sourceBufferLength;
|
||||
public int sourceBufferLengthUsed;
|
||||
public IntPtr sourceUserData;
|
||||
public IntPtr destBufferPointer;
|
||||
public int destBufferLength;
|
||||
public int destBufferLengthUsed = 0;
|
||||
public IntPtr destUserData;
|
||||
|
||||
// 10 reserved values follow this, we don't need to declare them
|
||||
// since we have set the struct size explicitly and don't
|
||||
// need to access them in client code (thanks Brian)
|
||||
/*public int reserved0;
|
||||
public int reserved1;
|
||||
public int reserved2;
|
||||
public int reserved3;
|
||||
public int reserved4;
|
||||
public int reserved5;
|
||||
public int reserved6;
|
||||
public int reserved7;
|
||||
public int reserved8;
|
||||
public int reserved9;*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91549b63de92ae04c90fd6e2370107c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
[Flags]
|
||||
enum AcmStreamOpenFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// ACM_STREAMOPENF_QUERY, ACM will be queried to determine whether it supports the given conversion. A conversion stream will not be opened, and no handle will be returned in the phas parameter.
|
||||
/// </summary>
|
||||
Query = 0x00000001,
|
||||
/// <summary>
|
||||
/// ACM_STREAMOPENF_ASYNC, Stream conversion should be performed asynchronously. If this flag is specified, the application can use a callback function to be notified when the conversion stream is opened and closed and after each buffer is converted. In addition to using a callback function, an application can examine the fdwStatus member of the ACMSTREAMHEADER structure for the ACMSTREAMHEADER_STATUSF_DONE flag.
|
||||
/// </summary>
|
||||
Async = 0x00000002,
|
||||
/// <summary>
|
||||
/// ACM_STREAMOPENF_NONREALTIME, ACM will not consider time constraints when converting the data. By default, the driver will attempt to convert the data in real time. For some formats, specifying this flag might improve the audio quality or other characteristics.
|
||||
/// </summary>
|
||||
NonRealTime = 0x00000004,
|
||||
/// <summary>
|
||||
/// CALLBACK_TYPEMASK, callback type mask
|
||||
/// </summary>
|
||||
CallbackTypeMask = 0x00070000,
|
||||
/// <summary>
|
||||
/// CALLBACK_NULL, no callback
|
||||
/// </summary>
|
||||
CallbackNull = 0x00000000,
|
||||
/// <summary>
|
||||
/// CALLBACK_WINDOW, dwCallback is a HWND
|
||||
/// </summary>
|
||||
CallbackWindow = 0x00010000,
|
||||
/// <summary>
|
||||
/// CALLBACK_TASK, dwCallback is a HTASK
|
||||
/// </summary>
|
||||
CallbackTask = 0x00020000,
|
||||
/// <summary>
|
||||
/// CALLBACK_FUNCTION, dwCallback is a FARPROC
|
||||
/// </summary>
|
||||
CallbackFunction = 0x00030000,
|
||||
/// <summary>
|
||||
/// CALLBACK_THREAD, thread ID replaces 16 bit task
|
||||
/// </summary>
|
||||
CallbackThread = CallbackTask,
|
||||
/// <summary>
|
||||
/// CALLBACK_EVENT, dwCallback is an EVENT Handle
|
||||
/// </summary>
|
||||
CallbackEvent = 0x00050000,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 473e4de9c2c745d48a960b22ee77555e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
enum AcmStreamSizeFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// ACM_STREAMSIZEF_SOURCE
|
||||
/// </summary>
|
||||
Source = 0x00000000,
|
||||
/// <summary>
|
||||
/// ACM_STREAMSIZEF_DESTINATION
|
||||
/// </summary>
|
||||
Destination = 0x00000001
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a09865d63cc568b4495b39f7d56795f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave.Compression
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for WaveFilter.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
|
||||
public class WaveFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// cbStruct
|
||||
/// </summary>
|
||||
public int StructureSize = Marshal.SizeOf(typeof(WaveFilter));
|
||||
/// <summary>
|
||||
/// dwFilterTag
|
||||
/// </summary>
|
||||
public int FilterTag = 0;
|
||||
/// <summary>
|
||||
/// fdwFilter
|
||||
/// </summary>
|
||||
public int Filter = 0;
|
||||
/// <summary>
|
||||
/// reserved
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst=5)]
|
||||
public int []Reserved = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 579eb20739ebc904b8a9fd283aa00833
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b623dcb2358bca343b3dd8a3cc8b95ec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,376 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio
|
||||
{
|
||||
/// <summary>
|
||||
/// Manufacturer codes from mmreg.h
|
||||
/// </summary>
|
||||
public enum Manufacturers
|
||||
{
|
||||
/// <summary>Microsoft Corporation</summary>
|
||||
Microsoft = 1,
|
||||
/// <summary>Creative Labs, Inc</summary>
|
||||
Creative = 2,
|
||||
/// <summary>Media Vision, Inc.</summary>
|
||||
Mediavision = 3,
|
||||
/// <summary>Fujitsu Corp.</summary>
|
||||
Fujitsu = 4,
|
||||
/// <summary>Artisoft, Inc.</summary>
|
||||
Artisoft = 20,
|
||||
/// <summary>Turtle Beach, Inc.</summary>
|
||||
TurtleBeach = 21,
|
||||
/// <summary>IBM Corporation</summary>
|
||||
Ibm = 22,
|
||||
/// <summary>Vocaltec LTD.</summary>
|
||||
Vocaltec = 23,
|
||||
/// <summary>Roland</summary>
|
||||
Roland = 24,
|
||||
/// <summary>DSP Solutions, Inc.</summary>
|
||||
DspSolutions = 25,
|
||||
/// <summary>NEC</summary>
|
||||
Nec = 26,
|
||||
/// <summary>ATI</summary>
|
||||
Ati = 27,
|
||||
/// <summary>Wang Laboratories, Inc</summary>
|
||||
Wanglabs = 28,
|
||||
/// <summary>Tandy Corporation</summary>
|
||||
Tandy = 29,
|
||||
/// <summary>Voyetra</summary>
|
||||
Voyetra = 30,
|
||||
/// <summary>Antex Electronics Corporation</summary>
|
||||
Antex = 31,
|
||||
/// <summary>ICL Personal Systems</summary>
|
||||
IclPS = 32,
|
||||
/// <summary>Intel Corporation</summary>
|
||||
Intel = 33,
|
||||
/// <summary>Advanced Gravis</summary>
|
||||
Gravis = 34,
|
||||
/// <summary>Video Associates Labs, Inc.</summary>
|
||||
Val = 35,
|
||||
/// <summary>InterActive Inc</summary>
|
||||
Interactive = 36,
|
||||
/// <summary>Yamaha Corporation of America</summary>
|
||||
Yamaha = 37,
|
||||
/// <summary>Everex Systems, Inc</summary>
|
||||
Everex = 38,
|
||||
/// <summary>Echo Speech Corporation</summary>
|
||||
Echo = 39,
|
||||
/// <summary>Sierra Semiconductor Corp</summary>
|
||||
Sierra = 40,
|
||||
/// <summary>Computer Aided Technologies</summary>
|
||||
Cat = 41,
|
||||
/// <summary>APPS Software International</summary>
|
||||
Apps = 42,
|
||||
/// <summary>DSP Group, Inc</summary>
|
||||
DspGroup = 43,
|
||||
/// <summary>microEngineering Labs</summary>
|
||||
Melabs = 44,
|
||||
/// <summary>Computer Friends, Inc.</summary>
|
||||
ComputerFriends = 45,
|
||||
/// <summary>ESS Technology</summary>
|
||||
Ess = 46,
|
||||
/// <summary>Audio, Inc.</summary>
|
||||
Audiofile = 47,
|
||||
/// <summary>Motorola, Inc.</summary>
|
||||
Motorola = 48,
|
||||
/// <summary>Canopus, co., Ltd.</summary>
|
||||
Canopus = 49,
|
||||
/// <summary>Seiko Epson Corporation</summary>
|
||||
Epson = 50,
|
||||
/// <summary>Truevision</summary>
|
||||
Truevision = 51,
|
||||
/// <summary>Aztech Labs, Inc.</summary>
|
||||
Aztech = 52,
|
||||
/// <summary>Videologic</summary>
|
||||
Videologic = 53,
|
||||
/// <summary>SCALACS</summary>
|
||||
Scalacs = 54,
|
||||
/// <summary>Korg Inc.</summary>
|
||||
Korg = 55,
|
||||
/// <summary>Audio Processing Technology</summary>
|
||||
Apt = 56,
|
||||
/// <summary>Integrated Circuit Systems, Inc.</summary>
|
||||
Ics = 57,
|
||||
/// <summary>Iterated Systems, Inc.</summary>
|
||||
Iteratedsys = 58,
|
||||
/// <summary>Metheus</summary>
|
||||
Metheus = 59,
|
||||
/// <summary>Logitech, Inc.</summary>
|
||||
Logitech = 60,
|
||||
/// <summary>Winnov, Inc.</summary>
|
||||
Winnov = 61,
|
||||
/// <summary>NCR Corporation</summary>
|
||||
Ncr = 62,
|
||||
/// <summary>EXAN</summary>
|
||||
Exan = 63,
|
||||
/// <summary>AST Research Inc.</summary>
|
||||
Ast = 64,
|
||||
/// <summary>Willow Pond Corporation</summary>
|
||||
Willowpond = 65,
|
||||
/// <summary>Sonic Foundry</summary>
|
||||
Sonicfoundry = 66,
|
||||
/// <summary>Vitec Multimedia</summary>
|
||||
Vitec = 67,
|
||||
/// <summary>MOSCOM Corporation</summary>
|
||||
Moscom = 68,
|
||||
/// <summary>Silicon Soft, Inc.</summary>
|
||||
Siliconsoft = 69,
|
||||
/// <summary>Supermac</summary>
|
||||
Supermac = 73,
|
||||
/// <summary>Audio Processing Technology</summary>
|
||||
Audiopt = 74,
|
||||
/// <summary>Speech Compression</summary>
|
||||
Speechcomp = 76,
|
||||
/// <summary>Ahead, Inc.</summary>
|
||||
Ahead = 77,
|
||||
/// <summary>Dolby Laboratories</summary>
|
||||
Dolby = 78,
|
||||
/// <summary>OKI</summary>
|
||||
Oki = 79,
|
||||
/// <summary>AuraVision Corporation</summary>
|
||||
Auravision = 80,
|
||||
/// <summary>Ing C. Olivetti & C., S.p.A.</summary>
|
||||
Olivetti = 81,
|
||||
/// <summary>I/O Magic Corporation</summary>
|
||||
Iomagic = 82,
|
||||
/// <summary>Matsushita Electric Industrial Co., LTD.</summary>
|
||||
Matsushita = 83,
|
||||
/// <summary>Control Resources Limited</summary>
|
||||
Controlres = 84,
|
||||
/// <summary>Xebec Multimedia Solutions Limited</summary>
|
||||
Xebec = 85,
|
||||
/// <summary>New Media Corporation</summary>
|
||||
Newmedia = 86,
|
||||
/// <summary>Natural MicroSystems</summary>
|
||||
Nms = 87,
|
||||
/// <summary>Lyrrus Inc.</summary>
|
||||
Lyrrus = 88,
|
||||
/// <summary>Compusic</summary>
|
||||
Compusic = 89,
|
||||
/// <summary>OPTi Computers Inc.</summary>
|
||||
Opti = 90,
|
||||
/// <summary>Adlib Accessories Inc.</summary>
|
||||
Adlacc = 91,
|
||||
/// <summary>Compaq Computer Corp.</summary>
|
||||
Compaq = 92,
|
||||
/// <summary>Dialogic Corporation</summary>
|
||||
Dialogic = 93,
|
||||
/// <summary>InSoft, Inc.</summary>
|
||||
Insoft = 94,
|
||||
/// <summary>M.P. Technologies, Inc.</summary>
|
||||
Mptus = 95,
|
||||
/// <summary>Weitek</summary>
|
||||
Weitek = 96,
|
||||
/// <summary>Lernout & Hauspie</summary>
|
||||
LernoutAndHauspie = 97,
|
||||
/// <summary>Quanta Computer Inc.</summary>
|
||||
Qciar = 98,
|
||||
/// <summary>Apple Computer, Inc.</summary>
|
||||
Apple = 99,
|
||||
/// <summary>Digital Equipment Corporation</summary>
|
||||
Digital = 100,
|
||||
/// <summary>Mark of the Unicorn</summary>
|
||||
Motu = 101,
|
||||
/// <summary>Workbit Corporation</summary>
|
||||
Workbit = 102,
|
||||
/// <summary>Ositech Communications Inc.</summary>
|
||||
Ositech = 103,
|
||||
/// <summary>miro Computer Products AG</summary>
|
||||
Miro = 104,
|
||||
/// <summary>Cirrus Logic</summary>
|
||||
Cirruslogic = 105,
|
||||
/// <summary>ISOLUTION B.V.</summary>
|
||||
Isolution = 106,
|
||||
/// <summary>Horizons Technology, Inc</summary>
|
||||
Horizons = 107,
|
||||
/// <summary>Computer Concepts Ltd</summary>
|
||||
Concepts = 108,
|
||||
/// <summary>Voice Technologies Group, Inc.</summary>
|
||||
Vtg = 109,
|
||||
/// <summary>Radius</summary>
|
||||
Radius = 110,
|
||||
/// <summary>Rockwell International</summary>
|
||||
Rockwell = 111,
|
||||
/// <summary>Co. XYZ for testing</summary>
|
||||
Xyz = 112,
|
||||
/// <summary>Opcode Systems</summary>
|
||||
Opcode = 113,
|
||||
/// <summary>Voxware Inc</summary>
|
||||
Voxware = 114,
|
||||
/// <summary>Northern Telecom Limited</summary>
|
||||
NorthernTelecom = 115,
|
||||
/// <summary>APICOM</summary>
|
||||
Apicom = 116,
|
||||
/// <summary>Grande Software</summary>
|
||||
Grande = 117,
|
||||
/// <summary>ADDX</summary>
|
||||
Addx = 118,
|
||||
/// <summary>Wildcat Canyon Software</summary>
|
||||
Wildcat = 119,
|
||||
/// <summary>Rhetorex Inc</summary>
|
||||
Rhetorex = 120,
|
||||
/// <summary>Brooktree Corporation</summary>
|
||||
Brooktree = 121,
|
||||
/// <summary>ENSONIQ Corporation</summary>
|
||||
Ensoniq = 125,
|
||||
/// <summary>FAST Multimedia AG</summary>
|
||||
Fast = 126,
|
||||
/// <summary>NVidia Corporation</summary>
|
||||
Nvidia = 127,
|
||||
/// <summary>OKSORI Co., Ltd.</summary>
|
||||
Oksori = 128,
|
||||
/// <summary>DiAcoustics, Inc.</summary>
|
||||
Diacoustics = 129,
|
||||
/// <summary>Gulbransen, Inc.</summary>
|
||||
Gulbransen = 130,
|
||||
/// <summary>Kay Elemetrics, Inc.</summary>
|
||||
KayElemetrics = 131,
|
||||
/// <summary>Crystal Semiconductor Corporation</summary>
|
||||
Crystal = 132,
|
||||
/// <summary>Splash Studios</summary>
|
||||
SplashStudios = 133,
|
||||
/// <summary>Quarterdeck Corporation</summary>
|
||||
Quarterdeck = 134,
|
||||
/// <summary>TDK Corporation</summary>
|
||||
Tdk = 135,
|
||||
/// <summary>Digital Audio Labs, Inc.</summary>
|
||||
DigitalAudioLabs = 136,
|
||||
/// <summary>Seer Systems, Inc.</summary>
|
||||
Seersys = 137,
|
||||
/// <summary>PictureTel Corporation</summary>
|
||||
Picturetel = 138,
|
||||
/// <summary>AT&T Microelectronics</summary>
|
||||
AttMicroelectronics = 139,
|
||||
/// <summary>Osprey Technologies, Inc.</summary>
|
||||
Osprey = 140,
|
||||
/// <summary>Mediatrix Peripherals</summary>
|
||||
Mediatrix = 141,
|
||||
/// <summary>SounDesignS M.C.S. Ltd.</summary>
|
||||
Soundesigns = 142,
|
||||
/// <summary>A.L. Digital Ltd.</summary>
|
||||
Aldigital = 143,
|
||||
/// <summary>Spectrum Signal Processing, Inc.</summary>
|
||||
SpectrumSignalProcessing = 144,
|
||||
/// <summary>Electronic Courseware Systems, Inc.</summary>
|
||||
Ecs = 145,
|
||||
/// <summary>AMD</summary>
|
||||
Amd = 146,
|
||||
/// <summary>Core Dynamics</summary>
|
||||
Coredynamics = 147,
|
||||
/// <summary>CANAM Computers</summary>
|
||||
Canam = 148,
|
||||
/// <summary>Softsound, Ltd.</summary>
|
||||
Softsound = 149,
|
||||
/// <summary>Norris Communications, Inc.</summary>
|
||||
Norris = 150,
|
||||
/// <summary>Danka Data Devices</summary>
|
||||
Ddd = 151,
|
||||
/// <summary>EuPhonics</summary>
|
||||
Euphonics = 152,
|
||||
/// <summary>Precept Software, Inc.</summary>
|
||||
Precept = 153,
|
||||
/// <summary>Crystal Net Corporation</summary>
|
||||
CrystalNet = 154,
|
||||
/// <summary>Chromatic Research, Inc</summary>
|
||||
Chromatic = 155,
|
||||
/// <summary>Voice Information Systems, Inc</summary>
|
||||
Voiceinfo = 156,
|
||||
/// <summary>Vienna Systems</summary>
|
||||
Viennasys = 157,
|
||||
/// <summary>Connectix Corporation</summary>
|
||||
Connectix = 158,
|
||||
/// <summary>Gadget Labs LLC</summary>
|
||||
Gadgetlabs = 159,
|
||||
/// <summary>Frontier Design Group LLC</summary>
|
||||
Frontier = 160,
|
||||
/// <summary>Viona Development GmbH</summary>
|
||||
Viona = 161,
|
||||
/// <summary>Casio Computer Co., LTD</summary>
|
||||
Casio = 162,
|
||||
/// <summary>Diamond Multimedia</summary>
|
||||
Diamondmm = 163,
|
||||
/// <summary>S3</summary>
|
||||
S3 = 164,
|
||||
/// <summary>Fraunhofer</summary>
|
||||
FraunhoferIis = 172,
|
||||
|
||||
/*
|
||||
public static String GetName(int manufacturerId) {
|
||||
switch(manufacturerId) {
|
||||
case Gravis: return "Advanced Gravis Computer Technology, Ltd.";
|
||||
case Antex: return "Antex Electronics Corporation";
|
||||
case Apps: return "APPS Software";
|
||||
case Artisoft: return "Artisoft, Inc.";
|
||||
case Ast: return "AST Research, Inc.";
|
||||
case Ati: return "ATI Technologies, Inc.";
|
||||
case Audiofile: return "Audio, Inc.";
|
||||
case Apt: return "Audio Processing Technology";
|
||||
case Audiopt: return "Audio Processing Technology";
|
||||
case Auravision: return "Auravision Corporation";
|
||||
case Aztech: return "Aztech Labs, Inc.";
|
||||
case Canopus: return "Canopus, Co., Ltd.";
|
||||
case Compusic: return "Compusic";
|
||||
case Cat: return "Computer Aided Technology, Inc.";
|
||||
case ComputerFriends: return "Computer Friends, Inc.";
|
||||
case Controlres: return "Control Resources Corporation";
|
||||
case Creative: return "Creative Labs, Inc.";
|
||||
case Dialogic: return "Dialogic Corporation";
|
||||
case Dolby: return "Dolby Laboratories, Inc.";
|
||||
case DspGroup: return "DSP Group, Inc.";
|
||||
case DspSolutions: return "DSP Solutions, Inc.";
|
||||
case Echo: return "Echo Speech Corporation";
|
||||
case Ess: return "ESS Technology, Inc.";
|
||||
case Everex: return "Everex Systems, Inc.";
|
||||
case Exan: return "EXAN, Ltd.";
|
||||
case Fujitsu: return "Fujitsu, Ltd.";
|
||||
case Iomagic: return "I/O Magic Corporation";
|
||||
case IclPS: return "ICL Personal Systems";
|
||||
case Olivetti: return "Ing. C. Olivetti & C., S.p.A.";
|
||||
case Ics: return "Integrated Circuit Systems, Inc.";
|
||||
case Intel: return "Intel Corporation";
|
||||
case Interactive: return "InterActive, Inc.";
|
||||
case Ibm: return "International Business Machines";
|
||||
case Iteratedsys: return "Iterated Systems, Inc.";
|
||||
case Logitech: return "Logitech, Inc.";
|
||||
case Lyrrus: return "Lyrrus, Inc.";
|
||||
case Matsushita: return "Matsushita Electric Corporation of America";
|
||||
case Mediavision: return "Media Vision, Inc.";
|
||||
case Metheus: return "Metheus Corporation";
|
||||
case Melabs: return "microEngineering Labs";
|
||||
case Microsoft: return "Microsoft Corporation";
|
||||
case Moscom: return "MOSCOM Corporation";
|
||||
case Motorola: return "Motorola, Inc.";
|
||||
case Nms: return "Natural MicroSystems Corporation";
|
||||
case Ncr: return "NCR Corporation";
|
||||
case Nec: return "NEC Corporation";
|
||||
case Newmedia: return "New Media Corporation";
|
||||
case Oki: return "OKI";
|
||||
case Opti: return "OPTi, Inc.";
|
||||
case Roland: return "Roland Corporation";
|
||||
case Scalacs: return "SCALACS";
|
||||
case Epson: return "Seiko Epson Corporation, Inc.";
|
||||
case Sierra: return "Sierra Semiconductor Corporation";
|
||||
case Siliconsoft: return "Silicon Software, Inc.";
|
||||
case Sonicfoundry: return "Sonic Foundry";
|
||||
case Speechcomp: return "Speech Compression";
|
||||
case Supermac: return "Supermac Technology, Inc.";
|
||||
case Tandy: return "Tandy Corporation";
|
||||
case Korg: return "Toshihiko Okuhura, Korg, Inc.";
|
||||
case Truevision: return "Truevision, Inc.";
|
||||
case TurtleBeach: return "Turtle Beach Systems";
|
||||
case Val: return "Video Associates Labs, Inc.";
|
||||
case Videologic: return "VideoLogic, Inc.";
|
||||
case Vitec: return "Visual Information Technologies, Inc.";
|
||||
case Vocaltec: return "VocalTec, Inc.";
|
||||
case Voyetra: return "Voyetra Technologies";
|
||||
case Wanglabs: return "Wang Laboratories";
|
||||
case Willowpond: return "Willow Pond Corporation";
|
||||
case Winnov: return "Winnov, LP";
|
||||
case Xebec: return "Xebec Multimedia Solutions Limited";
|
||||
case Yamaha: return "Yamaha Corporation of America";
|
||||
default: return String.Format("Unknown Manufacturer ({0})",manufacturerId);
|
||||
}
|
||||
}
|
||||
**/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f57b59750873d6043919bf60d94b92cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MmException.
|
||||
/// </summary>
|
||||
public class MmException : Exception
|
||||
{
|
||||
private MmResult result;
|
||||
private string function;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new MmException
|
||||
/// </summary>
|
||||
/// <param name="result">The result returned by the Windows API call</param>
|
||||
/// <param name="function">The name of the Windows API that failed</param>
|
||||
public MmException(MmResult result, string function)
|
||||
: base(MmException.ErrorMessage(result, function))
|
||||
{
|
||||
this.result = result;
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
|
||||
private static string ErrorMessage(MmResult result, string function)
|
||||
{
|
||||
return String.Format("{0} calling {1}", result, function);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper function to automatically raise an exception on failure
|
||||
/// </summary>
|
||||
/// <param name="result">The result of the API call</param>
|
||||
/// <param name="function">The API function name</param>
|
||||
public static void Try(MmResult result, string function)
|
||||
{
|
||||
if (result != MmResult.NoError)
|
||||
throw new MmException(result, function);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Windows API result
|
||||
/// </summary>
|
||||
public MmResult Result
|
||||
{
|
||||
get
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10dcef64a2b5b254aa3dd2fdf6e2a2aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio
|
||||
{
|
||||
/// <summary>
|
||||
/// Windows multimedia error codes from mmsystem.h.
|
||||
/// </summary>
|
||||
public enum MmResult
|
||||
{
|
||||
/// <summary>no error, MMSYSERR_NOERROR</summary>
|
||||
NoError = 0,
|
||||
/// <summary>unspecified error, MMSYSERR_ERROR</summary>
|
||||
UnspecifiedError = 1,
|
||||
/// <summary>device ID out of range, MMSYSERR_BADDEVICEID</summary>
|
||||
BadDeviceId = 2,
|
||||
/// <summary>driver failed enable, MMSYSERR_NOTENABLED</summary>
|
||||
NotEnabled = 3,
|
||||
/// <summary>device already allocated, MMSYSERR_ALLOCATED</summary>
|
||||
AlreadyAllocated = 4,
|
||||
/// <summary>device handle is invalid, MMSYSERR_INVALHANDLE</summary>
|
||||
InvalidHandle = 5,
|
||||
/// <summary>no device driver present, MMSYSERR_NODRIVER</summary>
|
||||
NoDriver = 6,
|
||||
/// <summary>memory allocation error, MMSYSERR_NOMEM</summary>
|
||||
MemoryAllocationError = 7,
|
||||
/// <summary>function isn't supported, MMSYSERR_NOTSUPPORTED</summary>
|
||||
NotSupported = 8,
|
||||
/// <summary>error value out of range, MMSYSERR_BADERRNUM</summary>
|
||||
BadErrorNumber = 9,
|
||||
/// <summary>invalid flag passed, MMSYSERR_INVALFLAG</summary>
|
||||
InvalidFlag = 10,
|
||||
/// <summary>invalid parameter passed, MMSYSERR_INVALPARAM</summary>
|
||||
InvalidParameter = 11,
|
||||
/// <summary>handle being used simultaneously on another thread (eg callback),MMSYSERR_HANDLEBUSY</summary>
|
||||
HandleBusy = 12,
|
||||
/// <summary>specified alias not found, MMSYSERR_INVALIDALIAS</summary>
|
||||
InvalidAlias = 13,
|
||||
/// <summary>bad registry database, MMSYSERR_BADDB</summary>
|
||||
BadRegistryDatabase = 14,
|
||||
/// <summary>registry key not found, MMSYSERR_KEYNOTFOUND</summary>
|
||||
RegistryKeyNotFound = 15,
|
||||
/// <summary>registry read error, MMSYSERR_READERROR</summary>
|
||||
RegistryReadError = 16,
|
||||
/// <summary>registry write error, MMSYSERR_WRITEERROR</summary>
|
||||
RegistryWriteError = 17,
|
||||
/// <summary>registry delete error, MMSYSERR_DELETEERROR</summary>
|
||||
RegistryDeleteError = 18,
|
||||
/// <summary>registry value not found, MMSYSERR_VALNOTFOUND</summary>
|
||||
RegistryValueNotFound = 19,
|
||||
/// <summary>driver does not call DriverCallback, MMSYSERR_NODRIVERCB</summary>
|
||||
NoDriverCallback = 20,
|
||||
/// <summary>more data to be returned, MMSYSERR_MOREDATA</summary>
|
||||
MoreData = 21,
|
||||
|
||||
/// <summary>unsupported wave format, WAVERR_BADFORMAT</summary>
|
||||
WaveBadFormat = 32,
|
||||
/// <summary>still something playing, WAVERR_STILLPLAYING</summary>
|
||||
WaveStillPlaying = 33,
|
||||
/// <summary>header not prepared, WAVERR_UNPREPARED</summary>
|
||||
WaveHeaderUnprepared = 34,
|
||||
/// <summary>device is synchronous, WAVERR_SYNC</summary>
|
||||
WaveSync = 35,
|
||||
|
||||
// ACM error codes, found in msacm.h
|
||||
|
||||
/// <summary>Conversion not possible (ACMERR_NOTPOSSIBLE)</summary>
|
||||
AcmNotPossible = 512,
|
||||
/// <summary>Busy (ACMERR_BUSY)</summary>
|
||||
AcmBusy = 513,
|
||||
/// <summary>Header Unprepared (ACMERR_UNPREPARED)</summary>
|
||||
AcmHeaderUnprepared = 514,
|
||||
/// <summary>Cancelled (ACMERR_CANCELED)</summary>
|
||||
AcmCancelled = 515,
|
||||
|
||||
// Mixer error codes, found in mmresult.h
|
||||
|
||||
/// <summary>invalid line (MIXERR_INVALLINE)</summary>
|
||||
MixerInvalidLine = 1024,
|
||||
/// <summary>invalid control (MIXERR_INVALCONTROL)</summary>
|
||||
MixerInvalidControl = 1025,
|
||||
/// <summary>invalid value (MIXERR_INVALVALUE)</summary>
|
||||
MixerInvalidValue = 1026,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3dc03c6094857b41b3775fa9dc5a080
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
// http://msdn.microsoft.com/en-us/library/dd757347(v=VS.85).aspx
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
struct MmTime
|
||||
{
|
||||
public const int TIME_MS = 0x0001;
|
||||
public const int TIME_SAMPLES = 0x0002;
|
||||
public const int TIME_BYTES = 0x0004;
|
||||
|
||||
[FieldOffset(0)]
|
||||
public UInt32 wType;
|
||||
[FieldOffset(4)]
|
||||
public UInt32 ms;
|
||||
[FieldOffset(4)]
|
||||
public UInt32 sample;
|
||||
[FieldOffset(4)]
|
||||
public UInt32 cb;
|
||||
[FieldOffset(4)]
|
||||
public UInt32 ticks;
|
||||
[FieldOffset(4)]
|
||||
public Byte smpteHour;
|
||||
[FieldOffset(5)]
|
||||
public Byte smpteMin;
|
||||
[FieldOffset(6)]
|
||||
public Byte smpteSec;
|
||||
[FieldOffset(7)]
|
||||
public Byte smpteFrame;
|
||||
[FieldOffset(8)]
|
||||
public Byte smpteFps;
|
||||
[FieldOffset(9)]
|
||||
public Byte smpteDummy;
|
||||
[FieldOffset(10)]
|
||||
public Byte smptePad0;
|
||||
[FieldOffset(11)]
|
||||
public Byte smptePad1;
|
||||
[FieldOffset(4)]
|
||||
public UInt32 midiSongPtrPos;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b37a5862f37fd8d4590a68249cb51289
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
/// <summary>
|
||||
/// Wave Callback Info
|
||||
/// </summary>
|
||||
public class WaveCallbackInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Callback Strategy
|
||||
/// </summary>
|
||||
public WaveCallbackStrategy Strategy { get; private set; }
|
||||
/// <summary>
|
||||
/// Window Handle (if applicable)
|
||||
/// </summary>
|
||||
public IntPtr Handle { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets up a new WaveCallbackInfo for function callbacks
|
||||
/// </summary>
|
||||
public static WaveCallbackInfo FunctionCallback()
|
||||
{
|
||||
return new WaveCallbackInfo(WaveCallbackStrategy.FunctionCallback, IntPtr.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up a new WaveCallbackInfo to use a New Window
|
||||
/// IMPORTANT: only use this on the GUI thread
|
||||
/// </summary>
|
||||
public static WaveCallbackInfo NewWindow()
|
||||
{
|
||||
return new WaveCallbackInfo(WaveCallbackStrategy.NewWindow, IntPtr.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets up a new WaveCallbackInfo to use an existing window
|
||||
/// IMPORTANT: only use this on the GUI thread
|
||||
/// </summary>
|
||||
public static WaveCallbackInfo ExistingWindow(IntPtr handle)
|
||||
{
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
throw new ArgumentException("Handle cannot be zero");
|
||||
}
|
||||
return new WaveCallbackInfo(WaveCallbackStrategy.ExistingWindow, handle);
|
||||
}
|
||||
|
||||
private WaveCallbackInfo(WaveCallbackStrategy strategy, IntPtr handle)
|
||||
{
|
||||
this.Strategy = strategy;
|
||||
this.Handle = handle;
|
||||
}
|
||||
|
||||
internal void Connect(WaveInterop.WaveCallback callback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal MmResult WaveOutOpen(out IntPtr waveOutHandle, int deviceNumber, WaveFormat waveFormat, WaveInterop.WaveCallback callback)
|
||||
{
|
||||
MmResult result;
|
||||
if (Strategy == WaveCallbackStrategy.FunctionCallback)
|
||||
{
|
||||
result = WaveInterop.waveOutOpen(out waveOutHandle, (IntPtr)deviceNumber, waveFormat, callback, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackFunction);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = WaveInterop.waveOutOpenWindow(out waveOutHandle, (IntPtr)deviceNumber, waveFormat, this.Handle, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackWindow);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal MmResult WaveInOpen(out IntPtr waveInHandle, int deviceNumber, WaveFormat waveFormat, WaveInterop.WaveCallback callback)
|
||||
{
|
||||
MmResult result;
|
||||
if (Strategy == WaveCallbackStrategy.FunctionCallback)
|
||||
{
|
||||
result = WaveInterop.waveInOpen(out waveInHandle, (IntPtr)deviceNumber, waveFormat, callback, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackFunction);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = WaveInterop.waveInOpenWindow(out waveInHandle, (IntPtr)deviceNumber, waveFormat, this.Handle, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackWindow);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void Disconnect()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e4a74a865447fe49812887ed78478db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
/// <summary>
|
||||
/// Wave Callback Strategy
|
||||
/// </summary>
|
||||
public enum WaveCallbackStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// Use a function
|
||||
/// </summary>
|
||||
FunctionCallback,
|
||||
/// <summary>
|
||||
/// Create a new window (should only be done if on GUI thread)
|
||||
/// </summary>
|
||||
NewWindow,
|
||||
/// <summary>
|
||||
/// Use an existing window handle
|
||||
/// </summary>
|
||||
ExistingWindow,
|
||||
/// <summary>
|
||||
/// Use an event handle
|
||||
/// </summary>
|
||||
Event,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a09269ec171e1584b908948cd28f3b6f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
/// <summary>
|
||||
/// WaveHeader interop structure (WAVEHDR)
|
||||
/// http://msdn.microsoft.com/en-us/library/dd743837%28VS.85%29.aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
class WaveHeader
|
||||
{
|
||||
/// <summary>pointer to locked data buffer (lpData)</summary>
|
||||
public IntPtr dataBuffer;
|
||||
/// <summary>length of data buffer (dwBufferLength)</summary>
|
||||
public int bufferLength;
|
||||
/// <summary>used for input only (dwBytesRecorded)</summary>
|
||||
public int bytesRecorded;
|
||||
/// <summary>for client's use (dwUser)</summary>
|
||||
public IntPtr userData;
|
||||
/// <summary>assorted flags (dwFlags)</summary>
|
||||
public WaveHeaderFlags flags;
|
||||
/// <summary>loop control counter (dwLoops)</summary>
|
||||
public int loops;
|
||||
/// <summary>PWaveHdr, reserved for driver (lpNext)</summary>
|
||||
public IntPtr next;
|
||||
/// <summary>reserved for driver</summary>
|
||||
public IntPtr reserved;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e79b335ad0883d8448abd72115446ef4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
/// <summary>
|
||||
/// Wave Header Flags enumeration
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum WaveHeaderFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// WHDR_BEGINLOOP
|
||||
/// This buffer is the first buffer in a loop. This flag is used only with output buffers.
|
||||
/// </summary>
|
||||
BeginLoop = 0x00000004,
|
||||
/// <summary>
|
||||
/// WHDR_DONE
|
||||
/// Set by the device driver to indicate that it is finished with the buffer and is returning it to the application.
|
||||
/// </summary>
|
||||
Done = 0x00000001,
|
||||
/// <summary>
|
||||
/// WHDR_ENDLOOP
|
||||
/// This buffer is the last buffer in a loop. This flag is used only with output buffers.
|
||||
/// </summary>
|
||||
EndLoop = 0x00000008,
|
||||
/// <summary>
|
||||
/// WHDR_INQUEUE
|
||||
/// Set by Windows to indicate that the buffer is queued for playback.
|
||||
/// </summary>
|
||||
InQueue = 0x00000010,
|
||||
/// <summary>
|
||||
/// WHDR_PREPARED
|
||||
/// Set by Windows to indicate that the buffer has been prepared with the waveInPrepareHeader or waveOutPrepareHeader function.
|
||||
/// </summary>
|
||||
Prepared = 0x00000002
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f628707965b98f940b70e7e1e1fbd6e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
/// <summary>
|
||||
/// WaveInCapabilities structure (based on WAVEINCAPS2 from mmsystem.h)
|
||||
/// http://msdn.microsoft.com/en-us/library/ms713726(VS.85).aspx
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
public struct WaveInCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// wMid
|
||||
/// </summary>
|
||||
private short manufacturerId;
|
||||
/// <summary>
|
||||
/// wPid
|
||||
/// </summary>
|
||||
private short productId;
|
||||
/// <summary>
|
||||
/// vDriverVersion
|
||||
/// </summary>
|
||||
private int driverVersion;
|
||||
/// <summary>
|
||||
/// Product Name (szPname)
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxProductNameLength)]
|
||||
private string productName;
|
||||
/// <summary>
|
||||
/// Supported formats (bit flags) dwFormats
|
||||
/// </summary>
|
||||
private SupportedWaveFormat supportedFormats;
|
||||
/// <summary>
|
||||
/// Supported channels (1 for mono 2 for stereo) (wChannels)
|
||||
/// Seems to be set to -1 on a lot of devices
|
||||
/// </summary>
|
||||
private short channels;
|
||||
/// <summary>
|
||||
/// wReserved1
|
||||
/// </summary>
|
||||
private short reserved;
|
||||
|
||||
// extra WAVEINCAPS2 members
|
||||
private Guid manufacturerGuid;
|
||||
private Guid productGuid;
|
||||
private Guid nameGuid;
|
||||
|
||||
private const int MaxProductNameLength = 32;
|
||||
|
||||
/// <summary>
|
||||
/// Number of channels supported
|
||||
/// </summary>
|
||||
public int Channels
|
||||
{
|
||||
get
|
||||
{
|
||||
return channels;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The product name
|
||||
/// </summary>
|
||||
public string ProductName
|
||||
{
|
||||
get
|
||||
{
|
||||
return productName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The device name Guid (if provided)
|
||||
/// </summary>
|
||||
public Guid NameGuid { get { return nameGuid; } }
|
||||
/// <summary>
|
||||
/// The product name Guid (if provided)
|
||||
/// </summary>
|
||||
public Guid ProductGuid { get { return productGuid; } }
|
||||
/// <summary>
|
||||
/// The manufacturer guid (if provided)
|
||||
/// </summary>
|
||||
public Guid ManufacturerGuid { get { return manufacturerGuid; } }
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if a given SupportedWaveFormat is supported
|
||||
/// </summary>
|
||||
/// <param name="waveFormat">The SupportedWaveFormat</param>
|
||||
/// <returns>true if supported</returns>
|
||||
public bool SupportsWaveFormat(SupportedWaveFormat waveFormat)
|
||||
{
|
||||
return (supportedFormats & waveFormat) == waveFormat;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal static class WaveCapabilitiesHelpers
|
||||
{
|
||||
public static readonly Guid MicrosoftDefaultManufacturerId = new Guid("d5a47fa8-6d98-11d1-a21a-00a0c9223196");
|
||||
public static readonly Guid DefaultWaveOutGuid = new Guid("E36DC310-6D9A-11D1-A21A-00A0C9223196");
|
||||
public static readonly Guid DefaultWaveInGuid = new Guid("E36DC311-6D9A-11D1-A21A-00A0C9223196");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8da8a77093edea149b1ef5ceabafd6ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
/// <summary>
|
||||
/// Event Args for WaveInStream event
|
||||
/// </summary>
|
||||
public class WaveInEventArgs : EventArgs
|
||||
{
|
||||
private byte[] buffer;
|
||||
private int bytes;
|
||||
|
||||
/// <summary>
|
||||
/// Creates new WaveInEventArgs
|
||||
/// </summary>
|
||||
public WaveInEventArgs(byte[] buffer, int bytes)
|
||||
{
|
||||
this.buffer = buffer;
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Buffer containing recorded data. Note that it might not be completely
|
||||
/// full. <seealso cref="BytesRecorded"/>
|
||||
/// </summary>
|
||||
public byte[] Buffer
|
||||
{
|
||||
get { return buffer; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of recorded bytes in Buffer. <seealso cref="Buffer"/>
|
||||
/// </summary>
|
||||
public int BytesRecorded
|
||||
{
|
||||
get { return bytes; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20a297154f726d24e863ed83dcbc60a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
/// <summary>
|
||||
/// MME Wave function interop
|
||||
/// </summary>
|
||||
class WaveInterop
|
||||
{
|
||||
[Flags]
|
||||
public enum WaveInOutOpenFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// CALLBACK_NULL
|
||||
/// No callback
|
||||
/// </summary>
|
||||
CallbackNull = 0,
|
||||
/// <summary>
|
||||
/// CALLBACK_FUNCTION
|
||||
/// dwCallback is a FARPROC
|
||||
/// </summary>
|
||||
CallbackFunction = 0x30000,
|
||||
/// <summary>
|
||||
/// CALLBACK_EVENT
|
||||
/// dwCallback is an EVENT handle
|
||||
/// </summary>
|
||||
CallbackEvent = 0x50000,
|
||||
/// <summary>
|
||||
/// CALLBACK_WINDOW
|
||||
/// dwCallback is a HWND
|
||||
/// </summary>
|
||||
CallbackWindow = 0x10000,
|
||||
/// <summary>
|
||||
/// CALLBACK_THREAD
|
||||
/// callback is a thread ID
|
||||
/// </summary>
|
||||
CallbackThread = 0x20000,
|
||||
/*
|
||||
WAVE_FORMAT_QUERY = 1,
|
||||
WAVE_MAPPED = 4,
|
||||
WAVE_FORMAT_DIRECT = 8*/
|
||||
}
|
||||
|
||||
//public const int TIME_MS = 0x0001; // time in milliseconds
|
||||
//public const int TIME_SAMPLES = 0x0002; // number of wave samples
|
||||
//public const int TIME_BYTES = 0x0004; // current byte offset
|
||||
|
||||
public enum WaveMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// WIM_OPEN
|
||||
/// </summary>
|
||||
WaveInOpen = 0x3BE,
|
||||
/// <summary>
|
||||
/// WIM_CLOSE
|
||||
/// </summary>
|
||||
WaveInClose = 0x3BF,
|
||||
/// <summary>
|
||||
/// WIM_DATA
|
||||
/// </summary>
|
||||
WaveInData = 0x3C0,
|
||||
|
||||
/// <summary>
|
||||
/// WOM_CLOSE
|
||||
/// </summary>
|
||||
WaveOutClose = 0x3BC,
|
||||
/// <summary>
|
||||
/// WOM_DONE
|
||||
/// </summary>
|
||||
WaveOutDone = 0x3BD,
|
||||
/// <summary>
|
||||
/// WOM_OPEN
|
||||
/// </summary>
|
||||
WaveOutOpen = 0x3BB
|
||||
}
|
||||
|
||||
// use the userdata as a reference
|
||||
// WaveOutProc http://msdn.microsoft.com/en-us/library/dd743869%28VS.85%29.aspx
|
||||
// WaveInProc http://msdn.microsoft.com/en-us/library/dd743849%28VS.85%29.aspx
|
||||
public delegate void WaveCallback(IntPtr hWaveOut, WaveMessage message, IntPtr dwInstance, WaveHeader wavhdr, IntPtr dwReserved);
|
||||
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern Int32 mmioStringToFOURCC([MarshalAs(UnmanagedType.LPStr)] String s, int flags);
|
||||
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern Int32 waveOutGetNumDevs();
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutPrepareHeader(IntPtr hWaveOut, WaveHeader lpWaveOutHdr, int uSize);
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutUnprepareHeader(IntPtr hWaveOut, WaveHeader lpWaveOutHdr, int uSize);
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutWrite(IntPtr hWaveOut, WaveHeader lpWaveOutHdr, int uSize);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743866%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutOpen(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
|
||||
[DllImport("winmm.dll", EntryPoint = "waveOutOpen")]
|
||||
public static extern MmResult waveOutOpenWindow(out IntPtr hWaveOut, IntPtr uDeviceID, WaveFormat lpFormat, IntPtr callbackWindowHandle, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
|
||||
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutReset(IntPtr hWaveOut);
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutClose(IntPtr hWaveOut);
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutPause(IntPtr hWaveOut);
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutRestart(IntPtr hWaveOut);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743863%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutGetPosition(IntPtr hWaveOut, out MmTime mmTime, int uSize);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743874%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutSetVolume(IntPtr hWaveOut, int dwVolume);
|
||||
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveOutGetVolume(IntPtr hWaveOut, out int dwVolume);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743857%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll", CharSet = CharSet.Auto)]
|
||||
public static extern MmResult waveOutGetDevCaps(IntPtr deviceID, out WaveOutCapabilities waveOutCaps, int waveOutCapsSize);
|
||||
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern Int32 waveInGetNumDevs();
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743841%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll", CharSet = CharSet.Auto)]
|
||||
public static extern MmResult waveInGetDevCaps(IntPtr deviceID, out WaveInCapabilities waveInCaps, int waveInCapsSize);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743838%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveInAddBuffer(IntPtr hWaveIn, WaveHeader pwh, int cbwh);
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveInClose(IntPtr hWaveIn);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743847%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveInOpen(out IntPtr hWaveIn, IntPtr uDeviceID, WaveFormat lpFormat, WaveCallback dwCallback, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
|
||||
[DllImport("winmm.dll", EntryPoint = "waveInOpen")]
|
||||
public static extern MmResult waveInOpenWindow(out IntPtr hWaveIn, IntPtr uDeviceID, WaveFormat lpFormat, IntPtr callbackWindowHandle, IntPtr dwInstance, WaveInOutOpenFlags dwFlags);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743848%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveInPrepareHeader(IntPtr hWaveIn, WaveHeader lpWaveInHdr, int uSize);
|
||||
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveInUnprepareHeader(IntPtr hWaveIn, WaveHeader lpWaveInHdr, int uSize);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743850%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveInReset(IntPtr hWaveIn);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743851%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveInStart(IntPtr hWaveIn);
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/dd743852%28VS.85%29.aspx
|
||||
[DllImport("winmm.dll")]
|
||||
public static extern MmResult waveInStop(IntPtr hWaveIn);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 743d4b380d00069459859a26b2eaeee8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,217 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
/// <summary>
|
||||
/// WaveOutCapabilities structure (based on WAVEOUTCAPS2 from mmsystem.h)
|
||||
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_waveoutcaps_str.asp
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
public struct WaveOutCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// wMid
|
||||
/// </summary>
|
||||
private short manufacturerId;
|
||||
/// <summary>
|
||||
/// wPid
|
||||
/// </summary>
|
||||
private short productId;
|
||||
/// <summary>
|
||||
/// vDriverVersion
|
||||
/// </summary>
|
||||
private int driverVersion;
|
||||
/// <summary>
|
||||
/// Product Name (szPname)
|
||||
/// </summary>
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxProductNameLength)]
|
||||
private string productName;
|
||||
/// <summary>
|
||||
/// Supported formats (bit flags) dwFormats
|
||||
/// </summary>
|
||||
private SupportedWaveFormat supportedFormats;
|
||||
/// <summary>
|
||||
/// Supported channels (1 for mono 2 for stereo) (wChannels)
|
||||
/// Seems to be set to -1 on a lot of devices
|
||||
/// </summary>
|
||||
private short channels;
|
||||
/// <summary>
|
||||
/// wReserved1
|
||||
/// </summary>
|
||||
private short reserved;
|
||||
/// <summary>
|
||||
/// Optional functionality supported by the device
|
||||
/// </summary>
|
||||
private WaveOutSupport support; // = new WaveOutSupport();
|
||||
|
||||
// extra WAVEOUTCAPS2 members
|
||||
private Guid manufacturerGuid;
|
||||
private Guid productGuid;
|
||||
private Guid nameGuid;
|
||||
|
||||
private const int MaxProductNameLength = 32;
|
||||
|
||||
/// <summary>
|
||||
/// Number of channels supported
|
||||
/// </summary>
|
||||
public int Channels
|
||||
{
|
||||
get
|
||||
{
|
||||
return channels;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether playback control is supported
|
||||
/// </summary>
|
||||
public bool SupportsPlaybackRateControl
|
||||
{
|
||||
get
|
||||
{
|
||||
return (support & WaveOutSupport.PlaybackRate) == WaveOutSupport.PlaybackRate;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The product name
|
||||
/// </summary>
|
||||
public string ProductName
|
||||
{
|
||||
get
|
||||
{
|
||||
return productName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks to see if a given SupportedWaveFormat is supported
|
||||
/// </summary>
|
||||
/// <param name="waveFormat">The SupportedWaveFormat</param>
|
||||
/// <returns>true if supported</returns>
|
||||
public bool SupportsWaveFormat(SupportedWaveFormat waveFormat)
|
||||
{
|
||||
return (supportedFormats & waveFormat) == waveFormat;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The device name Guid (if provided)
|
||||
/// </summary>
|
||||
public Guid NameGuid { get { return nameGuid; } }
|
||||
/// <summary>
|
||||
/// The product name Guid (if provided)
|
||||
/// </summary>
|
||||
public Guid ProductGuid { get { return productGuid; } }
|
||||
/// <summary>
|
||||
/// The manufacturer guid (if provided)
|
||||
/// </summary>
|
||||
public Guid ManufacturerGuid { get { return manufacturerGuid; } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supported wave formats for WaveOutCapabilities
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SupportedWaveFormat
|
||||
{
|
||||
/// <summary>
|
||||
/// 11.025 kHz, Mono, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_1M08 = 0x00000001,
|
||||
/// <summary>
|
||||
/// 11.025 kHz, Stereo, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_1S08 = 0x00000002,
|
||||
/// <summary>
|
||||
/// 11.025 kHz, Mono, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_1M16 = 0x00000004,
|
||||
/// <summary>
|
||||
/// 11.025 kHz, Stereo, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_1S16 = 0x00000008,
|
||||
/// <summary>
|
||||
/// 22.05 kHz, Mono, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_2M08 = 0x00000010,
|
||||
/// <summary>
|
||||
/// 22.05 kHz, Stereo, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_2S08 = 0x00000020,
|
||||
/// <summary>
|
||||
/// 22.05 kHz, Mono, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_2M16 = 0x00000040,
|
||||
/// <summary>
|
||||
/// 22.05 kHz, Stereo, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_2S16 = 0x00000080,
|
||||
/// <summary>
|
||||
/// 44.1 kHz, Mono, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_4M08 = 0x00000100,
|
||||
/// <summary>
|
||||
/// 44.1 kHz, Stereo, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_4S08 = 0x00000200,
|
||||
/// <summary>
|
||||
/// 44.1 kHz, Mono, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_4M16 = 0x00000400,
|
||||
/// <summary>
|
||||
/// 44.1 kHz, Stereo, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_4S16 = 0x00000800,
|
||||
|
||||
/// <summary>
|
||||
/// 44.1 kHz, Mono, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_44M08 = 0x00000100,
|
||||
/// <summary>
|
||||
/// 44.1 kHz, Stereo, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_44S08 = 0x00000200,
|
||||
/// <summary>
|
||||
/// 44.1 kHz, Mono, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_44M16 = 0x00000400,
|
||||
/// <summary>
|
||||
/// 44.1 kHz, Stereo, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_44S16 = 0x00000800,
|
||||
/// <summary>
|
||||
/// 48 kHz, Mono, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_48M08 = 0x00001000,
|
||||
/// <summary>
|
||||
/// 48 kHz, Stereo, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_48S08 = 0x00002000,
|
||||
/// <summary>
|
||||
/// 48 kHz, Mono, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_48M16 = 0x00004000,
|
||||
/// <summary>
|
||||
/// 48 kHz, Stereo, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_48S16 = 0x00008000,
|
||||
/// <summary>
|
||||
/// 96 kHz, Mono, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_96M08 = 0x00010000,
|
||||
/// <summary>
|
||||
/// 96 kHz, Stereo, 8-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_96S08 = 0x00020000,
|
||||
/// <summary>
|
||||
/// 96 kHz, Mono, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_96M16 = 0x00040000,
|
||||
/// <summary>
|
||||
/// 96 kHz, Stereo, 16-bit
|
||||
/// </summary>
|
||||
WAVE_FORMAT_96S16 = 0x00080000,
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b24aab35c26818f4689ae457056accbc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio.Wave
|
||||
{
|
||||
/// <summary>
|
||||
/// Flags indicating what features this WaveOut device supports
|
||||
/// </summary>
|
||||
[Flags]
|
||||
enum WaveOutSupport
|
||||
{
|
||||
/// <summary>supports pitch control (WAVECAPS_PITCH)</summary>
|
||||
Pitch = 0x0001,
|
||||
/// <summary>supports playback rate control (WAVECAPS_PLAYBACKRATE)</summary>
|
||||
PlaybackRate = 0x0002,
|
||||
/// <summary>supports volume control (WAVECAPS_VOLUME)</summary>
|
||||
Volume = 0x0004,
|
||||
/// <summary>supports separate left-right volume control (WAVECAPS_LRVOLUME)</summary>
|
||||
LRVolume = 0x0008,
|
||||
/// <summary>(WAVECAPS_SYNC)</summary>
|
||||
Sync = 0x0010,
|
||||
/// <summary>(WAVECAPS_SAMPLEACCURATE)</summary>
|
||||
SampleAccurate = 0x0020,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d9f9c23c44c5124d8dfd060da7c38e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c75302961bf09ee459f50ffe7b3c2a7d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Sample provider interface to make WaveChannel32 extensible
|
||||
/// Still a bit ugly, hence internal at the moment - and might even make these into
|
||||
/// bit depth converting WaveProviders
|
||||
/// </summary>
|
||||
interface ISampleChunkConverter
|
||||
{
|
||||
bool Supports(WaveFormat format);
|
||||
void LoadNextChunk(IWaveProvider sourceProvider, int samplePairsRequired);
|
||||
bool GetNextSample(out float sampleLeft, out float sampleRight);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 416b656fffb4c2346963663dca960f42
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
class Mono16SampleChunkConverter : ISampleChunkConverter
|
||||
{
|
||||
private int sourceSample;
|
||||
private byte[] sourceBuffer;
|
||||
private WaveBuffer sourceWaveBuffer;
|
||||
private int sourceSamples;
|
||||
|
||||
public bool Supports(WaveFormat waveFormat)
|
||||
{
|
||||
return waveFormat.Encoding == WaveFormatEncoding.Pcm &&
|
||||
waveFormat.BitsPerSample == 16 &&
|
||||
waveFormat.Channels == 1;
|
||||
}
|
||||
|
||||
public void LoadNextChunk(IWaveProvider source, int samplePairsRequired)
|
||||
{
|
||||
int sourceBytesRequired = samplePairsRequired * 2;
|
||||
sourceSample = 0;
|
||||
sourceBuffer = BufferHelpers.Ensure(sourceBuffer, sourceBytesRequired);
|
||||
sourceWaveBuffer = new WaveBuffer(sourceBuffer);
|
||||
sourceSamples = source.Read(sourceBuffer, 0, sourceBytesRequired) / 2;
|
||||
}
|
||||
|
||||
public bool GetNextSample(out float sampleLeft, out float sampleRight)
|
||||
{
|
||||
if (sourceSample < sourceSamples)
|
||||
{
|
||||
sampleLeft = sourceWaveBuffer.ShortBuffer[sourceSample++] / 32768.0f;
|
||||
sampleRight = sampleLeft;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleLeft = 0.0f;
|
||||
sampleRight = 0.0f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 031a2d3c303c50c47b82deed482e8b8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
class Mono24SampleChunkConverter : ISampleChunkConverter
|
||||
{
|
||||
private int offset;
|
||||
private byte[] sourceBuffer;
|
||||
private int sourceBytes;
|
||||
|
||||
public bool Supports(WaveFormat waveFormat)
|
||||
{
|
||||
return waveFormat.Encoding == WaveFormatEncoding.Pcm &&
|
||||
waveFormat.BitsPerSample == 24 &&
|
||||
waveFormat.Channels == 1;
|
||||
}
|
||||
|
||||
public void LoadNextChunk(IWaveProvider source, int samplePairsRequired)
|
||||
{
|
||||
int sourceBytesRequired = samplePairsRequired * 3;
|
||||
sourceBuffer = BufferHelpers.Ensure(sourceBuffer,sourceBytesRequired);
|
||||
sourceBytes = source.Read(sourceBuffer, 0, sourceBytesRequired);
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
public bool GetNextSample(out float sampleLeft, out float sampleRight)
|
||||
{
|
||||
if (offset < sourceBytes)
|
||||
{
|
||||
sampleLeft = (((sbyte)sourceBuffer[offset + 2] << 16) | (sourceBuffer[offset + 1] << 8) | sourceBuffer[offset]) / 8388608f;
|
||||
offset += 3;
|
||||
sampleRight = sampleLeft;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleLeft = 0.0f;
|
||||
sampleRight = 0.0f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 232cfe62ac0c78348939009e7d623cb5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
class Mono8SampleChunkConverter : ISampleChunkConverter
|
||||
{
|
||||
private int offset;
|
||||
private byte[] sourceBuffer;
|
||||
private int sourceBytes;
|
||||
|
||||
public bool Supports(WaveFormat waveFormat)
|
||||
{
|
||||
return waveFormat.Encoding == WaveFormatEncoding.Pcm &&
|
||||
waveFormat.BitsPerSample == 8 &&
|
||||
waveFormat.Channels == 1;
|
||||
}
|
||||
|
||||
public void LoadNextChunk(IWaveProvider source, int samplePairsRequired)
|
||||
{
|
||||
int sourceBytesRequired = samplePairsRequired;
|
||||
sourceBuffer = BufferHelpers.Ensure(sourceBuffer, sourceBytesRequired);
|
||||
sourceBytes = source.Read(sourceBuffer, 0, sourceBytesRequired);
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
public bool GetNextSample(out float sampleLeft, out float sampleRight)
|
||||
{
|
||||
if (offset < sourceBytes)
|
||||
{
|
||||
sampleLeft = sourceBuffer[offset] / 256f;
|
||||
offset++;
|
||||
sampleRight = sampleLeft;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleLeft = 0.0f;
|
||||
sampleRight = 0.0f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a69c513c13ad82b43b712f0651de2fd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
class MonoFloatSampleChunkConverter : ISampleChunkConverter
|
||||
{
|
||||
private int sourceSample;
|
||||
private byte[] sourceBuffer;
|
||||
private WaveBuffer sourceWaveBuffer;
|
||||
private int sourceSamples;
|
||||
|
||||
public bool Supports(WaveFormat waveFormat)
|
||||
{
|
||||
return waveFormat.Encoding == WaveFormatEncoding.IeeeFloat &&
|
||||
waveFormat.Channels == 1;
|
||||
}
|
||||
|
||||
public void LoadNextChunk(IWaveProvider source, int samplePairsRequired)
|
||||
{
|
||||
int sourceBytesRequired = samplePairsRequired * 4;
|
||||
sourceBuffer = BufferHelpers.Ensure(sourceBuffer, sourceBytesRequired);
|
||||
sourceWaveBuffer = new WaveBuffer(sourceBuffer);
|
||||
sourceSamples = source.Read(sourceBuffer, 0, sourceBytesRequired) / 4;
|
||||
sourceSample = 0;
|
||||
}
|
||||
|
||||
public bool GetNextSample(out float sampleLeft, out float sampleRight)
|
||||
{
|
||||
if (sourceSample < sourceSamples)
|
||||
{
|
||||
sampleLeft = sourceWaveBuffer.FloatBuffer[sourceSample++];
|
||||
sampleRight = sampleLeft;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleLeft = 0.0f;
|
||||
sampleRight = 0.0f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc285f33126969843a8a1be86ca1afcf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
class Stereo16SampleChunkConverter : ISampleChunkConverter
|
||||
{
|
||||
private int sourceSample;
|
||||
private byte[] sourceBuffer;
|
||||
private WaveBuffer sourceWaveBuffer;
|
||||
private int sourceSamples;
|
||||
|
||||
public bool Supports(WaveFormat waveFormat)
|
||||
{
|
||||
return waveFormat.Encoding == WaveFormatEncoding.Pcm &&
|
||||
waveFormat.BitsPerSample == 16 &&
|
||||
waveFormat.Channels == 2;
|
||||
}
|
||||
|
||||
public void LoadNextChunk(IWaveProvider source, int samplePairsRequired)
|
||||
{
|
||||
int sourceBytesRequired = samplePairsRequired * 4;
|
||||
sourceBuffer = BufferHelpers.Ensure(sourceBuffer, sourceBytesRequired);
|
||||
sourceWaveBuffer = new WaveBuffer(sourceBuffer);
|
||||
sourceSamples = source.Read(sourceBuffer, 0, sourceBytesRequired) / 2;
|
||||
sourceSample = 0;
|
||||
}
|
||||
|
||||
public bool GetNextSample(out float sampleLeft, out float sampleRight)
|
||||
{
|
||||
if (sourceSample < sourceSamples)
|
||||
{
|
||||
sampleLeft = sourceWaveBuffer.ShortBuffer[sourceSample++] / 32768.0f;
|
||||
sampleRight = sourceWaveBuffer.ShortBuffer[sourceSample++] / 32768.0f;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleLeft = 0.0f;
|
||||
sampleRight = 0.0f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1852c7291b1fa240b34865aed4ec293
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
class Stereo24SampleChunkConverter : ISampleChunkConverter
|
||||
{
|
||||
private int offset;
|
||||
private byte[] sourceBuffer;
|
||||
private int sourceBytes;
|
||||
|
||||
public bool Supports(WaveFormat waveFormat)
|
||||
{
|
||||
return waveFormat.Encoding == WaveFormatEncoding.Pcm &&
|
||||
waveFormat.BitsPerSample == 24 &&
|
||||
waveFormat.Channels == 2;
|
||||
}
|
||||
|
||||
|
||||
public void LoadNextChunk(IWaveProvider source, int samplePairsRequired)
|
||||
{
|
||||
int sourceBytesRequired = samplePairsRequired * 6;
|
||||
sourceBuffer = BufferHelpers.Ensure(sourceBuffer, sourceBytesRequired);
|
||||
sourceBytes = source.Read(sourceBuffer, 0, sourceBytesRequired);
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
public bool GetNextSample(out float sampleLeft, out float sampleRight)
|
||||
{
|
||||
if (offset < sourceBytes)
|
||||
{
|
||||
sampleLeft = (((sbyte)sourceBuffer[offset + 2] << 16) | (sourceBuffer[offset + 1] << 8) | sourceBuffer[offset]) / 8388608f;
|
||||
offset += 3;
|
||||
sampleRight = (((sbyte)sourceBuffer[offset + 2] << 16) | (sourceBuffer[offset + 1] << 8) | sourceBuffer[offset]) / 8388608f;
|
||||
offset += 3;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleLeft = 0.0f;
|
||||
sampleRight = 0.0f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8af114d8042c874d86f9a443b29ca47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
class Stereo8SampleChunkConverter : ISampleChunkConverter
|
||||
{
|
||||
private int offset;
|
||||
private byte[] sourceBuffer;
|
||||
private int sourceBytes;
|
||||
|
||||
public bool Supports(WaveFormat waveFormat)
|
||||
{
|
||||
return waveFormat.Encoding == WaveFormatEncoding.Pcm &&
|
||||
waveFormat.BitsPerSample == 8 &&
|
||||
waveFormat.Channels == 2;
|
||||
}
|
||||
|
||||
public void LoadNextChunk(IWaveProvider source, int samplePairsRequired)
|
||||
{
|
||||
int sourceBytesRequired = samplePairsRequired * 2;
|
||||
sourceBuffer = BufferHelpers.Ensure(sourceBuffer, sourceBytesRequired);
|
||||
sourceBytes = source.Read(sourceBuffer, 0, sourceBytesRequired);
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
public bool GetNextSample(out float sampleLeft, out float sampleRight)
|
||||
{
|
||||
if (offset < sourceBytes)
|
||||
{
|
||||
sampleLeft = sourceBuffer[offset++] / 256f;
|
||||
sampleRight = sourceBuffer[offset++] / 256f;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleLeft = 0.0f;
|
||||
sampleRight = 0.0f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fc6553aaf756474491232dbaab50cb4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
class StereoFloatSampleChunkConverter : ISampleChunkConverter
|
||||
{
|
||||
private int sourceSample;
|
||||
private byte[] sourceBuffer;
|
||||
private WaveBuffer sourceWaveBuffer;
|
||||
private int sourceSamples;
|
||||
|
||||
public bool Supports(WaveFormat waveFormat)
|
||||
{
|
||||
return waveFormat.Encoding == WaveFormatEncoding.IeeeFloat &&
|
||||
waveFormat.Channels == 2;
|
||||
}
|
||||
|
||||
public void LoadNextChunk(IWaveProvider source, int samplePairsRequired)
|
||||
{
|
||||
int sourceBytesRequired = samplePairsRequired * 8;
|
||||
sourceBuffer = BufferHelpers.Ensure(sourceBuffer, sourceBytesRequired);
|
||||
sourceWaveBuffer = new WaveBuffer(sourceBuffer);
|
||||
sourceSamples = source.Read(sourceBuffer, 0, sourceBytesRequired) / 4;
|
||||
sourceSample = 0;
|
||||
}
|
||||
|
||||
public bool GetNextSample(out float sampleLeft, out float sampleRight)
|
||||
{
|
||||
if (sourceSample < sourceSamples)
|
||||
{
|
||||
sampleLeft = sourceWaveBuffer.FloatBuffer[sourceSample++];
|
||||
sampleRight = sourceWaveBuffer.FloatBuffer[sourceSample++];
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleLeft = 0.0f;
|
||||
sampleRight = 0.0f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8ab0680aa0b34b4087b74d1de14c4a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e99d36d907668354589d821d9ef85ef3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NAudio.Dsp;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// ADSR sample provider allowing you to specify attack, decay, sustain and release values
|
||||
/// </summary>
|
||||
public class AdsrSampleProvider : ISampleProvider
|
||||
{
|
||||
private readonly ISampleProvider source;
|
||||
private readonly EnvelopeGenerator adsr;
|
||||
private float attackSeconds;
|
||||
private float releaseSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new AdsrSampleProvider with default values
|
||||
/// </summary>
|
||||
public AdsrSampleProvider(ISampleProvider source)
|
||||
{
|
||||
if (source.WaveFormat.Channels > 1) throw new ArgumentException("Currently only supports mono inputs");
|
||||
this.source = source;
|
||||
adsr = new EnvelopeGenerator();
|
||||
AttackSeconds = 0.01f;
|
||||
adsr.SustainLevel = 1.0f;
|
||||
adsr.DecayRate = 0.0f * WaveFormat.SampleRate;
|
||||
ReleaseSeconds = 0.3f;
|
||||
adsr.Gate(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attack time in seconds
|
||||
/// </summary>
|
||||
public float AttackSeconds
|
||||
{
|
||||
get
|
||||
{
|
||||
return attackSeconds;
|
||||
}
|
||||
set
|
||||
{
|
||||
attackSeconds = value;
|
||||
adsr.AttackRate = attackSeconds * WaveFormat.SampleRate;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Release time in seconds
|
||||
/// </summary>
|
||||
public float ReleaseSeconds
|
||||
{
|
||||
get
|
||||
{
|
||||
return releaseSeconds;
|
||||
}
|
||||
set
|
||||
{
|
||||
releaseSeconds = value;
|
||||
adsr.ReleaseRate = releaseSeconds * WaveFormat.SampleRate;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads audio from this sample provider
|
||||
/// </summary>
|
||||
public int Read(float[] buffer, int offset, int count)
|
||||
{
|
||||
if (adsr.State == EnvelopeGenerator.EnvelopeState.Idle) return 0; // we've finished
|
||||
var samples = source.Read(buffer, offset, count);
|
||||
for (int n = 0; n < samples; n++)
|
||||
{
|
||||
buffer[offset++] *= adsr.Process();
|
||||
}
|
||||
return samples;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enters the Release phase
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
adsr.Gate(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The output WaveFormat
|
||||
/// </summary>
|
||||
public WaveFormat WaveFormat { get { return source.WaveFormat; } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8238d9b8302f184bbc42343a5bcae18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Sample Provider to concatenate multiple sample providers together
|
||||
/// </summary>
|
||||
public class ConcatenatingSampleProvider : ISampleProvider
|
||||
{
|
||||
private readonly ISampleProvider[] providers;
|
||||
private int currentProviderIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new ConcatenatingSampleProvider
|
||||
/// </summary>
|
||||
/// <param name="providers">The source providers to play one after the other. Must all share the same sample rate and channel count</param>
|
||||
public ConcatenatingSampleProvider(IEnumerable<ISampleProvider> providers)
|
||||
{
|
||||
if (providers == null) throw new ArgumentNullException(nameof(providers));
|
||||
this.providers = providers.ToArray();
|
||||
if (this.providers.Length == 0) throw new ArgumentException("Must provide at least one input", nameof(providers));
|
||||
if (this.providers.Any(p => p.WaveFormat.Channels != WaveFormat.Channels)) throw new ArgumentException("All inputs must have the same channel count", nameof(providers));
|
||||
if (this.providers.Any(p => p.WaveFormat.SampleRate != WaveFormat.SampleRate)) throw new ArgumentException("All inputs must have the same sample rate", nameof(providers));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The WaveFormat of this Sample Provider
|
||||
/// </summary>
|
||||
public WaveFormat WaveFormat => providers[0].WaveFormat;
|
||||
|
||||
/// <summary>
|
||||
/// Read Samples from this sample provider
|
||||
/// </summary>
|
||||
public int Read(float[] buffer, int offset, int count)
|
||||
{
|
||||
var read = 0;
|
||||
while (read < count && currentProviderIndex < providers.Length)
|
||||
{
|
||||
var needed = count - read;
|
||||
var readThisTime = providers[currentProviderIndex].Read(buffer, read, needed);
|
||||
read += readThisTime;
|
||||
if (readThisTime == 0) currentProviderIndex++;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d3fca0e460be5f439d504fec52984e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,146 @@
|
||||
namespace NAudio.Wave.SampleProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Sample Provider to allow fading in and out
|
||||
/// </summary>
|
||||
public class FadeInOutSampleProvider : ISampleProvider
|
||||
{
|
||||
enum FadeState
|
||||
{
|
||||
Silence,
|
||||
FadingIn,
|
||||
FullVolume,
|
||||
FadingOut,
|
||||
}
|
||||
|
||||
private readonly object lockObject = new object();
|
||||
private readonly ISampleProvider source;
|
||||
private int fadeSamplePosition;
|
||||
private int fadeSampleCount;
|
||||
private FadeState fadeState;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new FadeInOutSampleProvider
|
||||
/// </summary>
|
||||
/// <param name="source">The source stream with the audio to be faded in or out</param>
|
||||
/// <param name="initiallySilent">If true, we start faded out</param>
|
||||
public FadeInOutSampleProvider(ISampleProvider source, bool initiallySilent = false)
|
||||
{
|
||||
this.source = source;
|
||||
fadeState = initiallySilent ? FadeState.Silence : FadeState.FullVolume;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests that a fade-in begins (will start on the next call to Read)
|
||||
/// </summary>
|
||||
/// <param name="fadeDurationInMilliseconds">Duration of fade in milliseconds</param>
|
||||
public void BeginFadeIn(double fadeDurationInMilliseconds)
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
fadeSamplePosition = 0;
|
||||
fadeSampleCount = (int)((fadeDurationInMilliseconds * source.WaveFormat.SampleRate) / 1000);
|
||||
fadeState = FadeState.FadingIn;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests that a fade-out begins (will start on the next call to Read)
|
||||
/// </summary>
|
||||
/// <param name="fadeDurationInMilliseconds">Duration of fade in milliseconds</param>
|
||||
public void BeginFadeOut(double fadeDurationInMilliseconds)
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
fadeSamplePosition = 0;
|
||||
fadeSampleCount = (int)((fadeDurationInMilliseconds * source.WaveFormat.SampleRate) / 1000);
|
||||
fadeState = FadeState.FadingOut;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads samples from this sample provider
|
||||
/// </summary>
|
||||
/// <param name="buffer">Buffer to read into</param>
|
||||
/// <param name="offset">Offset within buffer to write to</param>
|
||||
/// <param name="count">Number of samples desired</param>
|
||||
/// <returns>Number of samples read</returns>
|
||||
public int Read(float[] buffer, int offset, int count)
|
||||
{
|
||||
int sourceSamplesRead = source.Read(buffer, offset, count);
|
||||
lock (lockObject)
|
||||
{
|
||||
if (fadeState == FadeState.FadingIn)
|
||||
{
|
||||
FadeIn(buffer, offset, sourceSamplesRead);
|
||||
}
|
||||
else if (fadeState == FadeState.FadingOut)
|
||||
{
|
||||
FadeOut(buffer, offset, sourceSamplesRead);
|
||||
}
|
||||
else if (fadeState == FadeState.Silence)
|
||||
{
|
||||
ClearBuffer(buffer, offset, count);
|
||||
}
|
||||
}
|
||||
return sourceSamplesRead;
|
||||
}
|
||||
|
||||
private static void ClearBuffer(float[] buffer, int offset, int count)
|
||||
{
|
||||
for (int n = 0; n < count; n++)
|
||||
{
|
||||
buffer[n + offset] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void FadeOut(float[] buffer, int offset, int sourceSamplesRead)
|
||||
{
|
||||
int sample = 0;
|
||||
while (sample < sourceSamplesRead)
|
||||
{
|
||||
float multiplier = 1.0f - (fadeSamplePosition / (float)fadeSampleCount);
|
||||
for (int ch = 0; ch < source.WaveFormat.Channels; ch++)
|
||||
{
|
||||
buffer[offset + sample++] *= multiplier;
|
||||
}
|
||||
fadeSamplePosition++;
|
||||
if (fadeSamplePosition > fadeSampleCount)
|
||||
{
|
||||
fadeState = FadeState.Silence;
|
||||
// clear out the end
|
||||
ClearBuffer(buffer, sample + offset, sourceSamplesRead - sample);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FadeIn(float[] buffer, int offset, int sourceSamplesRead)
|
||||
{
|
||||
int sample = 0;
|
||||
while (sample < sourceSamplesRead)
|
||||
{
|
||||
float multiplier = (fadeSamplePosition / (float)fadeSampleCount);
|
||||
for (int ch = 0; ch < source.WaveFormat.Channels; ch++)
|
||||
{
|
||||
buffer[offset + sample++] *= multiplier;
|
||||
}
|
||||
fadeSamplePosition++;
|
||||
if (fadeSamplePosition > fadeSampleCount)
|
||||
{
|
||||
fadeState = FadeState.FullVolume;
|
||||
// no need to multiply any more
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WaveFormat of this SampleProvider
|
||||
/// </summary>
|
||||
public WaveFormat WaveFormat
|
||||
{
|
||||
get { return source.WaveFormat; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c31478154d4ad8f4cb7a179b9e04ec54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user