Remove Android platform support
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c0b0ac3e281b3f4c87f02a42e65baad
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9b61cdfbf5ba6a48a953e6db3db5905
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53e0959db419cbb4ebe8833103de3901
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,63 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Codecs
|
||||
{
|
||||
/// <summary>
|
||||
/// a-law decoder
|
||||
/// based on code from:
|
||||
/// http://hazelware.luggle.com/tutorials/mulawcompression.html
|
||||
/// </summary>
|
||||
public class ALawDecoder
|
||||
{
|
||||
/// <summary>
|
||||
/// only 512 bytes required, so just use a lookup
|
||||
/// </summary>
|
||||
private static readonly short[] ALawDecompressTable = new short[256]
|
||||
{
|
||||
-5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
|
||||
-7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
|
||||
-2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
|
||||
-3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
|
||||
-22016,-20992,-24064,-23040,-17920,-16896,-19968,-18944,
|
||||
-30208,-29184,-32256,-31232,-26112,-25088,-28160,-27136,
|
||||
-11008,-10496,-12032,-11520,-8960, -8448, -9984, -9472,
|
||||
-15104,-14592,-16128,-15616,-13056,-12544,-14080,-13568,
|
||||
-344, -328, -376, -360, -280, -264, -312, -296,
|
||||
-472, -456, -504, -488, -408, -392, -440, -424,
|
||||
-88, -72, -120, -104, -24, -8, -56, -40,
|
||||
-216, -200, -248, -232, -152, -136, -184, -168,
|
||||
-1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
|
||||
-1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
|
||||
-688, -656, -752, -720, -560, -528, -624, -592,
|
||||
-944, -912, -1008, -976, -816, -784, -880, -848,
|
||||
5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
|
||||
7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
|
||||
2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
|
||||
3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
|
||||
22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
|
||||
30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
|
||||
11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
|
||||
15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
|
||||
344, 328, 376, 360, 280, 264, 312, 296,
|
||||
472, 456, 504, 488, 408, 392, 440, 424,
|
||||
88, 72, 120, 104, 24, 8, 56, 40,
|
||||
216, 200, 248, 232, 152, 136, 184, 168,
|
||||
1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
|
||||
1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
|
||||
688, 656, 752, 720, 560, 528, 624, 592,
|
||||
944, 912, 1008, 976, 816, 784, 880, 848
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converts an a-law encoded byte to a 16 bit linear sample
|
||||
/// </summary>
|
||||
/// <param name="aLaw">a-law encoded byte</param>
|
||||
/// <returns>Linear sample</returns>
|
||||
public static short ALawToLinearSample(byte aLaw)
|
||||
{
|
||||
return ALawDecompressTable[aLaw];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c7731fd64041bc4ca69a7004c59d6c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Codecs
|
||||
{
|
||||
/// <summary>
|
||||
/// A-law encoder
|
||||
/// </summary>
|
||||
public static class ALawEncoder
|
||||
{
|
||||
private const int cBias = 0x84;
|
||||
private const int cClip = 32635;
|
||||
private static readonly byte[] ALawCompressTable = new byte[128]
|
||||
{
|
||||
1,1,2,2,3,3,3,3,
|
||||
4,4,4,4,4,4,4,4,
|
||||
5,5,5,5,5,5,5,5,
|
||||
5,5,5,5,5,5,5,5,
|
||||
6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,
|
||||
7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Encodes a single 16 bit sample to a-law
|
||||
/// </summary>
|
||||
/// <param name="sample">16 bit PCM sample</param>
|
||||
/// <returns>a-law encoded byte</returns>
|
||||
public static byte LinearToALawSample(short sample)
|
||||
{
|
||||
int sign;
|
||||
int exponent;
|
||||
int mantissa;
|
||||
byte compressedByte;
|
||||
|
||||
sign = ((~sample) >> 8) & 0x80;
|
||||
if (sign == 0)
|
||||
sample = (short)-sample;
|
||||
if (sample > cClip)
|
||||
sample = cClip;
|
||||
if (sample >= 256)
|
||||
{
|
||||
exponent = (int)ALawCompressTable[(sample >> 8) & 0x7F];
|
||||
mantissa = (sample >> (exponent + 3)) & 0x0F;
|
||||
compressedByte = (byte)((exponent << 4) | mantissa);
|
||||
}
|
||||
else
|
||||
{
|
||||
compressedByte = (byte)(sample >> 4);
|
||||
}
|
||||
compressedByte ^= (byte)(sign ^ 0x55);
|
||||
return compressedByte;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49601f5ceda3d7d4abc37b0c09532fb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,628 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.Codecs
|
||||
{
|
||||
/// <summary>
|
||||
/// SpanDSP - a series of DSP components for telephony
|
||||
///
|
||||
/// g722_decode.c - The ITU G.722 codec, decode part.
|
||||
///
|
||||
/// Written by Steve Underwood <steveu@coppice.org>
|
||||
///
|
||||
/// Copyright (C) 2005 Steve Underwood
|
||||
/// Ported to C# by Mark Heath 2011
|
||||
///
|
||||
/// Despite my general liking of the GPL, I place my own contributions
|
||||
/// to this code in the public domain for the benefit of all mankind -
|
||||
/// even the slimy ones who might try to proprietize my work and use it
|
||||
/// to my detriment.
|
||||
///
|
||||
/// Based in part on a single channel G.722 codec which is:
|
||||
/// Copyright (c) CMU 1993
|
||||
/// Computer Science, Speech Group
|
||||
/// Chengxiang Lu and Alex Hauptmann
|
||||
/// </summary>
|
||||
public class G722Codec
|
||||
{
|
||||
/// <summary>
|
||||
/// hard limits to 16 bit samples
|
||||
/// </summary>
|
||||
static short Saturate(int amp)
|
||||
{
|
||||
short amp16;
|
||||
|
||||
// Hopefully this is optimised for the common case - not clipping
|
||||
amp16 = (short)amp;
|
||||
if (amp == amp16)
|
||||
return amp16;
|
||||
if (amp > Int16.MaxValue)
|
||||
return Int16.MaxValue;
|
||||
return Int16.MinValue;
|
||||
}
|
||||
|
||||
static void Block4(G722CodecState s, int band, int d)
|
||||
{
|
||||
int wd1;
|
||||
int wd2;
|
||||
int wd3;
|
||||
int i;
|
||||
|
||||
// Block 4, RECONS
|
||||
s.Band[band].d[0] = d;
|
||||
s.Band[band].r[0] = Saturate(s.Band[band].s + d);
|
||||
|
||||
// Block 4, PARREC
|
||||
s.Band[band].p[0] = Saturate(s.Band[band].sz + d);
|
||||
|
||||
// Block 4, UPPOL2
|
||||
for (i = 0; i < 3; i++)
|
||||
s.Band[band].sg[i] = s.Band[band].p[i] >> 15;
|
||||
wd1 = Saturate(s.Band[band].a[1] << 2);
|
||||
|
||||
wd2 = (s.Band[band].sg[0] == s.Band[band].sg[1]) ? -wd1 : wd1;
|
||||
if (wd2 > 32767)
|
||||
wd2 = 32767;
|
||||
wd3 = (s.Band[band].sg[0] == s.Band[band].sg[2]) ? 128 : -128;
|
||||
wd3 += (wd2 >> 7);
|
||||
wd3 += (s.Band[band].a[2] * 32512) >> 15;
|
||||
if (wd3 > 12288)
|
||||
wd3 = 12288;
|
||||
else if (wd3 < -12288)
|
||||
wd3 = -12288;
|
||||
s.Band[band].ap[2] = wd3;
|
||||
|
||||
// Block 4, UPPOL1
|
||||
s.Band[band].sg[0] = s.Band[band].p[0] >> 15;
|
||||
s.Band[band].sg[1] = s.Band[band].p[1] >> 15;
|
||||
wd1 = (s.Band[band].sg[0] == s.Band[band].sg[1]) ? 192 : -192;
|
||||
wd2 = (s.Band[band].a[1] * 32640) >> 15;
|
||||
|
||||
s.Band[band].ap[1] = Saturate(wd1 + wd2);
|
||||
wd3 = Saturate(15360 - s.Band[band].ap[2]);
|
||||
if (s.Band[band].ap[1] > wd3)
|
||||
s.Band[band].ap[1] = wd3;
|
||||
else if (s.Band[band].ap[1] < -wd3)
|
||||
s.Band[band].ap[1] = -wd3;
|
||||
|
||||
// Block 4, UPZERO
|
||||
wd1 = (d == 0) ? 0 : 128;
|
||||
s.Band[band].sg[0] = d >> 15;
|
||||
for (i = 1; i < 7; i++)
|
||||
{
|
||||
s.Band[band].sg[i] = s.Band[band].d[i] >> 15;
|
||||
wd2 = (s.Band[band].sg[i] == s.Band[band].sg[0]) ? wd1 : -wd1;
|
||||
wd3 = (s.Band[band].b[i] * 32640) >> 15;
|
||||
s.Band[band].bp[i] = Saturate(wd2 + wd3);
|
||||
}
|
||||
|
||||
// Block 4, DELAYA
|
||||
for (i = 6; i > 0; i--)
|
||||
{
|
||||
s.Band[band].d[i] = s.Band[band].d[i - 1];
|
||||
s.Band[band].b[i] = s.Band[band].bp[i];
|
||||
}
|
||||
|
||||
for (i = 2; i > 0; i--)
|
||||
{
|
||||
s.Band[band].r[i] = s.Band[band].r[i - 1];
|
||||
s.Band[band].p[i] = s.Band[band].p[i - 1];
|
||||
s.Band[band].a[i] = s.Band[band].ap[i];
|
||||
}
|
||||
|
||||
// Block 4, FILTEP
|
||||
wd1 = Saturate(s.Band[band].r[1] + s.Band[band].r[1]);
|
||||
wd1 = (s.Band[band].a[1] * wd1) >> 15;
|
||||
wd2 = Saturate(s.Band[band].r[2] + s.Band[band].r[2]);
|
||||
wd2 = (s.Band[band].a[2] * wd2) >> 15;
|
||||
s.Band[band].sp = Saturate(wd1 + wd2);
|
||||
|
||||
// Block 4, FILTEZ
|
||||
s.Band[band].sz = 0;
|
||||
for (i = 6; i > 0; i--)
|
||||
{
|
||||
wd1 = Saturate(s.Band[band].d[i] + s.Band[band].d[i]);
|
||||
s.Band[band].sz += (s.Band[band].b[i] * wd1) >> 15;
|
||||
}
|
||||
s.Band[band].sz = Saturate(s.Band[band].sz);
|
||||
|
||||
// Block 4, PREDIC
|
||||
s.Band[band].s = Saturate(s.Band[band].sp + s.Band[band].sz);
|
||||
}
|
||||
|
||||
static readonly int[] wl = { -60, -30, 58, 172, 334, 538, 1198, 3042 };
|
||||
static readonly int[] rl42 = { 0, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 0 };
|
||||
static readonly int[] ilb = { 2048, 2093, 2139, 2186, 2233, 2282, 2332, 2383, 2435, 2489, 2543, 2599, 2656, 2714, 2774, 2834, 2896, 2960, 3025, 3091, 3158, 3228, 3298, 3371, 3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008 };
|
||||
static readonly int[] wh = { 0, -214, 798 };
|
||||
static readonly int[] rh2 = { 2, 1, 2, 1 };
|
||||
static readonly int[] qm2 = { -7408, -1616, 7408, 1616 };
|
||||
static readonly int[] qm4 = { 0, -20456, -12896, -8968, -6288, -4240, -2584, -1200, 20456, 12896, 8968, 6288, 4240, 2584, 1200, 0 };
|
||||
static readonly int[] qm5 = { -280, -280, -23352, -17560, -14120, -11664, -9752, -8184, -6864, -5712, -4696, -3784, -2960, -2208, -1520, -880, 23352, 17560, 14120, 11664, 9752, 8184, 6864, 5712, 4696, 3784, 2960, 2208, 1520, 880, 280, -280 };
|
||||
static readonly int[] qm6 = { -136, -136, -136, -136, -24808, -21904, -19008, -16704, -14984, -13512, -12280, -11192, -10232, -9360, -8576, -7856, -7192, -6576, -6000, -5456, -4944, -4464, -4008, -3576, -3168, -2776, -2400, -2032, -1688, -1360, -1040, -728, 24808, 21904, 19008, 16704, 14984, 13512, 12280, 11192, 10232, 9360, 8576, 7856, 7192, 6576, 6000, 5456, 4944, 4464, 4008, 3576, 3168, 2776, 2400, 2032, 1688, 1360, 1040, 728, 432, 136, -432, -136 };
|
||||
static readonly int[] qmf_coeffs = { 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11, };
|
||||
static readonly int[] q6 = { 0, 35, 72, 110, 150, 190, 233, 276, 323, 370, 422, 473, 530, 587, 650, 714, 786, 858, 940, 1023, 1121, 1219, 1339, 1458, 1612, 1765, 1980, 2195, 2557, 2919, 0, 0 };
|
||||
static readonly int[] iln = { 0, 63, 62, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 0 };
|
||||
static readonly int[] ilp = { 0, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 0 };
|
||||
static readonly int[] ihn = { 0, 1, 0 };
|
||||
static readonly int[] ihp = { 0, 3, 2 };
|
||||
|
||||
/// <summary>
|
||||
/// Decodes a buffer of G722
|
||||
/// </summary>
|
||||
/// <param name="state">Codec state</param>
|
||||
/// <param name="outputBuffer">Output buffer (to contain decompressed PCM samples)</param>
|
||||
/// <param name="inputG722Data"></param>
|
||||
/// <param name="inputLength">Number of bytes in input G722 data to decode</param>
|
||||
/// <returns>Number of samples written into output buffer</returns>
|
||||
public int Decode(G722CodecState state, short[] outputBuffer, byte[] inputG722Data, int inputLength)
|
||||
{
|
||||
int dlowt;
|
||||
int rlow;
|
||||
int ihigh;
|
||||
int dhigh;
|
||||
int rhigh;
|
||||
int xout1;
|
||||
int xout2;
|
||||
int wd1;
|
||||
int wd2;
|
||||
int wd3;
|
||||
int code;
|
||||
int outlen;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
outlen = 0;
|
||||
rhigh = 0;
|
||||
for (j = 0; j < inputLength; )
|
||||
{
|
||||
if (state.Packed)
|
||||
{
|
||||
// Unpack the code bits
|
||||
if (state.InBits < state.BitsPerSample)
|
||||
{
|
||||
state.InBuffer |= (uint)(inputG722Data[j++] << state.InBits);
|
||||
state.InBits += 8;
|
||||
}
|
||||
code = (int)state.InBuffer & ((1 << state.BitsPerSample) - 1);
|
||||
state.InBuffer >>= state.BitsPerSample;
|
||||
state.InBits -= state.BitsPerSample;
|
||||
}
|
||||
else
|
||||
{
|
||||
code = inputG722Data[j++];
|
||||
}
|
||||
|
||||
switch (state.BitsPerSample)
|
||||
{
|
||||
default:
|
||||
case 8:
|
||||
wd1 = code & 0x3F;
|
||||
ihigh = (code >> 6) & 0x03;
|
||||
wd2 = qm6[wd1];
|
||||
wd1 >>= 2;
|
||||
break;
|
||||
case 7:
|
||||
wd1 = code & 0x1F;
|
||||
ihigh = (code >> 5) & 0x03;
|
||||
wd2 = qm5[wd1];
|
||||
wd1 >>= 1;
|
||||
break;
|
||||
case 6:
|
||||
wd1 = code & 0x0F;
|
||||
ihigh = (code >> 4) & 0x03;
|
||||
wd2 = qm4[wd1];
|
||||
break;
|
||||
}
|
||||
|
||||
// Block 5L, LOW BAND INVQBL
|
||||
wd2 = (state.Band[0].det * wd2) >> 15;
|
||||
|
||||
// Block 5L, RECONS
|
||||
rlow = state.Band[0].s + wd2;
|
||||
|
||||
// Block 6L, LIMIT
|
||||
if (rlow > 16383)
|
||||
rlow = 16383;
|
||||
else if (rlow < -16384)
|
||||
rlow = -16384;
|
||||
|
||||
// Block 2L, INVQAL
|
||||
wd2 = qm4[wd1];
|
||||
dlowt = (state.Band[0].det * wd2) >> 15;
|
||||
|
||||
// Block 3L, LOGSCL
|
||||
wd2 = rl42[wd1];
|
||||
wd1 = (state.Band[0].nb * 127) >> 7;
|
||||
wd1 += wl[wd2];
|
||||
if (wd1 < 0)
|
||||
wd1 = 0;
|
||||
else if (wd1 > 18432)
|
||||
wd1 = 18432;
|
||||
state.Band[0].nb = wd1;
|
||||
|
||||
// Block 3L, SCALEL
|
||||
wd1 = (state.Band[0].nb >> 6) & 31;
|
||||
wd2 = 8 - (state.Band[0].nb >> 11);
|
||||
wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
|
||||
state.Band[0].det = wd3 << 2;
|
||||
|
||||
Block4(state, 0, dlowt);
|
||||
|
||||
if (!state.EncodeFrom8000Hz)
|
||||
{
|
||||
// Block 2H, INVQAH
|
||||
wd2 = qm2[ihigh];
|
||||
dhigh = (state.Band[1].det * wd2) >> 15;
|
||||
|
||||
// Block 5H, RECONS
|
||||
rhigh = dhigh + state.Band[1].s;
|
||||
|
||||
// Block 6H, LIMIT
|
||||
if (rhigh > 16383)
|
||||
rhigh = 16383;
|
||||
else if (rhigh < -16384)
|
||||
rhigh = -16384;
|
||||
|
||||
// Block 2H, INVQAH
|
||||
wd2 = rh2[ihigh];
|
||||
wd1 = (state.Band[1].nb * 127) >> 7;
|
||||
wd1 += wh[wd2];
|
||||
if (wd1 < 0)
|
||||
wd1 = 0;
|
||||
else if (wd1 > 22528)
|
||||
wd1 = 22528;
|
||||
state.Band[1].nb = wd1;
|
||||
|
||||
// Block 3H, SCALEH
|
||||
wd1 = (state.Band[1].nb >> 6) & 31;
|
||||
wd2 = 10 - (state.Band[1].nb >> 11);
|
||||
wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
|
||||
state.Band[1].det = wd3 << 2;
|
||||
|
||||
Block4(state, 1, dhigh);
|
||||
}
|
||||
|
||||
if (state.ItuTestMode)
|
||||
{
|
||||
outputBuffer[outlen++] = (short)(rlow << 1);
|
||||
outputBuffer[outlen++] = (short)(rhigh << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (state.EncodeFrom8000Hz)
|
||||
{
|
||||
outputBuffer[outlen++] = (short)(rlow << 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply the receive QMF
|
||||
for (i = 0; i < 22; i++)
|
||||
state.QmfSignalHistory[i] = state.QmfSignalHistory[i + 2];
|
||||
state.QmfSignalHistory[22] = rlow + rhigh;
|
||||
state.QmfSignalHistory[23] = rlow - rhigh;
|
||||
|
||||
xout1 = 0;
|
||||
xout2 = 0;
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
xout2 += state.QmfSignalHistory[2 * i] * qmf_coeffs[i];
|
||||
xout1 += state.QmfSignalHistory[2 * i + 1] * qmf_coeffs[11 - i];
|
||||
}
|
||||
outputBuffer[outlen++] = (short)(xout1 >> 11);
|
||||
outputBuffer[outlen++] = (short)(xout2 >> 11);
|
||||
}
|
||||
}
|
||||
}
|
||||
return outlen;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encodes a buffer of G722
|
||||
/// </summary>
|
||||
/// <param name="state">Codec state</param>
|
||||
/// <param name="outputBuffer">Output buffer (to contain encoded G722)</param>
|
||||
/// <param name="inputBuffer">PCM 16 bit samples to encode</param>
|
||||
/// <param name="inputBufferCount">Number of samples in the input buffer to encode</param>
|
||||
/// <returns>Number of encoded bytes written into output buffer</returns>
|
||||
public int Encode(G722CodecState state, byte[] outputBuffer, short[] inputBuffer, int inputBufferCount)
|
||||
{
|
||||
int dlow;
|
||||
int dhigh;
|
||||
int el;
|
||||
int wd;
|
||||
int wd1;
|
||||
int ril;
|
||||
int wd2;
|
||||
int il4;
|
||||
int ih2;
|
||||
int wd3;
|
||||
int eh;
|
||||
int mih;
|
||||
int i;
|
||||
int j;
|
||||
// Low and high band PCM from the QMF
|
||||
int xlow;
|
||||
int xhigh;
|
||||
int g722_bytes;
|
||||
// Even and odd tap accumulators
|
||||
int sumeven;
|
||||
int sumodd;
|
||||
int ihigh;
|
||||
int ilow;
|
||||
int code;
|
||||
|
||||
g722_bytes = 0;
|
||||
xhigh = 0;
|
||||
for (j = 0; j < inputBufferCount; )
|
||||
{
|
||||
if (state.ItuTestMode)
|
||||
{
|
||||
xlow =
|
||||
xhigh = inputBuffer[j++] >> 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (state.EncodeFrom8000Hz)
|
||||
{
|
||||
xlow = inputBuffer[j++] >> 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply the transmit QMF
|
||||
// Shuffle the buffer down
|
||||
for (i = 0; i < 22; i++)
|
||||
state.QmfSignalHistory[i] = state.QmfSignalHistory[i + 2];
|
||||
state.QmfSignalHistory[22] = inputBuffer[j++];
|
||||
state.QmfSignalHistory[23] = inputBuffer[j++];
|
||||
|
||||
// Discard every other QMF output
|
||||
sumeven = 0;
|
||||
sumodd = 0;
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
sumodd += state.QmfSignalHistory[2 * i] * qmf_coeffs[i];
|
||||
sumeven += state.QmfSignalHistory[2 * i + 1] * qmf_coeffs[11 - i];
|
||||
}
|
||||
xlow = (sumeven + sumodd) >> 14;
|
||||
xhigh = (sumeven - sumodd) >> 14;
|
||||
}
|
||||
}
|
||||
// Block 1L, SUBTRA
|
||||
el = Saturate(xlow - state.Band[0].s);
|
||||
|
||||
// Block 1L, QUANTL
|
||||
wd = (el >= 0) ? el : -(el + 1);
|
||||
|
||||
for (i = 1; i < 30; i++)
|
||||
{
|
||||
wd1 = (q6[i] * state.Band[0].det) >> 12;
|
||||
if (wd < wd1)
|
||||
break;
|
||||
}
|
||||
ilow = (el < 0) ? iln[i] : ilp[i];
|
||||
|
||||
// Block 2L, INVQAL
|
||||
ril = ilow >> 2;
|
||||
wd2 = qm4[ril];
|
||||
dlow = (state.Band[0].det * wd2) >> 15;
|
||||
|
||||
// Block 3L, LOGSCL
|
||||
il4 = rl42[ril];
|
||||
wd = (state.Band[0].nb * 127) >> 7;
|
||||
state.Band[0].nb = wd + wl[il4];
|
||||
if (state.Band[0].nb < 0)
|
||||
state.Band[0].nb = 0;
|
||||
else if (state.Band[0].nb > 18432)
|
||||
state.Band[0].nb = 18432;
|
||||
|
||||
// Block 3L, SCALEL
|
||||
wd1 = (state.Band[0].nb >> 6) & 31;
|
||||
wd2 = 8 - (state.Band[0].nb >> 11);
|
||||
wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
|
||||
state.Band[0].det = wd3 << 2;
|
||||
|
||||
Block4(state, 0, dlow);
|
||||
|
||||
if (state.EncodeFrom8000Hz)
|
||||
{
|
||||
// Just leave the high bits as zero
|
||||
code = (0xC0 | ilow) >> (8 - state.BitsPerSample);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Block 1H, SUBTRA
|
||||
eh = Saturate(xhigh - state.Band[1].s);
|
||||
|
||||
// Block 1H, QUANTH
|
||||
wd = (eh >= 0) ? eh : -(eh + 1);
|
||||
wd1 = (564 * state.Band[1].det) >> 12;
|
||||
mih = (wd >= wd1) ? 2 : 1;
|
||||
ihigh = (eh < 0) ? ihn[mih] : ihp[mih];
|
||||
|
||||
// Block 2H, INVQAH
|
||||
wd2 = qm2[ihigh];
|
||||
dhigh = (state.Band[1].det * wd2) >> 15;
|
||||
|
||||
// Block 3H, LOGSCH
|
||||
ih2 = rh2[ihigh];
|
||||
wd = (state.Band[1].nb * 127) >> 7;
|
||||
state.Band[1].nb = wd + wh[ih2];
|
||||
if (state.Band[1].nb < 0)
|
||||
state.Band[1].nb = 0;
|
||||
else if (state.Band[1].nb > 22528)
|
||||
state.Band[1].nb = 22528;
|
||||
|
||||
// Block 3H, SCALEH
|
||||
wd1 = (state.Band[1].nb >> 6) & 31;
|
||||
wd2 = 10 - (state.Band[1].nb >> 11);
|
||||
wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2);
|
||||
state.Band[1].det = wd3 << 2;
|
||||
|
||||
Block4(state, 1, dhigh);
|
||||
code = ((ihigh << 6) | ilow) >> (8 - state.BitsPerSample);
|
||||
}
|
||||
|
||||
if (state.Packed)
|
||||
{
|
||||
// Pack the code bits
|
||||
state.OutBuffer |= (uint)(code << state.OutBits);
|
||||
state.OutBits += state.BitsPerSample;
|
||||
if (state.OutBits >= 8)
|
||||
{
|
||||
outputBuffer[g722_bytes++] = (byte)(state.OutBuffer & 0xFF);
|
||||
state.OutBits -= 8;
|
||||
state.OutBuffer >>= 8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outputBuffer[g722_bytes++] = (byte)code;
|
||||
}
|
||||
}
|
||||
return g722_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores state to be used between calls to Encode or Decode
|
||||
/// </summary>
|
||||
public class G722CodecState
|
||||
{
|
||||
/// <summary>
|
||||
/// ITU Test Mode
|
||||
/// TRUE if the operating in the special ITU test mode, with the band split filters disabled.
|
||||
/// </summary>
|
||||
public bool ItuTestMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TRUE if the G.722 data is packed
|
||||
/// </summary>
|
||||
public bool Packed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 8kHz Sampling
|
||||
/// TRUE if encode from 8k samples/second
|
||||
/// </summary>
|
||||
public bool EncodeFrom8000Hz { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Bits Per Sample
|
||||
/// 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps.
|
||||
/// </summary>
|
||||
public int BitsPerSample { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Signal history for the QMF (x)
|
||||
/// </summary>
|
||||
public int[] QmfSignalHistory { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Band
|
||||
/// </summary>
|
||||
public Band[] Band { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// In bit buffer
|
||||
/// </summary>
|
||||
public uint InBuffer { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of bits in InBuffer
|
||||
/// </summary>
|
||||
public int InBits { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Out bit buffer
|
||||
/// </summary>
|
||||
public uint OutBuffer { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of bits in OutBuffer
|
||||
/// </summary>
|
||||
public int OutBits { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of G722 Codec State for a
|
||||
/// new encode or decode session
|
||||
/// </summary>
|
||||
/// <param name="rate">Bitrate (typically 64000)</param>
|
||||
/// <param name="options">Special options</param>
|
||||
public G722CodecState(int rate, G722Flags options)
|
||||
{
|
||||
this.Band = new Band[2] { new Band(), new Band() };
|
||||
this.QmfSignalHistory = new int[24];
|
||||
this.ItuTestMode = false;
|
||||
|
||||
if (rate == 48000)
|
||||
this.BitsPerSample = 6;
|
||||
else if (rate == 56000)
|
||||
this.BitsPerSample = 7;
|
||||
else if (rate == 64000)
|
||||
this.BitsPerSample = 8;
|
||||
else
|
||||
throw new ArgumentException("Invalid rate, should be 48000, 56000 or 64000");
|
||||
if ((options & G722Flags.SampleRate8000) == G722Flags.SampleRate8000)
|
||||
this.EncodeFrom8000Hz = true;
|
||||
if (((options & G722Flags.Packed) == G722Flags.Packed) && this.BitsPerSample != 8)
|
||||
this.Packed = true;
|
||||
else
|
||||
this.Packed = false;
|
||||
this.Band[0].det = 32;
|
||||
this.Band[1].det = 8;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Band data for G722 Codec
|
||||
/// </summary>
|
||||
public class Band
|
||||
{
|
||||
/// <summary>s</summary>
|
||||
public int s;
|
||||
/// <summary>sp</summary>
|
||||
public int sp;
|
||||
/// <summary>sz</summary>
|
||||
public int sz;
|
||||
/// <summary>r</summary>
|
||||
public int[] r = new int[3];
|
||||
/// <summary>a</summary>
|
||||
public int[] a = new int[3];
|
||||
/// <summary>ap</summary>
|
||||
public int[] ap = new int[3];
|
||||
/// <summary>p</summary>
|
||||
public int[] p = new int[3];
|
||||
/// <summary>d</summary>
|
||||
public int[] d = new int[7];
|
||||
/// <summary>b</summary>
|
||||
public int[] b = new int[7];
|
||||
/// <summary>bp</summary>
|
||||
public int[] bp = new int[7];
|
||||
/// <summary>sg</summary>
|
||||
public int[] sg = new int[7];
|
||||
/// <summary>nb</summary>
|
||||
public int nb;
|
||||
/// <summary>det</summary>
|
||||
public int det;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// G722 Flags
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum G722Flags
|
||||
{
|
||||
/// <summary>
|
||||
/// None
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// Using a G722 sample rate of 8000
|
||||
/// </summary>
|
||||
SampleRate8000 = 0x0001,
|
||||
/// <summary>
|
||||
/// Packed
|
||||
/// </summary>
|
||||
Packed = 0x0002
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0905d4344a800341aae597e92687bb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,60 +0,0 @@
|
||||
namespace NAudio.Codecs
|
||||
{
|
||||
/// <summary>
|
||||
/// mu-law decoder
|
||||
/// based on code from:
|
||||
/// http://hazelware.luggle.com/tutorials/mulawcompression.html
|
||||
/// </summary>
|
||||
public static class MuLawDecoder
|
||||
{
|
||||
/// <summary>
|
||||
/// only 512 bytes required, so just use a lookup
|
||||
/// </summary>
|
||||
private static readonly short[] MuLawDecompressTable = new short[256]
|
||||
{
|
||||
-32124,-31100,-30076,-29052,-28028,-27004,-25980,-24956,
|
||||
-23932,-22908,-21884,-20860,-19836,-18812,-17788,-16764,
|
||||
-15996,-15484,-14972,-14460,-13948,-13436,-12924,-12412,
|
||||
-11900,-11388,-10876,-10364, -9852, -9340, -8828, -8316,
|
||||
-7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140,
|
||||
-5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092,
|
||||
-3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004,
|
||||
-2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980,
|
||||
-1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436,
|
||||
-1372, -1308, -1244, -1180, -1116, -1052, -988, -924,
|
||||
-876, -844, -812, -780, -748, -716, -684, -652,
|
||||
-620, -588, -556, -524, -492, -460, -428, -396,
|
||||
-372, -356, -340, -324, -308, -292, -276, -260,
|
||||
-244, -228, -212, -196, -180, -164, -148, -132,
|
||||
-120, -112, -104, -96, -88, -80, -72, -64,
|
||||
-56, -48, -40, -32, -24, -16, -8, -1,
|
||||
32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956,
|
||||
23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764,
|
||||
15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412,
|
||||
11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316,
|
||||
7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140,
|
||||
5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092,
|
||||
3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004,
|
||||
2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980,
|
||||
1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436,
|
||||
1372, 1308, 1244, 1180, 1116, 1052, 988, 924,
|
||||
876, 844, 812, 780, 748, 716, 684, 652,
|
||||
620, 588, 556, 524, 492, 460, 428, 396,
|
||||
372, 356, 340, 324, 308, 292, 276, 260,
|
||||
244, 228, 212, 196, 180, 164, 148, 132,
|
||||
120, 112, 104, 96, 88, 80, 72, 64,
|
||||
56, 48, 40, 32, 24, 16, 8, 0
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Converts a mu-law encoded byte to a 16 bit linear sample
|
||||
/// </summary>
|
||||
/// <param name="muLaw">mu-law encoded byte</param>
|
||||
/// <returns>Linear sample</returns>
|
||||
public static short MuLawToLinearSample(byte muLaw)
|
||||
{
|
||||
return MuLawDecompressTable[muLaw];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e8f8f3cc467423488b6e7267d3e29cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,53 +0,0 @@
|
||||
namespace NAudio.Codecs
|
||||
{
|
||||
/// <summary>
|
||||
/// mu-law encoder
|
||||
/// based on code from:
|
||||
/// http://hazelware.luggle.com/tutorials/mulawcompression.html
|
||||
/// </summary>
|
||||
public static class MuLawEncoder
|
||||
{
|
||||
private const int cBias = 0x84;
|
||||
private const int cClip = 32635;
|
||||
|
||||
private static readonly byte[] MuLawCompressTable = new byte[256]
|
||||
{
|
||||
0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
|
||||
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
|
||||
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Encodes a single 16 bit sample to mu-law
|
||||
/// </summary>
|
||||
/// <param name="sample">16 bit PCM sample</param>
|
||||
/// <returns>mu-law encoded byte</returns>
|
||||
public static byte LinearToMuLawSample(short sample)
|
||||
{
|
||||
int sign = (sample >> 8) & 0x80;
|
||||
if (sign != 0)
|
||||
sample = (short)-sample;
|
||||
if (sample > cClip)
|
||||
sample = cClip;
|
||||
sample = (short)(sample + cBias);
|
||||
int exponent = (int)MuLawCompressTable[(sample >> 7) & 0xFF];
|
||||
int mantissa = (sample >> (exponent + 3)) & 0x0F;
|
||||
int compressedByte = ~(sign | (exponent << 4) | mantissa);
|
||||
|
||||
return (byte)compressedByte;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd985b3b8cb2c2544afb6cfdda7804d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a448c0f4734c67041aa149aaa40bf04e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,85 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Capture Client
|
||||
/// </summary>
|
||||
public class AudioCaptureClient : IDisposable
|
||||
{
|
||||
IAudioCaptureClient audioCaptureClientInterface;
|
||||
|
||||
internal AudioCaptureClient(IAudioCaptureClient audioCaptureClientInterface)
|
||||
{
|
||||
this.audioCaptureClientInterface = audioCaptureClientInterface;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a pointer to the buffer
|
||||
/// </summary>
|
||||
/// <returns>Pointer to the buffer</returns>
|
||||
public IntPtr GetBuffer(
|
||||
out int numFramesToRead,
|
||||
out AudioClientBufferFlags bufferFlags,
|
||||
out long devicePosition,
|
||||
out long qpcPosition)
|
||||
{
|
||||
IntPtr bufferPointer;
|
||||
Marshal.ThrowExceptionForHR(audioCaptureClientInterface.GetBuffer(out bufferPointer, out numFramesToRead, out bufferFlags, out devicePosition, out qpcPosition));
|
||||
return bufferPointer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a pointer to the buffer
|
||||
/// </summary>
|
||||
/// <param name="numFramesToRead">Number of frames to read</param>
|
||||
/// <param name="bufferFlags">Buffer flags</param>
|
||||
/// <returns>Pointer to the buffer</returns>
|
||||
public IntPtr GetBuffer(
|
||||
out int numFramesToRead,
|
||||
out AudioClientBufferFlags bufferFlags)
|
||||
{
|
||||
IntPtr bufferPointer;
|
||||
long devicePosition;
|
||||
long qpcPosition;
|
||||
Marshal.ThrowExceptionForHR(audioCaptureClientInterface.GetBuffer(out bufferPointer, out numFramesToRead, out bufferFlags, out devicePosition, out qpcPosition));
|
||||
return bufferPointer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the next packet
|
||||
/// </summary>
|
||||
public int GetNextPacketSize()
|
||||
{
|
||||
int numFramesInNextPacket;
|
||||
Marshal.ThrowExceptionForHR(audioCaptureClientInterface.GetNextPacketSize(out numFramesInNextPacket));
|
||||
return numFramesInNextPacket;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Release buffer
|
||||
/// </summary>
|
||||
/// <param name="numFramesWritten">Number of frames written</param>
|
||||
public void ReleaseBuffer(int numFramesWritten)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioCaptureClientInterface.ReleaseBuffer(numFramesWritten));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Release the COM object
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (audioCaptureClientInterface != null)
|
||||
{
|
||||
// althugh GC would do this for us, we want it done now
|
||||
// to let us reopen WASAPI
|
||||
Marshal.ReleaseComObject(audioCaptureClientInterface);
|
||||
audioCaptureClientInterface = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e2d556c5bc4fee41b67c5bd69f90aa3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,357 +0,0 @@
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAudio.Utils;
|
||||
using NAudio.Wave;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Windows CoreAudio AudioClient
|
||||
/// </summary>
|
||||
public class AudioClient : IDisposable
|
||||
{
|
||||
private IAudioClient audioClientInterface;
|
||||
private WaveFormat mixFormat;
|
||||
private AudioRenderClient audioRenderClient;
|
||||
private AudioCaptureClient audioCaptureClient;
|
||||
private AudioClockClient audioClockClient;
|
||||
private AudioStreamVolume audioStreamVolume;
|
||||
private AudioClientShareMode shareMode;
|
||||
|
||||
internal AudioClient(IAudioClient audioClientInterface)
|
||||
{
|
||||
this.audioClientInterface = audioClientInterface;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the stream format that the audio engine uses for its internal processing of shared-mode streams.
|
||||
/// Can be called before initialize
|
||||
/// </summary>
|
||||
public WaveFormat MixFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mixFormat == null)
|
||||
{
|
||||
IntPtr waveFormatPointer;
|
||||
Marshal.ThrowExceptionForHR(audioClientInterface.GetMixFormat(out waveFormatPointer));
|
||||
var waveFormat = WaveFormat.MarshalFromPtr(waveFormatPointer);
|
||||
Marshal.FreeCoTaskMem(waveFormatPointer);
|
||||
mixFormat = waveFormat;
|
||||
}
|
||||
return mixFormat;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the Audio Client
|
||||
/// </summary>
|
||||
/// <param name="shareMode">Share Mode</param>
|
||||
/// <param name="streamFlags">Stream Flags</param>
|
||||
/// <param name="bufferDuration">Buffer Duration</param>
|
||||
/// <param name="periodicity">Periodicity</param>
|
||||
/// <param name="waveFormat">Wave Format</param>
|
||||
/// <param name="audioSessionGuid">Audio Session GUID (can be null)</param>
|
||||
public void Initialize(AudioClientShareMode shareMode,
|
||||
AudioClientStreamFlags streamFlags,
|
||||
long bufferDuration,
|
||||
long periodicity,
|
||||
WaveFormat waveFormat,
|
||||
Guid audioSessionGuid)
|
||||
{
|
||||
this.shareMode = shareMode;
|
||||
int hresult = audioClientInterface.Initialize(shareMode, streamFlags, bufferDuration, periodicity, waveFormat, ref audioSessionGuid);
|
||||
Marshal.ThrowExceptionForHR(hresult);
|
||||
// may have changed the mix format so reset it
|
||||
mixFormat = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the size (maximum capacity) of the audio buffer associated with the endpoint. (must initialize first)
|
||||
/// </summary>
|
||||
public int BufferSize
|
||||
{
|
||||
get
|
||||
{
|
||||
uint bufferSize;
|
||||
Marshal.ThrowExceptionForHR(audioClientInterface.GetBufferSize(out bufferSize));
|
||||
return (int) bufferSize;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the maximum latency for the current stream and can be called any time after the stream has been initialized.
|
||||
/// </summary>
|
||||
public long StreamLatency
|
||||
{
|
||||
get
|
||||
{
|
||||
return audioClientInterface.GetStreamLatency();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the number of frames of padding in the endpoint buffer (must initialize first)
|
||||
/// </summary>
|
||||
public int CurrentPadding
|
||||
{
|
||||
get
|
||||
{
|
||||
int currentPadding;
|
||||
Marshal.ThrowExceptionForHR(audioClientInterface.GetCurrentPadding(out currentPadding));
|
||||
return currentPadding;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the length of the periodic interval separating successive processing passes by the audio engine on the data in the endpoint buffer.
|
||||
/// (can be called before initialize)
|
||||
/// </summary>
|
||||
public long DefaultDevicePeriod
|
||||
{
|
||||
get
|
||||
{
|
||||
long defaultDevicePeriod;
|
||||
long minimumDevicePeriod;
|
||||
Marshal.ThrowExceptionForHR(audioClientInterface.GetDevicePeriod(out defaultDevicePeriod, out minimumDevicePeriod));
|
||||
return defaultDevicePeriod;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minimum device period
|
||||
/// (can be called before initialize)
|
||||
/// </summary>
|
||||
public long MinimumDevicePeriod
|
||||
{
|
||||
get
|
||||
{
|
||||
long defaultDevicePeriod;
|
||||
long minimumDevicePeriod;
|
||||
Marshal.ThrowExceptionForHR(audioClientInterface.GetDevicePeriod(out defaultDevicePeriod, out minimumDevicePeriod));
|
||||
return minimumDevicePeriod;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: GetService:
|
||||
// IID_IAudioSessionControl
|
||||
// IID_IChannelAudioVolume
|
||||
// IID_ISimpleAudioVolume
|
||||
|
||||
/// <summary>
|
||||
/// Returns the AudioStreamVolume service for this AudioClient.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This returns the AudioStreamVolume object ONLY for shared audio streams.
|
||||
/// </remarks>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// This is thrown when an exclusive audio stream is being used.
|
||||
/// </exception>
|
||||
public AudioStreamVolume AudioStreamVolume
|
||||
{
|
||||
get
|
||||
{
|
||||
if (shareMode == AudioClientShareMode.Exclusive)
|
||||
{
|
||||
throw new InvalidOperationException("AudioStreamVolume is ONLY supported for shared audio streams.");
|
||||
}
|
||||
if (audioStreamVolume == null)
|
||||
{
|
||||
object audioStreamVolumeInterface;
|
||||
var audioStreamVolumeGuid = new Guid("93014887-242D-4068-8A15-CF5E93B90FE3");
|
||||
Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioStreamVolumeGuid, out audioStreamVolumeInterface));
|
||||
audioStreamVolume = new AudioStreamVolume((IAudioStreamVolume)audioStreamVolumeInterface);
|
||||
}
|
||||
return audioStreamVolume;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the AudioClockClient service
|
||||
/// </summary>
|
||||
public AudioClockClient AudioClockClient
|
||||
{
|
||||
get
|
||||
{
|
||||
if (audioClockClient == null)
|
||||
{
|
||||
object audioClockClientInterface;
|
||||
var audioClockClientGuid = new Guid("CD63314F-3FBA-4a1b-812C-EF96358728E7");
|
||||
Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioClockClientGuid, out audioClockClientInterface));
|
||||
audioClockClient = new AudioClockClient((IAudioClock)audioClockClientInterface);
|
||||
}
|
||||
return audioClockClient;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the AudioRenderClient service
|
||||
/// </summary>
|
||||
public AudioRenderClient AudioRenderClient
|
||||
{
|
||||
get
|
||||
{
|
||||
if (audioRenderClient == null)
|
||||
{
|
||||
object audioRenderClientInterface;
|
||||
var audioRenderClientGuid = new Guid("F294ACFC-3146-4483-A7BF-ADDCA7C260E2");
|
||||
Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioRenderClientGuid, out audioRenderClientInterface));
|
||||
audioRenderClient = new AudioRenderClient((IAudioRenderClient)audioRenderClientInterface);
|
||||
}
|
||||
return audioRenderClient;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the AudioCaptureClient service
|
||||
/// </summary>
|
||||
public AudioCaptureClient AudioCaptureClient
|
||||
{
|
||||
get
|
||||
{
|
||||
if (audioCaptureClient == null)
|
||||
{
|
||||
object audioCaptureClientInterface;
|
||||
var audioCaptureClientGuid = new Guid("c8adbd64-e71e-48a0-a4de-185c395cd317");
|
||||
Marshal.ThrowExceptionForHR(audioClientInterface.GetService(audioCaptureClientGuid, out audioCaptureClientInterface));
|
||||
audioCaptureClient = new AudioCaptureClient((IAudioCaptureClient)audioCaptureClientInterface);
|
||||
}
|
||||
return audioCaptureClient;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether if the specified output format is supported
|
||||
/// </summary>
|
||||
/// <param name="shareMode">The share mode.</param>
|
||||
/// <param name="desiredFormat">The desired format.</param>
|
||||
/// <returns>True if the format is supported</returns>
|
||||
public bool IsFormatSupported(AudioClientShareMode shareMode,
|
||||
WaveFormat desiredFormat)
|
||||
{
|
||||
WaveFormatExtensible closestMatchFormat;
|
||||
return IsFormatSupported(shareMode, desiredFormat, out closestMatchFormat);
|
||||
}
|
||||
|
||||
private IntPtr GetPointerToPointer()
|
||||
{
|
||||
return Marshal.AllocHGlobal(MarshalHelpers.SizeOf<IntPtr>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the specified output format is supported in shared mode
|
||||
/// </summary>
|
||||
/// <param name="shareMode">Share Mode</param>
|
||||
/// <param name="desiredFormat">Desired Format</param>
|
||||
/// <param name="closestMatchFormat">Output The closest match format.</param>
|
||||
/// <returns>True if the format is supported</returns>
|
||||
public bool IsFormatSupported(AudioClientShareMode shareMode, WaveFormat desiredFormat, out WaveFormatExtensible closestMatchFormat)
|
||||
{
|
||||
IntPtr pointerToPtr = GetPointerToPointer(); // IntPtr.Zero; // Marshal.AllocHGlobal(Marshal.SizeOf<WaveFormatExtensible>());
|
||||
closestMatchFormat = null;
|
||||
int hresult = audioClientInterface.IsFormatSupported(shareMode, desiredFormat, pointerToPtr);
|
||||
|
||||
var closestMatchPtr = MarshalHelpers.PtrToStructure<IntPtr>(pointerToPtr);
|
||||
|
||||
if (closestMatchPtr != IntPtr.Zero)
|
||||
{
|
||||
closestMatchFormat = MarshalHelpers.PtrToStructure<WaveFormatExtensible>(closestMatchPtr);
|
||||
Marshal.FreeCoTaskMem(closestMatchPtr);
|
||||
}
|
||||
Marshal.FreeHGlobal(pointerToPtr);
|
||||
// S_OK is 0, S_FALSE = 1
|
||||
if (hresult == 0)
|
||||
{
|
||||
|
||||
// directly supported
|
||||
return true;
|
||||
}
|
||||
if (hresult == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (hresult == (int)AudioClientErrors.UnsupportedFormat)
|
||||
{
|
||||
// Succeeded but the specified format is not supported in exclusive mode.
|
||||
return shareMode != AudioClientShareMode.Exclusive;
|
||||
}
|
||||
Marshal.ThrowExceptionForHR(hresult);
|
||||
// shouldn't get here
|
||||
throw new NotSupportedException("Unknown hresult " + hresult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts the audio stream
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
audioClientInterface.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the audio stream.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
audioClientInterface.Stop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the Event Handle for buffer synchro.
|
||||
/// </summary>
|
||||
/// <param name="eventWaitHandle">The Wait Handle to setup</param>
|
||||
public void SetEventHandle(IntPtr eventWaitHandle)
|
||||
{
|
||||
audioClientInterface.SetEventHandle(eventWaitHandle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the audio stream
|
||||
/// Reset is a control method that the client calls to reset a stopped audio stream.
|
||||
/// Resetting the stream flushes all pending data and resets the audio clock stream
|
||||
/// position to 0. This method fails if it is called on a stream that is not stopped
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
audioClientInterface.Reset();
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (audioClientInterface != null)
|
||||
{
|
||||
if (audioClockClient != null)
|
||||
{
|
||||
audioClockClient.Dispose();
|
||||
audioClockClient = null;
|
||||
}
|
||||
if (audioRenderClient != null)
|
||||
{
|
||||
audioRenderClient.Dispose();
|
||||
audioRenderClient = null;
|
||||
}
|
||||
if (audioCaptureClient != null)
|
||||
{
|
||||
audioCaptureClient.Dispose();
|
||||
audioCaptureClient = null;
|
||||
}
|
||||
if (audioStreamVolume != null)
|
||||
{
|
||||
audioStreamVolume.Dispose();
|
||||
audioStreamVolume = null;
|
||||
}
|
||||
Marshal.ReleaseComObject(audioClientInterface);
|
||||
audioClientInterface = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a8ce790c8bafe149b00a1541d1fea8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Client Buffer Flags
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum AudioClientBufferFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// None
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY
|
||||
/// </summary>
|
||||
DataDiscontinuity = 0x1,
|
||||
/// <summary>
|
||||
/// AUDCLNT_BUFFERFLAGS_SILENT
|
||||
/// </summary>
|
||||
Silent = 0x2,
|
||||
/// <summary>
|
||||
/// AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR
|
||||
/// </summary>
|
||||
TimestampError = 0x4
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38ba0bfc415031548b63bec98df7b981
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// The AudioClientProperties structure is used to set the parameters that describe the properties of the client's audio stream.
|
||||
/// </summary>
|
||||
/// <remarks>http://msdn.microsoft.com/en-us/library/windows/desktop/hh968105(v=vs.85).aspx</remarks>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct AudioClientProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// The size of the buffer for the audio stream.
|
||||
/// </summary>
|
||||
public UInt32 cbSize;
|
||||
/// <summary>
|
||||
/// Boolean value to indicate whether or not the audio stream is hardware-offloaded
|
||||
/// </summary>
|
||||
public int bIsOffload;
|
||||
/// <summary>
|
||||
/// An enumeration that is used to specify the category of the audio stream.
|
||||
/// </summary>
|
||||
public AudioStreamCategory eCategory;
|
||||
/// <summary>
|
||||
/// A bit-field describing the characteristics of the stream. Supported in Windows 8.1 and later.
|
||||
/// </summary>
|
||||
public AudioClientStreamOptions Options;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e31c85e7de3c6a44089d7abec81789fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// AUDCLNT_SHAREMODE
|
||||
/// </summary>
|
||||
public enum AudioClientShareMode
|
||||
{
|
||||
/// <summary>
|
||||
/// AUDCLNT_SHAREMODE_SHARED,
|
||||
/// </summary>
|
||||
Shared,
|
||||
/// <summary>
|
||||
/// AUDCLNT_SHAREMODE_EXCLUSIVE
|
||||
/// </summary>
|
||||
Exclusive,
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d9bb3bb833766540846ddcfcc0986a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// AUDCLNT_STREAMFLAGS
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum AudioClientStreamFlags
|
||||
{
|
||||
/// <summary>
|
||||
/// None
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// AUDCLNT_STREAMFLAGS_CROSSPROCESS
|
||||
/// </summary>
|
||||
CrossProcess = 0x00010000,
|
||||
/// <summary>
|
||||
/// AUDCLNT_STREAMFLAGS_LOOPBACK
|
||||
/// </summary>
|
||||
Loopback = 0x00020000,
|
||||
/// <summary>
|
||||
/// AUDCLNT_STREAMFLAGS_EVENTCALLBACK
|
||||
/// </summary>
|
||||
EventCallback = 0x00040000,
|
||||
/// <summary>
|
||||
/// AUDCLNT_STREAMFLAGS_NOPERSIST
|
||||
/// </summary>
|
||||
NoPersist = 0x00080000,
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7f5275174aacdf4b8f51153a54bddcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines values that describe the characteristics of an audio stream.
|
||||
/// </summary>
|
||||
public enum AudioClientStreamOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// No stream options.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// The audio stream is a 'raw' stream that bypasses all signal processing except for endpoint specific, always-on processing in the APO, driver, and hardware.
|
||||
/// </summary>
|
||||
Raw = 0x1
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3398a3960a7a1be4c8f6e66dd9bee3b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,128 +0,0 @@
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Clock Client
|
||||
/// </summary>
|
||||
public class AudioClockClient : IDisposable
|
||||
{
|
||||
IAudioClock audioClockClientInterface;
|
||||
|
||||
internal AudioClockClient(IAudioClock audioClockClientInterface)
|
||||
{
|
||||
this.audioClockClientInterface = audioClockClientInterface;
|
||||
|
||||
//Stopwatch.GetTimestamp();
|
||||
//Stopwatch.Frequency
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Characteristics
|
||||
/// </summary>
|
||||
public int Characteristics
|
||||
{
|
||||
get
|
||||
{
|
||||
uint characteristics;
|
||||
Marshal.ThrowExceptionForHR(audioClockClientInterface.GetCharacteristics(out characteristics));
|
||||
return (int)characteristics;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Frequency
|
||||
/// </summary>
|
||||
public ulong Frequency
|
||||
{
|
||||
get
|
||||
{
|
||||
ulong freq;
|
||||
Marshal.ThrowExceptionForHR(audioClockClientInterface.GetFrequency(out freq));
|
||||
return freq;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Position
|
||||
/// </summary>
|
||||
public bool GetPosition(out ulong position, out ulong qpcPosition)
|
||||
{
|
||||
var hr = audioClockClientInterface.GetPosition(out position, out qpcPosition);
|
||||
if (hr == -1) return false;
|
||||
Marshal.ThrowExceptionForHR(hr);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjusted Position
|
||||
/// </summary>
|
||||
public ulong AdjustedPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
// figure out ticks per byte (for later)
|
||||
var byteLatency = (TimeSpan.TicksPerSecond / Frequency);
|
||||
|
||||
ulong pos, qpos;
|
||||
int cnt = 0;
|
||||
while (!GetPosition(out pos, out qpos))
|
||||
{
|
||||
if (++cnt == 5)
|
||||
{
|
||||
// we've tried too many times, so now we have to just run with what we have...
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Stopwatch.IsHighResolution)
|
||||
{
|
||||
// cool, we can adjust our position appropriately
|
||||
|
||||
// get the current qpc count (in ticks)
|
||||
var qposNow = (ulong)((Stopwatch.GetTimestamp() * 10000000M) / Stopwatch.Frequency);
|
||||
|
||||
// find out how many ticks has passed since the device reported the position
|
||||
var qposDiff = (qposNow - qpos) / 100;
|
||||
|
||||
// find out how many byte would have played in that time span
|
||||
var bytes = qposDiff / byteLatency;
|
||||
|
||||
// add it to the position
|
||||
pos += bytes;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Can Adjust Position
|
||||
/// </summary>
|
||||
public bool CanAdjustPosition
|
||||
{
|
||||
get { return Stopwatch.IsHighResolution; }
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (audioClockClientInterface != null)
|
||||
{
|
||||
// althugh GC would do this for us, we want it done now
|
||||
// to let us reopen WASAPI
|
||||
Marshal.ReleaseComObject(audioClockClientInterface);
|
||||
audioClockClientInterface = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6515848616958440b244d4c0bb10c0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,226 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Endpoint Volume
|
||||
/// </summary>
|
||||
public class AudioEndpointVolume : IDisposable
|
||||
{
|
||||
private readonly IAudioEndpointVolume audioEndPointVolume;
|
||||
private readonly AudioEndpointVolumeChannels channels;
|
||||
private readonly AudioEndpointVolumeStepInformation stepInformation;
|
||||
private readonly AudioEndpointVolumeVolumeRange volumeRange;
|
||||
private readonly EEndpointHardwareSupport hardwareSupport;
|
||||
private AudioEndpointVolumeCallback callBack;
|
||||
|
||||
private Guid notificationGuid = Guid.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// GUID to pass to AudioEndpointVolumeCallback
|
||||
/// </summary>
|
||||
public Guid NotificationGuid {
|
||||
get
|
||||
{
|
||||
return notificationGuid;
|
||||
}
|
||||
set
|
||||
{
|
||||
notificationGuid = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Volume Notification
|
||||
/// </summary>
|
||||
public event AudioEndpointVolumeNotificationDelegate OnVolumeNotification;
|
||||
|
||||
/// <summary>
|
||||
/// Volume Range
|
||||
/// </summary>
|
||||
public AudioEndpointVolumeVolumeRange VolumeRange
|
||||
{
|
||||
get
|
||||
{
|
||||
return volumeRange;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hardware Support
|
||||
/// </summary>
|
||||
public EEndpointHardwareSupport HardwareSupport
|
||||
{
|
||||
get
|
||||
{
|
||||
return hardwareSupport;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Step Information
|
||||
/// </summary>
|
||||
public AudioEndpointVolumeStepInformation StepInformation
|
||||
{
|
||||
get
|
||||
{
|
||||
return stepInformation;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Channels
|
||||
/// </summary>
|
||||
public AudioEndpointVolumeChannels Channels
|
||||
{
|
||||
get
|
||||
{
|
||||
return channels;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Master Volume Level
|
||||
/// </summary>
|
||||
public float MasterVolumeLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
float result;
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.GetMasterVolumeLevel(out result));
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.SetMasterVolumeLevel(value, ref notificationGuid));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Master Volume Level Scalar
|
||||
/// </summary>
|
||||
public float MasterVolumeLevelScalar
|
||||
{
|
||||
get
|
||||
{
|
||||
float result;
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.GetMasterVolumeLevelScalar(out result));
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.SetMasterVolumeLevelScalar(value, ref notificationGuid));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mute
|
||||
/// </summary>
|
||||
public bool Mute
|
||||
{
|
||||
get
|
||||
{
|
||||
bool result;
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.GetMute(out result));
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.SetMute(value, ref notificationGuid));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Volume Step Up
|
||||
/// </summary>
|
||||
public void VolumeStepUp()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.VolumeStepUp(ref notificationGuid));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Volume Step Down
|
||||
/// </summary>
|
||||
public void VolumeStepDown()
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.VolumeStepDown(ref notificationGuid));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Audio endpoint volume
|
||||
/// </summary>
|
||||
/// <param name="realEndpointVolume">IAudioEndpointVolume COM interface</param>
|
||||
internal AudioEndpointVolume(IAudioEndpointVolume realEndpointVolume)
|
||||
{
|
||||
uint hardwareSupp;
|
||||
|
||||
audioEndPointVolume = realEndpointVolume;
|
||||
channels = new AudioEndpointVolumeChannels(audioEndPointVolume);
|
||||
stepInformation = new AudioEndpointVolumeStepInformation(audioEndPointVolume);
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.QueryHardwareSupport(out hardwareSupp));
|
||||
hardwareSupport = (EEndpointHardwareSupport)hardwareSupp;
|
||||
volumeRange = new AudioEndpointVolumeVolumeRange(audioEndPointVolume);
|
||||
callBack = new AudioEndpointVolumeCallback(this);
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.RegisterControlChangeNotify(callBack));
|
||||
}
|
||||
|
||||
internal void FireNotification(AudioVolumeNotificationData notificationData)
|
||||
{
|
||||
AudioEndpointVolumeNotificationDelegate del = OnVolumeNotification;
|
||||
if (del != null)
|
||||
{
|
||||
del(notificationData);
|
||||
}
|
||||
}
|
||||
#region IDisposable Members
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (callBack != null)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.UnregisterControlChangeNotify(callBack));
|
||||
callBack = null;
|
||||
}
|
||||
Marshal.ReleaseComObject(audioEndPointVolume);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizer
|
||||
/// </summary>
|
||||
~AudioEndpointVolume()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ada5f03e052e4fd4aada9e1559850551
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
(Modified for NAudio by Mark Heath)
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
// This class implements the IAudioEndpointVolumeCallback interface,
|
||||
// it is implemented in this class because implementing it on AudioEndpointVolume
|
||||
// (where the functionality is really wanted, would cause the OnNotify function
|
||||
// to show up in the public API.
|
||||
internal class AudioEndpointVolumeCallback : IAudioEndpointVolumeCallback
|
||||
{
|
||||
private readonly AudioEndpointVolume parent;
|
||||
|
||||
internal AudioEndpointVolumeCallback(AudioEndpointVolume parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void OnNotify(IntPtr notifyData)
|
||||
{
|
||||
//Since AUDIO_VOLUME_NOTIFICATION_DATA is dynamic in length based on the
|
||||
//number of audio channels available we cannot just call PtrToStructure
|
||||
//to get all data, thats why it is split up into two steps, first the static
|
||||
//data is marshalled into the data structure, then with some IntPtr math the
|
||||
//remaining floats are read from memory.
|
||||
//
|
||||
var data = MarshalHelpers.PtrToStructure<AudioVolumeNotificationDataStruct>(notifyData);
|
||||
|
||||
//Determine offset in structure of the first float
|
||||
var offset = MarshalHelpers.OffsetOf<AudioVolumeNotificationDataStruct>("ChannelVolume");
|
||||
//Determine offset in memory of the first float
|
||||
var firstFloatPtr = (IntPtr)((long)notifyData + (long)offset);
|
||||
|
||||
var voldata = new float[data.nChannels];
|
||||
|
||||
//Read all floats from memory.
|
||||
for (int i = 0; i < data.nChannels; i++)
|
||||
{
|
||||
voldata[i] = MarshalHelpers.PtrToStructure<float>(firstFloatPtr);
|
||||
}
|
||||
|
||||
//Create combined structure and Fire Event in parent class.
|
||||
var notificationData = new AudioVolumeNotificationData(data.guidEventContext, data.bMuted, data.fMasterVolume, voldata, data.guidEventContext);
|
||||
parent.FireNotification(notificationData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3587af9c51990145ab25a1038283977
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Endpoint Volume Channel
|
||||
/// </summary>
|
||||
public class AudioEndpointVolumeChannel
|
||||
{
|
||||
private readonly uint channel;
|
||||
private readonly IAudioEndpointVolume audioEndpointVolume;
|
||||
|
||||
private Guid notificationGuid = Guid.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// GUID to pass to AudioEndpointVolumeCallback
|
||||
/// </summary>
|
||||
public Guid NotificationGuid
|
||||
{
|
||||
get
|
||||
{
|
||||
return notificationGuid;
|
||||
}
|
||||
set
|
||||
{
|
||||
notificationGuid = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal AudioEndpointVolumeChannel(IAudioEndpointVolume parent, int channel)
|
||||
{
|
||||
this.channel = (uint)channel;
|
||||
audioEndpointVolume = parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Volume Level
|
||||
/// </summary>
|
||||
public float VolumeLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
float result;
|
||||
Marshal.ThrowExceptionForHR(audioEndpointVolume.GetChannelVolumeLevel(channel,out result));
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioEndpointVolume.SetChannelVolumeLevel(channel, value, ref this.notificationGuid));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Volume Level Scalar
|
||||
/// </summary>
|
||||
public float VolumeLevelScalar
|
||||
{
|
||||
get
|
||||
{
|
||||
float result;
|
||||
Marshal.ThrowExceptionForHR(audioEndpointVolume.GetChannelVolumeLevelScalar(channel, out result));
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioEndpointVolume.SetChannelVolumeLevelScalar(channel, value, ref this.notificationGuid));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d48e80398c7c89642bd685d7c8c16ae1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Endpoint Volume Channels
|
||||
/// </summary>
|
||||
public class AudioEndpointVolumeChannels
|
||||
{
|
||||
readonly IAudioEndpointVolume audioEndPointVolume;
|
||||
readonly AudioEndpointVolumeChannel[] channels;
|
||||
|
||||
/// <summary>
|
||||
/// Channel Count
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
int result;
|
||||
Marshal.ThrowExceptionForHR(audioEndPointVolume.GetChannelCount(out result));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indexer - get a specific channel
|
||||
/// </summary>
|
||||
public AudioEndpointVolumeChannel this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return channels[index];
|
||||
}
|
||||
}
|
||||
|
||||
internal AudioEndpointVolumeChannels(IAudioEndpointVolume parent)
|
||||
{
|
||||
int ChannelCount;
|
||||
audioEndPointVolume = parent;
|
||||
|
||||
ChannelCount = Count;
|
||||
channels = new AudioEndpointVolumeChannel[ChannelCount];
|
||||
for (int i = 0; i < ChannelCount; i++)
|
||||
{
|
||||
channels[i] = new AudioEndpointVolumeChannel(audioEndPointVolume, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a76257c81db832e4f8f7d1086f1767de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Endpoint Volume Notifiaction Delegate
|
||||
/// </summary>
|
||||
/// <param name="data">Audio Volume Notification Data</param>
|
||||
public delegate void AudioEndpointVolumeNotificationDelegate(AudioVolumeNotificationData data);
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6453b96c8b75e5a45a48feaa8016df92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Endpoint Volume Step Information
|
||||
/// </summary>
|
||||
public class AudioEndpointVolumeStepInformation
|
||||
{
|
||||
private readonly uint step;
|
||||
private readonly uint stepCount;
|
||||
|
||||
internal AudioEndpointVolumeStepInformation(IAudioEndpointVolume parent)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(parent.GetVolumeStepInfo(out step, out stepCount));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Step
|
||||
/// </summary>
|
||||
public uint Step
|
||||
{
|
||||
get { return step; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// StepCount
|
||||
/// </summary>
|
||||
public uint StepCount
|
||||
{
|
||||
get { return stepCount; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fb7669af1a21d94ba2cfab59c50abb0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
// modified for NAudio
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Endpoint Volume Volume Range
|
||||
/// </summary>
|
||||
public class AudioEndpointVolumeVolumeRange
|
||||
{
|
||||
readonly float volumeMinDecibels;
|
||||
readonly float volumeMaxDecibels;
|
||||
readonly float volumeIncrementDecibels;
|
||||
|
||||
internal AudioEndpointVolumeVolumeRange(IAudioEndpointVolume parent)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(parent.GetVolumeRange(out volumeMinDecibels,out volumeMaxDecibels,out volumeIncrementDecibels));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Minimum Decibels
|
||||
/// </summary>
|
||||
public float MinDecibels
|
||||
{
|
||||
get { return volumeMinDecibels; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximum Decibels
|
||||
/// </summary>
|
||||
public float MaxDecibels
|
||||
{
|
||||
get { return volumeMaxDecibels; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increment Decibels
|
||||
/// </summary>
|
||||
public float IncrementDecibels
|
||||
{
|
||||
get { return volumeIncrementDecibels; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 462f548873fcd3346a9598a0776b4af4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Meter Information
|
||||
/// </summary>
|
||||
public class AudioMeterInformation
|
||||
{
|
||||
private readonly IAudioMeterInformation audioMeterInformation;
|
||||
private readonly EEndpointHardwareSupport hardwareSupport;
|
||||
private readonly AudioMeterInformationChannels channels;
|
||||
|
||||
internal AudioMeterInformation(IAudioMeterInformation realInterface)
|
||||
{
|
||||
int hardwareSupp;
|
||||
|
||||
audioMeterInformation = realInterface;
|
||||
Marshal.ThrowExceptionForHR(audioMeterInformation.QueryHardwareSupport(out hardwareSupp));
|
||||
hardwareSupport = (EEndpointHardwareSupport)hardwareSupp;
|
||||
channels = new AudioMeterInformationChannels(audioMeterInformation);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Peak Values
|
||||
/// </summary>
|
||||
public AudioMeterInformationChannels PeakValues
|
||||
{
|
||||
get
|
||||
{
|
||||
return channels;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hardware Support
|
||||
/// </summary>
|
||||
public EEndpointHardwareSupport HardwareSupport
|
||||
{
|
||||
get
|
||||
{
|
||||
return hardwareSupport;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Master Peak Value
|
||||
/// </summary>
|
||||
public float MasterPeakValue
|
||||
{
|
||||
get
|
||||
{
|
||||
float result;
|
||||
Marshal.ThrowExceptionForHR(audioMeterInformation.GetPeakValue(out result));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e67b5c7f575a84e4081d1f59384cb96b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Meter Information Channels
|
||||
/// </summary>
|
||||
public class AudioMeterInformationChannels
|
||||
{
|
||||
private readonly IAudioMeterInformation audioMeterInformation;
|
||||
|
||||
/// <summary>
|
||||
/// Metering Channel Count
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
int result;
|
||||
Marshal.ThrowExceptionForHR(audioMeterInformation.GetMeteringChannelCount(out result));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Peak value
|
||||
/// </summary>
|
||||
/// <param name="index">Channel index</param>
|
||||
/// <returns>Peak value</returns>
|
||||
public float this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
var channels = Count;
|
||||
if (index >= channels)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index),
|
||||
$"Peak index cannot be greater than number of channels ({channels})");
|
||||
}
|
||||
var peakValues = new float[Count];
|
||||
var Params = GCHandle.Alloc(peakValues, GCHandleType.Pinned);
|
||||
Marshal.ThrowExceptionForHR(audioMeterInformation.GetChannelsPeakValues(peakValues.Length, Params.AddrOfPinnedObject()));
|
||||
Params.Free();
|
||||
return peakValues[index];
|
||||
}
|
||||
}
|
||||
|
||||
internal AudioMeterInformationChannels(IAudioMeterInformation parent)
|
||||
{
|
||||
audioMeterInformation = parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a41adf542de59234eb42e16fc2d8cf16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Render Client
|
||||
/// </summary>
|
||||
public class AudioRenderClient : IDisposable
|
||||
{
|
||||
IAudioRenderClient audioRenderClientInterface;
|
||||
|
||||
internal AudioRenderClient(IAudioRenderClient audioRenderClientInterface)
|
||||
{
|
||||
this.audioRenderClientInterface = audioRenderClientInterface;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a pointer to the buffer
|
||||
/// </summary>
|
||||
/// <param name="numFramesRequested">Number of frames requested</param>
|
||||
/// <returns>Pointer to the buffer</returns>
|
||||
public IntPtr GetBuffer(int numFramesRequested)
|
||||
{
|
||||
IntPtr bufferPointer;
|
||||
Marshal.ThrowExceptionForHR(audioRenderClientInterface.GetBuffer(numFramesRequested, out bufferPointer));
|
||||
return bufferPointer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Release buffer
|
||||
/// </summary>
|
||||
/// <param name="numFramesWritten">Number of frames written</param>
|
||||
/// <param name="bufferFlags">Buffer flags</param>
|
||||
public void ReleaseBuffer(int numFramesWritten,AudioClientBufferFlags bufferFlags)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioRenderClientInterface.ReleaseBuffer(numFramesWritten, bufferFlags));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Release the COM object
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (audioRenderClientInterface != null)
|
||||
{
|
||||
// althugh GC would do this for us, we want it done now
|
||||
// to let us reopen WASAPI
|
||||
Marshal.ReleaseComObject(audioRenderClientInterface);
|
||||
audioRenderClientInterface = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27c5dbb82cdd8a1429aba1223fd48d57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,237 +0,0 @@
|
||||
// -----------------------------------------
|
||||
// milligan22963 - implemented to work with nAudio
|
||||
// 12/2014
|
||||
// -----------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// AudioSessionControl object for information
|
||||
/// regarding an audio session
|
||||
/// </summary>
|
||||
public class AudioSessionControl : IDisposable
|
||||
{
|
||||
private readonly IAudioSessionControl audioSessionControlInterface;
|
||||
private readonly IAudioSessionControl2 audioSessionControlInterface2;
|
||||
private AudioSessionEventsCallback audioSessionEventCallback;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="audioSessionControl"></param>
|
||||
public AudioSessionControl(IAudioSessionControl audioSessionControl)
|
||||
{
|
||||
audioSessionControlInterface = audioSessionControl;
|
||||
audioSessionControlInterface2 = audioSessionControl as IAudioSessionControl2;
|
||||
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
var meters = audioSessionControlInterface as IAudioMeterInformation;
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global
|
||||
var volume = audioSessionControlInterface as ISimpleAudioVolume;
|
||||
if (meters != null)
|
||||
AudioMeterInformation = new AudioMeterInformation(meters);
|
||||
if (volume != null)
|
||||
SimpleAudioVolume = new SimpleAudioVolume(volume);
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (audioSessionEventCallback != null)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.UnregisterAudioSessionNotification(audioSessionEventCallback));
|
||||
audioSessionEventCallback = null;
|
||||
}
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizer
|
||||
/// </summary>
|
||||
~AudioSessionControl()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Audio meter information of the audio session.
|
||||
/// </summary>
|
||||
public AudioMeterInformation AudioMeterInformation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Simple audio volume of the audio session (for volume and mute status).
|
||||
/// </summary>
|
||||
public SimpleAudioVolume SimpleAudioVolume { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The current state of the audio session.
|
||||
/// </summary>
|
||||
public AudioSessionState State
|
||||
{
|
||||
get
|
||||
{
|
||||
AudioSessionState state;
|
||||
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetState(out state));
|
||||
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of the audio session.
|
||||
/// </summary>
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
string displayName;
|
||||
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetDisplayName(out displayName));
|
||||
|
||||
return displayName;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != String.Empty)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.SetDisplayName(value, Guid.Empty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the path to the icon shown in the mixer.
|
||||
/// </summary>
|
||||
public string IconPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string iconPath;
|
||||
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetIconPath(out iconPath));
|
||||
|
||||
return iconPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != String.Empty)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.SetIconPath(value, Guid.Empty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The session identifier of the audio session.
|
||||
/// </summary>
|
||||
public string GetSessionIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (audioSessionControlInterface2 == null) throw new InvalidOperationException("Not supported on this version of Windows");
|
||||
string str;
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface2.GetSessionIdentifier(out str));
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The session instance identifier of the audio session.
|
||||
/// </summary>
|
||||
public string GetSessionInstanceIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (audioSessionControlInterface2 == null) throw new InvalidOperationException("Not supported on this version of Windows");
|
||||
string str;
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface2.GetSessionInstanceIdentifier(out str));
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The process identifier of the audio session.
|
||||
/// </summary>
|
||||
public uint GetProcessID
|
||||
{
|
||||
get
|
||||
{
|
||||
if (audioSessionControlInterface2 == null) throw new InvalidOperationException("Not supported on this version of Windows");
|
||||
uint pid;
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface2.GetProcessId(out pid));
|
||||
return pid;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the session a system sounds session.
|
||||
/// </summary>
|
||||
public bool IsSystemSoundsSession
|
||||
{
|
||||
get
|
||||
{
|
||||
if (audioSessionControlInterface2 == null) throw new InvalidOperationException("Not supported on this version of Windows");
|
||||
return (audioSessionControlInterface2.IsSystemSoundsSession() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the grouping param for an audio session grouping
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Guid GetGroupingParam()
|
||||
{
|
||||
Guid groupingId;
|
||||
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.GetGroupingParam(out groupingId));
|
||||
|
||||
return groupingId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For chanigng the grouping param and supplying the context of said change
|
||||
/// </summary>
|
||||
/// <param name="groupingId"></param>
|
||||
/// <param name="context"></param>
|
||||
public void SetGroupingParam(Guid groupingId, Guid context)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.SetGroupingParam(groupingId, context));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers an even client for callbacks
|
||||
/// </summary>
|
||||
/// <param name="eventClient"></param>
|
||||
public void RegisterEventClient(IAudioSessionEventsHandler eventClient)
|
||||
{
|
||||
// we could have an array or list of listeners if we like
|
||||
audioSessionEventCallback = new AudioSessionEventsCallback(eventClient);
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.RegisterAudioSessionNotification(audioSessionEventCallback));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregisters an event client from receiving callbacks
|
||||
/// </summary>
|
||||
/// <param name="eventClient"></param>
|
||||
public void UnRegisterEventClient(IAudioSessionEventsHandler eventClient)
|
||||
{
|
||||
// if one is registered, let it go
|
||||
if (audioSessionEventCallback != null)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioSessionControlInterface.UnregisterAudioSessionNotification(audioSessionEventCallback));
|
||||
audioSessionEventCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 489c9772d31f9da42a6deea4b004d0d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,135 +0,0 @@
|
||||
// -----------------------------------------
|
||||
// milligan22963 - implemented to work with nAudio
|
||||
// 12/2014
|
||||
// -----------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// AudioSessionEvents callback implementation
|
||||
/// </summary>
|
||||
public class AudioSessionEventsCallback : IAudioSessionEvents
|
||||
{
|
||||
private readonly IAudioSessionEventsHandler audioSessionEventsHandler;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="handler"></param>
|
||||
public AudioSessionEventsCallback(IAudioSessionEventsHandler handler)
|
||||
{
|
||||
audioSessionEventsHandler = handler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the display name for the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="displayName">The new display name for the session.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
public int OnDisplayNameChanged(
|
||||
[In] [MarshalAs(UnmanagedType.LPWStr)] string displayName,
|
||||
[In] ref Guid eventContext)
|
||||
{
|
||||
audioSessionEventsHandler.OnDisplayNameChanged(displayName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the display icon for the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="iconPath">The path for the new display icon for the session.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
public int OnIconPathChanged(
|
||||
[In] [MarshalAs(UnmanagedType.LPWStr)] string iconPath,
|
||||
[In] ref Guid eventContext)
|
||||
{
|
||||
audioSessionEventsHandler.OnIconPathChanged(iconPath);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the volume level or muting state of the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="volume">The new volume level for the audio session.</param>
|
||||
/// <param name="isMuted">The new muting state.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
public int OnSimpleVolumeChanged(
|
||||
[In] [MarshalAs(UnmanagedType.R4)] float volume,
|
||||
[In] [MarshalAs(UnmanagedType.Bool)] bool isMuted,
|
||||
[In] ref Guid eventContext)
|
||||
{
|
||||
audioSessionEventsHandler.OnVolumeChanged(volume, isMuted);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the volume level of an audio channel in the session submix has changed.
|
||||
/// </summary>
|
||||
/// <param name="channelCount">The channel count.</param>
|
||||
/// <param name="newVolumes">An array of volumnes cooresponding with each channel index.</param>
|
||||
/// <param name="channelIndex">The number of the channel whose volume level changed.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
public int OnChannelVolumeChanged(
|
||||
[In] [MarshalAs(UnmanagedType.U4)] UInt32 channelCount,
|
||||
[In] [MarshalAs(UnmanagedType.SysInt)] IntPtr newVolumes, // Pointer to float array
|
||||
[In] [MarshalAs(UnmanagedType.U4)] UInt32 channelIndex,
|
||||
[In] ref Guid eventContext)
|
||||
{
|
||||
audioSessionEventsHandler.OnChannelVolumeChanged(channelCount, newVolumes, channelIndex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the grouping parameter for the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="groupingId">The new grouping parameter for the session.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
public int OnGroupingParamChanged(
|
||||
[In] ref Guid groupingId,
|
||||
[In] ref Guid eventContext)
|
||||
{
|
||||
audioSessionEventsHandler.OnGroupingParamChanged(ref groupingId);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the stream-activity state of the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="state">The new session state.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
public int OnStateChanged(
|
||||
[In] AudioSessionState state)
|
||||
{
|
||||
audioSessionEventsHandler.OnStateChanged(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the session has been disconnected.
|
||||
/// </summary>
|
||||
/// <param name="disconnectReason">The reason that the audio session was disconnected.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
public int OnSessionDisconnected(
|
||||
[In] AudioSessionDisconnectReason disconnectReason)
|
||||
{
|
||||
audioSessionEventsHandler.OnSessionDisconnected(disconnectReason);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 258b25fc0a77da44589f4f0cbe8e244e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,144 +0,0 @@
|
||||
// -----------------------------------------
|
||||
// milligan22963 - implemented to work with nAudio
|
||||
// 12/2014
|
||||
// -----------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// AudioSessionManager
|
||||
///
|
||||
/// Designed to manage audio sessions and in particuar the
|
||||
/// SimpleAudioVolume interface to adjust a session volume
|
||||
/// </summary>
|
||||
public class AudioSessionManager
|
||||
{
|
||||
private readonly IAudioSessionManager audioSessionInterface;
|
||||
private readonly IAudioSessionManager2 audioSessionInterface2;
|
||||
private AudioSessionNotification audioSessionNotification;
|
||||
private SessionCollection sessions;
|
||||
|
||||
private SimpleAudioVolume simpleAudioVolume;
|
||||
private AudioSessionControl audioSessionControl;
|
||||
|
||||
/// <summary>
|
||||
/// Session created delegate
|
||||
/// </summary>
|
||||
public delegate void SessionCreatedDelegate(object sender, IAudioSessionControl newSession);
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when audio session has been added (for example run another program that use audio playback).
|
||||
/// </summary>
|
||||
public event SessionCreatedDelegate OnSessionCreated;
|
||||
|
||||
internal AudioSessionManager(IAudioSessionManager audioSessionManager)
|
||||
{
|
||||
audioSessionInterface = audioSessionManager;
|
||||
audioSessionInterface2 = audioSessionManager as IAudioSessionManager2;
|
||||
|
||||
RefreshSessions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SimpleAudioVolume object
|
||||
/// for adjusting the volume for the user session
|
||||
/// </summary>
|
||||
public SimpleAudioVolume SimpleAudioVolume
|
||||
{
|
||||
get
|
||||
{
|
||||
if (simpleAudioVolume == null)
|
||||
{
|
||||
ISimpleAudioVolume simpleAudioInterface;
|
||||
|
||||
audioSessionInterface.GetSimpleAudioVolume(Guid.Empty, 0, out simpleAudioInterface);
|
||||
|
||||
simpleAudioVolume = new SimpleAudioVolume(simpleAudioInterface);
|
||||
}
|
||||
return simpleAudioVolume;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AudioSessionControl object
|
||||
/// for registring for callbacks and other session information
|
||||
/// </summary>
|
||||
public AudioSessionControl AudioSessionControl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (audioSessionControl == null)
|
||||
{
|
||||
IAudioSessionControl audioSessionControlInterface;
|
||||
|
||||
audioSessionInterface.GetAudioSessionControl(Guid.Empty, 0, out audioSessionControlInterface);
|
||||
|
||||
audioSessionControl = new AudioSessionControl(audioSessionControlInterface);
|
||||
}
|
||||
return audioSessionControl;
|
||||
}
|
||||
}
|
||||
|
||||
internal void FireSessionCreated(IAudioSessionControl newSession)
|
||||
{
|
||||
OnSessionCreated?.Invoke(this, newSession);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh session of current device.
|
||||
/// </summary>
|
||||
public void RefreshSessions()
|
||||
{
|
||||
UnregisterNotifications();
|
||||
|
||||
if (audioSessionInterface2 != null)
|
||||
{
|
||||
IAudioSessionEnumerator sessionEnum;
|
||||
Marshal.ThrowExceptionForHR(audioSessionInterface2.GetSessionEnumerator(out sessionEnum));
|
||||
sessions = new SessionCollection(sessionEnum);
|
||||
|
||||
audioSessionNotification = new AudioSessionNotification(this);
|
||||
Marshal.ThrowExceptionForHR(audioSessionInterface2.RegisterSessionNotification(audioSessionNotification));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns list of sessions of current device.
|
||||
/// </summary>
|
||||
public SessionCollection Sessions => sessions;
|
||||
|
||||
/// <summary>
|
||||
/// Dispose.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
UnregisterNotifications();
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void UnregisterNotifications()
|
||||
{
|
||||
sessions = null;
|
||||
|
||||
if (audioSessionNotification != null && audioSessionInterface2 != null)
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(
|
||||
audioSessionInterface2.UnregisterSessionNotification(audioSessionNotification));
|
||||
audioSessionNotification = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizer.
|
||||
/// </summary>
|
||||
~AudioSessionManager()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a93077ee64c37d843b465f227fa04835
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,24 +0,0 @@
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
internal class AudioSessionNotification : IAudioSessionNotification
|
||||
{
|
||||
private AudioSessionManager parent;
|
||||
|
||||
internal AudioSessionNotification(AudioSessionManager parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
[PreserveSig]
|
||||
public int OnSessionCreated(IAudioSessionControl newSession)
|
||||
{
|
||||
parent.FireSessionCreated(newSession);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8c952d77ab7de5408e3b5dc71ec75ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,41 +0,0 @@
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the category of an audio stream.
|
||||
/// </summary>
|
||||
public enum AudioStreamCategory
|
||||
{
|
||||
/// <summary>
|
||||
/// Other audio stream.
|
||||
/// </summary>
|
||||
Other = 0,
|
||||
/// <summary>
|
||||
/// Media that will only stream when the app is in the foreground.
|
||||
/// </summary>
|
||||
ForegroundOnlyMedia,
|
||||
/// <summary>
|
||||
/// Media that can be streamed when the app is in the background.
|
||||
/// </summary>
|
||||
BackgroundCapableMedia,
|
||||
/// <summary>
|
||||
/// Real-time communications, such as VOIP or chat.
|
||||
/// </summary>
|
||||
Communications,
|
||||
/// <summary>
|
||||
/// Alert sounds.
|
||||
/// </summary>
|
||||
Alerts,
|
||||
/// <summary>
|
||||
/// Sound effects.
|
||||
/// </summary>
|
||||
SoundEffects,
|
||||
/// <summary>
|
||||
/// Game sound effects.
|
||||
/// </summary>
|
||||
GameEffects,
|
||||
/// <summary>
|
||||
/// Background audio for games.
|
||||
/// </summary>
|
||||
GameMedia,
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eee244e0fbc65c94fb561767f32865d3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,170 +0,0 @@
|
||||
using NAudio.CoreAudioApi.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages the AudioStreamVolume for the <see cref="AudioClient"/>.
|
||||
/// </summary>
|
||||
public class AudioStreamVolume : IDisposable
|
||||
{
|
||||
IAudioStreamVolume audioStreamVolumeInterface;
|
||||
|
||||
internal AudioStreamVolume(IAudioStreamVolume audioStreamVolumeInterface)
|
||||
{
|
||||
this.audioStreamVolumeInterface = audioStreamVolumeInterface;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify that the channel index is valid.
|
||||
/// </summary>
|
||||
/// <param name="channelIndex"></param>
|
||||
/// <param name="parameter"></param>
|
||||
private void CheckChannelIndex(int channelIndex, string parameter)
|
||||
{
|
||||
int channelCount = ChannelCount;
|
||||
if (channelIndex >= channelCount)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(parameter, "You must supply a valid channel index < current count of channels: " + channelCount.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the current stream volumes for all channels
|
||||
/// </summary>
|
||||
/// <returns>An array of volume levels between 0.0 and 1.0 for each channel in the audio stream.</returns>
|
||||
public float[] GetAllVolumes()
|
||||
{
|
||||
uint channels;
|
||||
float[] levels;
|
||||
Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetChannelCount(out channels));
|
||||
levels = new float[channels];
|
||||
Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetAllVolumes(channels, levels));
|
||||
return levels;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the current number of channels in this audio stream.
|
||||
/// </summary>
|
||||
public int ChannelCount
|
||||
{
|
||||
get
|
||||
{
|
||||
uint channels;
|
||||
Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetChannelCount(out channels));
|
||||
unchecked
|
||||
{
|
||||
return (int)channels;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the current volume for the requested channel.
|
||||
/// </summary>
|
||||
/// <param name="channelIndex">The 0 based index into the channels.</param>
|
||||
/// <returns>The volume level for the channel between 0.0 and 1.0.</returns>
|
||||
public float GetChannelVolume(int channelIndex)
|
||||
{
|
||||
CheckChannelIndex(channelIndex, "channelIndex");
|
||||
|
||||
uint index;
|
||||
float level;
|
||||
unchecked
|
||||
{
|
||||
index = (uint)channelIndex;
|
||||
}
|
||||
Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.GetChannelVolume(index, out level));
|
||||
return level;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the volume level for each channel of the audio stream.
|
||||
/// </summary>
|
||||
/// <param name="levels">An array of volume levels (between 0.0 and 1.0) one for each channel.</param>
|
||||
/// <remarks>
|
||||
/// A volume level MUST be supplied for reach channel in the audio stream.
|
||||
/// </remarks>
|
||||
/// <exception cref="ArgumentOutOfRangeException">
|
||||
/// Thrown when <paramref name="levels"/> does not contain <see cref="ChannelCount"/> elements.
|
||||
/// </exception>
|
||||
public void SetAllVolumes(float[] levels)
|
||||
{
|
||||
// Make friendly Net exceptions for common problems:
|
||||
int channelCount = ChannelCount;
|
||||
if (levels == null)
|
||||
{
|
||||
throw new ArgumentNullException("levels");
|
||||
}
|
||||
if (levels.Length != channelCount)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
"levels",
|
||||
String.Format(CultureInfo.InvariantCulture, "SetAllVolumes MUST be supplied with a volume level for ALL channels. The AudioStream has {0} channels and you supplied {1} channels.",
|
||||
channelCount, levels.Length));
|
||||
}
|
||||
for (int i = 0; i < levels.Length; i++)
|
||||
{
|
||||
float level = levels[i];
|
||||
if (level < 0.0f) throw new ArgumentOutOfRangeException("levels", "All volumes must be between 0.0 and 1.0. Invalid volume at index: " + i.ToString());
|
||||
if (level > 1.0f) throw new ArgumentOutOfRangeException("levels", "All volumes must be between 0.0 and 1.0. Invalid volume at index: " + i.ToString());
|
||||
}
|
||||
unchecked
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.SetAllVoumes((uint)channelCount, levels));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the volume level for one channel in the audio stream.
|
||||
/// </summary>
|
||||
/// <param name="index">The 0-based index into the channels to adjust the volume of.</param>
|
||||
/// <param name="level">The volume level between 0.0 and 1.0 for this channel of the audio stream.</param>
|
||||
public void SetChannelVolume(int index, float level)
|
||||
{
|
||||
CheckChannelIndex(index, "index");
|
||||
|
||||
if (level < 0.0f) throw new ArgumentOutOfRangeException("level", "Volume must be between 0.0 and 1.0");
|
||||
if (level > 1.0f) throw new ArgumentOutOfRangeException("level", "Volume must be between 0.0 and 1.0");
|
||||
unchecked
|
||||
{
|
||||
Marshal.ThrowExceptionForHR(audioStreamVolumeInterface.SetChannelVolume((uint)index, level));
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Release/cleanup objects during Dispose/finalization.
|
||||
/// </summary>
|
||||
/// <param name="disposing">True if disposing and false if being finalized.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (audioStreamVolumeInterface != null)
|
||||
{
|
||||
// although GC would do this for us, we want it done now
|
||||
Marshal.ReleaseComObject(audioStreamVolumeInterface);
|
||||
audioStreamVolumeInterface = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5af5c8c992d1ad846abbd103ec12452f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Volume Notification Data
|
||||
/// </summary>
|
||||
public class AudioVolumeNotificationData
|
||||
{
|
||||
private readonly Guid eventContext;
|
||||
private readonly bool muted;
|
||||
private readonly float masterVolume;
|
||||
private readonly int channels;
|
||||
private readonly float[] channelVolume;
|
||||
private readonly Guid guid;
|
||||
|
||||
/// <summary>
|
||||
/// Event Context
|
||||
/// </summary>
|
||||
public Guid EventContext
|
||||
{
|
||||
get { return eventContext; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Muted
|
||||
/// </summary>
|
||||
public bool Muted
|
||||
{
|
||||
get { return muted; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Guid that raised the event
|
||||
/// </summary>
|
||||
public Guid Guid
|
||||
{
|
||||
get { return guid; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Master Volume
|
||||
/// </summary>
|
||||
public float MasterVolume
|
||||
{
|
||||
get { return masterVolume; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Channels
|
||||
/// </summary>
|
||||
public int Channels
|
||||
{
|
||||
get { return channels; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Channel Volume
|
||||
/// </summary>
|
||||
public float[] ChannelVolume
|
||||
{
|
||||
get { return channelVolume; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Audio Volume Notification Data
|
||||
/// </summary>
|
||||
/// <param name="eventContext"></param>
|
||||
/// <param name="muted"></param>
|
||||
/// <param name="masterVolume"></param>
|
||||
/// <param name="channelVolume"></param>
|
||||
/// <param name="guid"></param>
|
||||
public AudioVolumeNotificationData(Guid eventContext, bool muted, float masterVolume, float[] channelVolume, Guid guid)
|
||||
{
|
||||
this.eventContext = eventContext;
|
||||
this.muted = muted;
|
||||
this.masterVolume = masterVolume;
|
||||
channels = channelVolume.Length;
|
||||
this.channelVolume = channelVolume;
|
||||
this.guid = guid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a96bfcae2cdcb38459d6276cbd2eefa7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// The EDataFlow enumeration defines constants that indicate the direction
|
||||
/// in which audio data flows between an audio endpoint device and an application
|
||||
/// </summary>
|
||||
public enum DataFlow
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio rendering stream.
|
||||
/// Audio data flows from the application to the audio endpoint device, which renders the stream.
|
||||
/// </summary>
|
||||
Render,
|
||||
/// <summary>
|
||||
/// Audio capture stream. Audio data flows from the audio endpoint device that captures the stream,
|
||||
/// to the application
|
||||
/// </summary>
|
||||
Capture,
|
||||
/// <summary>
|
||||
/// Audio rendering or capture stream. Audio data can flow either from the application to the audio
|
||||
/// endpoint device, or from the audio endpoint device to the application.
|
||||
/// </summary>
|
||||
All
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78249ef88ae0d554bbd08d9d26bb2911
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
// adapted for NAudio,
|
||||
// updated to be in line with http://msdn.microsoft.com/en-us/library/dd370823%28v=vs.85%29.aspx
|
||||
using System;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Device State
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DeviceState
|
||||
{
|
||||
/// <summary>
|
||||
/// DEVICE_STATE_ACTIVE
|
||||
/// </summary>
|
||||
Active = 0x00000001,
|
||||
/// <summary>
|
||||
/// DEVICE_STATE_DISABLED
|
||||
/// </summary>
|
||||
Disabled = 0x00000002,
|
||||
/// <summary>
|
||||
/// DEVICE_STATE_NOTPRESENT
|
||||
/// </summary>
|
||||
NotPresent = 0x00000004,
|
||||
/// <summary>
|
||||
/// DEVICE_STATE_UNPLUGGED
|
||||
/// </summary>
|
||||
Unplugged = 0x00000008,
|
||||
/// <summary>
|
||||
/// DEVICE_STATEMASK_ALL
|
||||
/// </summary>
|
||||
All = 0x0000000F
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0e2f7774f6b928478d0f98e34b811dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace NAudio.CoreAudioApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Endpoint Hardware Support
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum EEndpointHardwareSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// Volume
|
||||
/// </summary>
|
||||
Volume = 0x00000001,
|
||||
/// <summary>
|
||||
/// Mute
|
||||
/// </summary>
|
||||
Mute = 0x00000002,
|
||||
/// <summary>
|
||||
/// Meter
|
||||
/// </summary>
|
||||
Meter = 0x00000004
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f25c53b846f4fc14bb669c766b2f6c5d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 839424e4ce312b84fbecc270ee3a12f7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
internal struct AudioVolumeNotificationDataStruct
|
||||
{
|
||||
public Guid guidEventContext;
|
||||
public bool bMuted;
|
||||
public float fMasterVolume;
|
||||
public uint nChannels;
|
||||
public float ChannelVolume;
|
||||
|
||||
//Code Should Compile at warning level4 without any warnings,
|
||||
//However this struct will give us Warning CS0649: Field [Fieldname]
|
||||
//is never assigned to, and will always have its default value
|
||||
//You can disable CS0649 in the project options but that will disable
|
||||
//the warning for the whole project, it's a nice warning and we do want
|
||||
//it in other places so we make a nice dummy function to keep the compiler
|
||||
//happy.
|
||||
private void FixCS0649()
|
||||
{
|
||||
guidEventContext = Guid.Empty;
|
||||
bMuted = false;
|
||||
fMasterVolume = 0;
|
||||
nChannels = 0;
|
||||
ChannelVolume = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0836d3a7bc79c3449fd114cedd50316
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
// Adapted for NAudio
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Representation of binary large object container.
|
||||
/// </summary>
|
||||
public struct Blob
|
||||
{
|
||||
/// <summary>
|
||||
/// Length of binary object.
|
||||
/// </summary>
|
||||
public int Length;
|
||||
/// <summary>
|
||||
/// Pointer to buffer storing data.
|
||||
/// </summary>
|
||||
public IntPtr Data;
|
||||
|
||||
//Code Should Compile at warning level4 without any warnings,
|
||||
//However this struct will give us Warning CS0649: Field [Fieldname]
|
||||
//is never assigned to, and will always have its default value
|
||||
//You can disable CS0649 in the project options but that will disable
|
||||
//the warning for the whole project, it's a nice warning and we do want
|
||||
//it in other places so we make a nice dummy function to keep the compiler
|
||||
//happy.
|
||||
private void FixCS0649()
|
||||
{
|
||||
Length = 0;
|
||||
Data = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78e5f968a86b62f43a324078f4a06df2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// is defined in WTypes.h
|
||||
/// </summary>
|
||||
[Flags]
|
||||
enum ClsCtx
|
||||
{
|
||||
INPROC_SERVER = 0x1,
|
||||
INPROC_HANDLER = 0x2,
|
||||
LOCAL_SERVER = 0x4,
|
||||
INPROC_SERVER16 = 0x8,
|
||||
REMOTE_SERVER = 0x10,
|
||||
INPROC_HANDLER16 = 0x20,
|
||||
//RESERVED1 = 0x40,
|
||||
//RESERVED2 = 0x80,
|
||||
//RESERVED3 = 0x100,
|
||||
//RESERVED4 = 0x200,
|
||||
NO_CODE_DOWNLOAD = 0x400,
|
||||
//RESERVED5 = 0x800,
|
||||
NO_CUSTOM_MARSHAL = 0x1000,
|
||||
ENABLE_CODE_DOWNLOAD = 0x2000,
|
||||
NO_FAILURE_LOG = 0x4000,
|
||||
DISABLE_AAA = 0x8000,
|
||||
ENABLE_AAA = 0x10000,
|
||||
FROM_DEFAULT_CONTEXT = 0x20000,
|
||||
ACTIVATE_32_BIT_SERVER = 0x40000,
|
||||
ACTIVATE_64_BIT_SERVER = 0x80000,
|
||||
ENABLE_CLOAKING = 0x100000,
|
||||
PS_DLL = unchecked ( (int) 0x80000000 ),
|
||||
INPROC = INPROC_SERVER | INPROC_HANDLER,
|
||||
SERVER = INPROC_SERVER | LOCAL_SERVER | REMOTE_SERVER,
|
||||
ALL = SERVER | INPROC_HANDLER
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42c523645eb94624f840e795a27f35e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,66 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NAudio.Utils;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio Client WASAPI Error Codes (HResult)
|
||||
/// </summary>
|
||||
public enum AudioClientErrors
|
||||
{
|
||||
/// <summary>
|
||||
/// AUDCLNT_E_NOT_INITIALIZED
|
||||
/// </summary>
|
||||
NotInitialized = unchecked((int)0x88890001),
|
||||
/// <summary>
|
||||
/// AUDCLNT_E_UNSUPPORTED_FORMAT
|
||||
/// </summary>
|
||||
UnsupportedFormat = unchecked((int)0x88890008),
|
||||
/// <summary>
|
||||
/// AUDCLNT_E_DEVICE_IN_USE
|
||||
/// </summary>
|
||||
DeviceInUse = unchecked((int)0x8889000A),
|
||||
/// <summary>
|
||||
/// AUDCLNT_E_RESOURCES_INVALIDATED
|
||||
/// </summary>
|
||||
ResourcesInvalidated = unchecked((int)0x88890026),
|
||||
}
|
||||
|
||||
static class ErrorCodes
|
||||
{
|
||||
// AUDCLNT_ERR(n) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, n)
|
||||
// AUDCLNT_SUCCESS(n) MAKE_SCODE(SEVERITY_SUCCESS, FACILITY_AUDCLNT, n)
|
||||
// ReSharper disable InconsistentNaming
|
||||
public const int SEVERITY_ERROR = 1;
|
||||
public const int FACILITY_AUDCLNT = 0x889;
|
||||
public static readonly int AUDCLNT_E_NOT_INITIALIZED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x001);
|
||||
public static readonly int AUDCLNT_E_ALREADY_INITIALIZED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x002);
|
||||
public static readonly int AUDCLNT_E_WRONG_ENDPOINT_TYPE = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x003);
|
||||
public static readonly int AUDCLNT_E_DEVICE_INVALIDATED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x004);
|
||||
public static readonly int AUDCLNT_E_NOT_STOPPED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x005);
|
||||
public static readonly int AUDCLNT_E_BUFFER_TOO_LARGE = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x006);
|
||||
public static readonly int AUDCLNT_E_OUT_OF_ORDER = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x007);
|
||||
public static readonly int AUDCLNT_E_UNSUPPORTED_FORMAT = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x008);
|
||||
public static readonly int AUDCLNT_E_INVALID_SIZE = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x009);
|
||||
public static readonly int AUDCLNT_E_DEVICE_IN_USE = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x00A);
|
||||
public static readonly int AUDCLNT_E_BUFFER_OPERATION_PENDING = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x00B);
|
||||
public static readonly int AUDCLNT_E_THREAD_NOT_REGISTERED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x00C);
|
||||
public static readonly int AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x00E);
|
||||
public static readonly int AUDCLNT_E_ENDPOINT_CREATE_FAILED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x00F);
|
||||
public static readonly int AUDCLNT_E_SERVICE_NOT_RUNNING = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x010);
|
||||
public static readonly int AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x011);
|
||||
public static readonly int AUDCLNT_E_EXCLUSIVE_MODE_ONLY = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x0012);
|
||||
public static readonly int AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x013);
|
||||
public static readonly int AUDCLNT_E_EVENTHANDLE_NOT_SET = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x014);
|
||||
public static readonly int AUDCLNT_E_INCORRECT_BUFFER_SIZE = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x015);
|
||||
public static readonly int AUDCLNT_E_BUFFER_SIZE_ERROR = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x016);
|
||||
public static readonly int AUDCLNT_E_CPUUSAGE_EXCEEDED = HResult.MAKE_HRESULT(SEVERITY_ERROR, FACILITY_AUDCLNT, 0x017);
|
||||
public static readonly int AUDCLNT_E_RESOURCES_INVALIDATED = unchecked((int) 0x88890026);
|
||||
// ReSharper restore InconsistentNaming
|
||||
/*static readonly int AUDCLNT_S_BUFFER_EMPTY AUDCLNT_SUCCESS(0x001)
|
||||
static readonly int AUDCLNT_S_THREAD_ALREADY_REGISTERED AUDCLNT_SUCCESS(0x002)
|
||||
static readonly int AUDCLNT_S_POSITION_STALLED AUDCLNT_SUCCESS(0x003)*/
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9d37ab47ed6e1c408aa46667cd77c0b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,34 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
|
||||
|
||||
[Guid("C8ADBD64-E71E-48a0-A4DE-185C395CD317"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
interface IAudioCaptureClient
|
||||
{
|
||||
/*HRESULT GetBuffer(
|
||||
BYTE** ppData,
|
||||
UINT32* pNumFramesToRead,
|
||||
DWORD* pdwFlags,
|
||||
UINT64* pu64DevicePosition,
|
||||
UINT64* pu64QPCPosition
|
||||
);*/
|
||||
|
||||
int GetBuffer(
|
||||
out IntPtr dataBuffer,
|
||||
out int numFramesToRead,
|
||||
out AudioClientBufferFlags bufferFlags,
|
||||
out long devicePosition,
|
||||
out long qpcPosition);
|
||||
|
||||
int ReleaseBuffer(int numFramesRead);
|
||||
|
||||
int GetNextPacketSize(out int numFramesInNextPacket);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e17c700f3a6a899419af842802610b80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,61 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using NAudio.Wave;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Windows CoreAudio IAudioClient interface
|
||||
/// Defined in AudioClient.h
|
||||
/// </summary>
|
||||
[Guid("1CB9AD4C-DBFA-4c32-B178-C2F568A703B2"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
|
||||
ComImport]
|
||||
internal interface IAudioClient
|
||||
{
|
||||
[PreserveSig]
|
||||
int Initialize(AudioClientShareMode shareMode,
|
||||
AudioClientStreamFlags streamFlags,
|
||||
long hnsBufferDuration, // REFERENCE_TIME
|
||||
long hnsPeriodicity, // REFERENCE_TIME
|
||||
[In] WaveFormat pFormat,
|
||||
[In] ref Guid audioSessionGuid);
|
||||
|
||||
/// <summary>
|
||||
/// The GetBufferSize method retrieves the size (maximum capacity) of the endpoint buffer.
|
||||
/// </summary>
|
||||
int GetBufferSize(out uint bufferSize);
|
||||
|
||||
[return: MarshalAs(UnmanagedType.I8)]
|
||||
long GetStreamLatency();
|
||||
|
||||
int GetCurrentPadding(out int currentPadding);
|
||||
|
||||
[PreserveSig]
|
||||
int IsFormatSupported(
|
||||
AudioClientShareMode shareMode,
|
||||
[In] WaveFormat pFormat,
|
||||
IntPtr closestMatchFormat);
|
||||
|
||||
int GetMixFormat(out IntPtr deviceFormatPointer);
|
||||
|
||||
// REFERENCE_TIME is 64 bit int
|
||||
int GetDevicePeriod(out long defaultDevicePeriod, out long minimumDevicePeriod);
|
||||
|
||||
int Start();
|
||||
|
||||
int Stop();
|
||||
|
||||
int Reset();
|
||||
|
||||
int SetEventHandle(IntPtr eventHandle);
|
||||
|
||||
/// <summary>
|
||||
/// The GetService method accesses additional services from the audio client object.
|
||||
/// </summary>
|
||||
/// <param name="interfaceId">The interface ID for the requested service.</param>
|
||||
/// <param name="interfacePointer">Pointer to a pointer variable into which the method writes the address of an instance of the requested interface. </param>
|
||||
[PreserveSig]
|
||||
int GetService([In, MarshalAs(UnmanagedType.LPStruct)] Guid interfaceId, [Out, MarshalAs(UnmanagedType.IUnknown)] out object interfacePointer);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d567d49a7f8a7b48b20954cd6c16dad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,35 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Defined in AudioClient.h
|
||||
/// </summary>
|
||||
[Guid("CD63314F-3FBA-4a1b-812C-EF96358728E7"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface IAudioClock
|
||||
{
|
||||
[PreserveSig]
|
||||
int GetFrequency(out ulong frequency);
|
||||
|
||||
[PreserveSig]
|
||||
int GetPosition(out ulong devicePosition, out ulong qpcPosition);
|
||||
|
||||
[PreserveSig]
|
||||
int GetCharacteristics(out uint characteristics);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defined in AudioClient.h
|
||||
/// </summary>
|
||||
[Guid("6f49ff73-6727-49AC-A008-D98CF5E70048"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface IAudioClock2 : IAudioClock
|
||||
{
|
||||
[PreserveSig]
|
||||
int GetDevicePosition(out ulong devicePosition, out ulong qpcPosition);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb0ad5003fe76d64290037f92ac376bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface IAudioEndpointVolume
|
||||
{
|
||||
int RegisterControlChangeNotify(IAudioEndpointVolumeCallback pNotify);
|
||||
int UnregisterControlChangeNotify(IAudioEndpointVolumeCallback pNotify);
|
||||
int GetChannelCount(out int pnChannelCount);
|
||||
int SetMasterVolumeLevel(float fLevelDB, ref Guid pguidEventContext);
|
||||
int SetMasterVolumeLevelScalar(float fLevel, ref Guid pguidEventContext);
|
||||
int GetMasterVolumeLevel(out float pfLevelDB);
|
||||
int GetMasterVolumeLevelScalar(out float pfLevel);
|
||||
int SetChannelVolumeLevel(uint nChannel, float fLevelDB, ref Guid pguidEventContext);
|
||||
int SetChannelVolumeLevelScalar(uint nChannel, float fLevel, ref Guid pguidEventContext);
|
||||
int GetChannelVolumeLevel(uint nChannel, out float pfLevelDB);
|
||||
int GetChannelVolumeLevelScalar(uint nChannel, out float pfLevel);
|
||||
int SetMute([MarshalAs(UnmanagedType.Bool)] Boolean bMute, ref Guid pguidEventContext);
|
||||
int GetMute(out bool pbMute);
|
||||
int GetVolumeStepInfo(out uint pnStep, out uint pnStepCount);
|
||||
int VolumeStepUp(ref Guid pguidEventContext);
|
||||
int VolumeStepDown(ref Guid pguidEventContext);
|
||||
int QueryHardwareSupport(out uint pdwHardwareSupportMask);
|
||||
int GetVolumeRange(out float pflVolumeMindB, out float pflVolumeMaxdB, out float pflVolumeIncrementdB);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8909dfd17d01b2d47856fda72eccf2c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
(Modified for NAudio by Mark Heath)
|
||||
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
[Guid("657804FA-D6AD-4496-8A60-352752AF4F89"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface IAudioEndpointVolumeCallback
|
||||
{
|
||||
void OnNotify(IntPtr notifyData);
|
||||
};
|
||||
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e51cde0c844461498d2a546cba34418
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
LICENSE
|
||||
-------
|
||||
Copyright (C) 2007 Ray Molenkamp
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this source code or the software it produces.
|
||||
|
||||
Permission is granted to anyone to use this source code for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
[Guid("C02216F6-8C67-4B5B-9D00-D008E73E0064"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface IAudioMeterInformation
|
||||
{
|
||||
int GetPeakValue(out float pfPeak);
|
||||
int GetMeteringChannelCount(out int pnChannelCount);
|
||||
int GetChannelsPeakValues(int u32ChannelCount, [In] IntPtr afPeakValues);
|
||||
int QueryHardwareSupport(out int pdwHardwareSupportMask);
|
||||
};
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fba18c1048759cf4e93c9e5c1c284de4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
[Guid("F294ACFC-3146-4483-A7BF-ADDCA7C260E2"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
|
||||
ComImport]
|
||||
interface IAudioRenderClient
|
||||
{
|
||||
int GetBuffer(int numFramesRequested, out IntPtr dataBufferPointer);
|
||||
int ReleaseBuffer(int numFramesWritten, AudioClientBufferFlags bufferFlags);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfd9dc6141ee0124d9e884913bde689d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,260 +0,0 @@
|
||||
// -----------------------------------------
|
||||
// SoundScribe (TM) and related software.
|
||||
//
|
||||
// Copyright (C) 2007-2011 Vannatech
|
||||
// http://www.vannatech.com
|
||||
// All rights reserved.
|
||||
//
|
||||
// This source code is subject to the MIT License.
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
// -----------------------------------------
|
||||
// milligan22963 - ported to nAudio
|
||||
// -----------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Windows CoreAudio IAudioSessionControl interface
|
||||
/// Defined in AudioPolicy.h
|
||||
/// </summary>
|
||||
[Guid("F4B1A599-7266-4319-A8CA-E70ACB11E8CD"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
public interface IAudioSessionControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the current state of the audio session.
|
||||
/// </summary>
|
||||
/// <param name="state">Receives the current session state.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int GetState(
|
||||
[Out] out AudioSessionState state);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the display name for the audio session.
|
||||
/// </summary>
|
||||
/// <param name="displayName">Receives a string that contains the display name.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int GetDisplayName(
|
||||
[Out] [MarshalAs(UnmanagedType.LPWStr)] out string displayName);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns a display name to the current audio session.
|
||||
/// </summary>
|
||||
/// <param name="displayName">A string that contains the new display name for the session.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int SetDisplayName(
|
||||
[In] [MarshalAs(UnmanagedType.LPWStr)] string displayName,
|
||||
[In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the path for the display icon for the audio session.
|
||||
/// </summary>
|
||||
/// <param name="iconPath">Receives a string that specifies the fully qualified path of the file that contains the icon.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int GetIconPath(
|
||||
[Out] [MarshalAs(UnmanagedType.LPWStr)] out string iconPath);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns a display icon to the current session.
|
||||
/// </summary>
|
||||
/// <param name="iconPath">A string that specifies the fully qualified path of the file that contains the new icon.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int SetIconPath(
|
||||
[In] [MarshalAs(UnmanagedType.LPWStr)] string iconPath,
|
||||
[In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the grouping parameter of the audio session.
|
||||
/// </summary>
|
||||
/// <param name="groupingId">Receives the grouping parameter ID.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int GetGroupingParam(
|
||||
[Out] out Guid groupingId);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns a session to a grouping of sessions.
|
||||
/// </summary>
|
||||
/// <param name="groupingId">The new grouping parameter ID.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int SetGroupingParam(
|
||||
[In] [MarshalAs(UnmanagedType.LPStruct)] Guid groupingId,
|
||||
[In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Registers the client to receive notifications of session events, including changes in the session state.
|
||||
/// </summary>
|
||||
/// <param name="client">A client-implemented <see cref="IAudioSessionEvents"/> interface.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int RegisterAudioSessionNotification(
|
||||
[In] IAudioSessionEvents client);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a previous registration by the client to receive notifications.
|
||||
/// </summary>
|
||||
/// <param name="client">A client-implemented <see cref="IAudioSessionEvents"/> interface.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int UnregisterAudioSessionNotification(
|
||||
[In] IAudioSessionEvents client);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Windows CoreAudio IAudioSessionControl interface
|
||||
/// Defined in AudioPolicy.h
|
||||
/// </summary>
|
||||
[Guid("bfb7ff88-7239-4fc9-8fa2-07c950be9c6d"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
public interface IAudioSessionControl2 : IAudioSessionControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the current state of the audio session.
|
||||
/// </summary>
|
||||
/// <param name="state">Receives the current session state.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
new int GetState(
|
||||
[Out] out AudioSessionState state);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the display name for the audio session.
|
||||
/// </summary>
|
||||
/// <param name="displayName">Receives a string that contains the display name.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
new int GetDisplayName(
|
||||
[Out] [MarshalAs(UnmanagedType.LPWStr)] out string displayName);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns a display name to the current audio session.
|
||||
/// </summary>
|
||||
/// <param name="displayName">A string that contains the new display name for the session.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
new int SetDisplayName(
|
||||
[In] [MarshalAs(UnmanagedType.LPWStr)] string displayName,
|
||||
[In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the path for the display icon for the audio session.
|
||||
/// </summary>
|
||||
/// <param name="iconPath">Receives a string that specifies the fully qualified path of the file that contains the icon.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
new int GetIconPath(
|
||||
[Out] [MarshalAs(UnmanagedType.LPWStr)] out string iconPath);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns a display icon to the current session.
|
||||
/// </summary>
|
||||
/// <param name="iconPath">A string that specifies the fully qualified path of the file that contains the new icon.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
new int SetIconPath(
|
||||
[In] [MarshalAs(UnmanagedType.LPWStr)] string iconPath,
|
||||
[In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the grouping parameter of the audio session.
|
||||
/// </summary>
|
||||
/// <param name="groupingId">Receives the grouping parameter ID.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
new int GetGroupingParam(
|
||||
[Out] out Guid groupingId);
|
||||
|
||||
/// <summary>
|
||||
/// Assigns a session to a grouping of sessions.
|
||||
/// </summary>
|
||||
/// <param name="groupingId">The new grouping parameter ID.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
new int SetGroupingParam(
|
||||
[In] [MarshalAs(UnmanagedType.LPStruct)] Guid groupingId,
|
||||
[In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Registers the client to receive notifications of session events, including changes in the session state.
|
||||
/// </summary>
|
||||
/// <param name="client">A client-implemented <see cref="IAudioSessionEvents"/> interface.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
new int RegisterAudioSessionNotification(
|
||||
[In] IAudioSessionEvents client);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a previous registration by the client to receive notifications.
|
||||
/// </summary>
|
||||
/// <param name="client">A client-implemented <see cref="IAudioSessionEvents"/> interface.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
new int UnregisterAudioSessionNotification(
|
||||
[In] IAudioSessionEvents client);
|
||||
/// <summary>
|
||||
/// Retrieves the identifier for the audio session.
|
||||
/// </summary>
|
||||
/// <param name="retVal">Receives the session identifier.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int GetSessionIdentifier(
|
||||
[Out] [MarshalAs(UnmanagedType.LPWStr)] out string retVal);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the identifier of the audio session instance.
|
||||
/// </summary>
|
||||
/// <param name="retVal">Receives the identifier of a particular instance.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int GetSessionInstanceIdentifier(
|
||||
[Out] [MarshalAs(UnmanagedType.LPWStr)] out string retVal);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the process identifier of the audio session.
|
||||
/// </summary>
|
||||
/// <param name="retVal">Receives the process identifier of the audio session.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int GetProcessId(
|
||||
[Out] out UInt32 retVal);
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the session is a system sounds session.
|
||||
/// </summary>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int IsSystemSoundsSession();
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables the default stream attenuation experience (auto-ducking) provided by the system.
|
||||
/// </summary>
|
||||
/// <param name="optOut">A variable that enables or disables system auto-ducking.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int SetDuckingPreference(bool optOut);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10d7bb651d86c2e42bad2af0ac0e06ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
[Guid("E2F5BB11-0570-40CA-ACDD-3AA01277DEE8"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
internal interface IAudioSessionEnumerator
|
||||
{
|
||||
int GetCount(out int sessionCount);
|
||||
|
||||
int GetSession(int sessionCount, out IAudioSessionControl session);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5f5ea1b27e646845934380be75b7f29
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,177 +0,0 @@
|
||||
// -----------------------------------------
|
||||
// SoundScribe (TM) and related software.
|
||||
//
|
||||
// Copyright (C) 2007-2011 Vannatech
|
||||
// http://www.vannatech.com
|
||||
// All rights reserved.
|
||||
//
|
||||
// This source code is subject to the MIT License.
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
// -----------------------------------------
|
||||
// milligan22963 - ported to nAudio
|
||||
// -----------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAudio.CoreAudioApi.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines constants that indicate the current state of an audio session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// MSDN Reference: http://msdn.microsoft.com/en-us/library/dd370792.aspx
|
||||
/// </remarks>
|
||||
public enum AudioSessionState
|
||||
{
|
||||
/// <summary>
|
||||
/// The audio session is inactive.
|
||||
/// </summary>
|
||||
AudioSessionStateInactive = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The audio session is active.
|
||||
/// </summary>
|
||||
AudioSessionStateActive = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The audio session has expired.
|
||||
/// </summary>
|
||||
AudioSessionStateExpired = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines constants that indicate a reason for an audio session being disconnected.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// MSDN Reference: Unknown
|
||||
/// </remarks>
|
||||
public enum AudioSessionDisconnectReason
|
||||
{
|
||||
/// <summary>
|
||||
/// The user removed the audio endpoint device.
|
||||
/// </summary>
|
||||
DisconnectReasonDeviceRemoval = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The Windows audio service has stopped.
|
||||
/// </summary>
|
||||
DisconnectReasonServerShutdown = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The stream format changed for the device that the audio session is connected to.
|
||||
/// </summary>
|
||||
DisconnectReasonFormatChanged = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The user logged off the WTS session that the audio session was running in.
|
||||
/// </summary>
|
||||
DisconnectReasonSessionLogoff = 3,
|
||||
|
||||
/// <summary>
|
||||
/// The WTS session that the audio session was running in was disconnected.
|
||||
/// </summary>
|
||||
DisconnectReasonSessionDisconnected = 4,
|
||||
|
||||
/// <summary>
|
||||
/// The (shared-mode) audio session was disconnected to make the audio endpoint device available for an exclusive-mode connection.
|
||||
/// </summary>
|
||||
DisconnectReasonExclusiveModeOverride = 5
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Windows CoreAudio IAudioSessionControl interface
|
||||
/// Defined in AudioPolicy.h
|
||||
/// </summary>
|
||||
[Guid("24918ACC-64B3-37C1-8CA9-74A66E9957A8"),
|
||||
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
public interface IAudioSessionEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// Notifies the client that the display name for the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="displayName">The new display name for the session.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int OnDisplayNameChanged(
|
||||
[In] [MarshalAs(UnmanagedType.LPWStr)] string displayName,
|
||||
[In] ref Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the display icon for the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="iconPath">The path for the new display icon for the session.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int OnIconPathChanged(
|
||||
[In] [MarshalAs(UnmanagedType.LPWStr)] string iconPath,
|
||||
[In] ref Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the volume level or muting state of the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="volume">The new volume level for the audio session.</param>
|
||||
/// <param name="isMuted">The new muting state.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int OnSimpleVolumeChanged(
|
||||
[In] [MarshalAs(UnmanagedType.R4)] float volume,
|
||||
[In] [MarshalAs(UnmanagedType.Bool)] bool isMuted,
|
||||
[In] ref Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the volume level of an audio channel in the session submix has changed.
|
||||
/// </summary>
|
||||
/// <param name="channelCount">The channel count.</param>
|
||||
/// <param name="newVolumes">An array of volumnes cooresponding with each channel index.</param>
|
||||
/// <param name="channelIndex">The number of the channel whose volume level changed.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int OnChannelVolumeChanged(
|
||||
[In] [MarshalAs(UnmanagedType.U4)] UInt32 channelCount,
|
||||
[In] [MarshalAs(UnmanagedType.SysInt)] IntPtr newVolumes, // Pointer to float array
|
||||
[In] [MarshalAs(UnmanagedType.U4)] UInt32 channelIndex,
|
||||
[In] ref Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the grouping parameter for the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="groupingId">The new grouping parameter for the session.</param>
|
||||
/// <param name="eventContext">A user context value that is passed to the notification callback.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int OnGroupingParamChanged(
|
||||
[In] ref Guid groupingId,
|
||||
[In] ref Guid eventContext);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the stream-activity state of the session has changed.
|
||||
/// </summary>
|
||||
/// <param name="state">The new session state.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int OnStateChanged(
|
||||
[In] AudioSessionState state);
|
||||
|
||||
/// <summary>
|
||||
/// Notifies the client that the session has been disconnected.
|
||||
/// </summary>
|
||||
/// <param name="disconnectReason">The reason that the audio session was disconnected.</param>
|
||||
/// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
|
||||
[PreserveSig]
|
||||
int OnSessionDisconnected(
|
||||
[In] AudioSessionDisconnectReason disconnectReason);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 756a19b9791567d4d9a6843625e88f8a
|
||||
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