29 using System.Globalization;
30 using System.Runtime.InteropServices;
32 using SiliconStudio.Core;
34 namespace SiliconStudio.
Paradox.Audio.Wave
40 internal class WaveFormatExtensible : WaveFormat
42 private short wValidBitsPerSample;
47 public Guid GuidSubFormat;
52 public Speakers ChannelMask;
58 internal WaveFormatExtensible()
65 public WaveFormatExtensible(
int rate,
int bits,
int channels)
66 : base(rate, bits, channels)
68 waveFormatTag = WaveFormatEncoding.Extensible;
70 wValidBitsPerSample = (short)bits;
71 int dwChannelMask = 0;
72 for (
int n = 0; n < channels; n++)
73 dwChannelMask |= (1 << n);
74 ChannelMask = (Speakers)dwChannelMask;
78 GuidSubFormat = bits == 32 ?
new Guid(
"00000003-0000-0010-8000-00aa00389b71") : new Guid(
"00000001-0000-0010-8000-00aa00389b71");
81 protected override unsafe IntPtr MarshalToPtr()
83 var result = Marshal.AllocHGlobal(Utilities.SizeOf<__Native>());
84 __MarshalTo(ref *(__Native*)result);
88 [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 2)]
89 internal new struct __Native
91 public WaveFormat.__Native waveFormat;
93 public short wValidBitsPerSample;
95 public Speakers dwChannelMask;
97 public Guid subFormat;
100 internal void __MarshalFree()
102 waveFormat.__MarshalFree();
107 internal void __MarshalFrom(ref __Native @ref)
109 __MarshalFrom(ref @ref.waveFormat);
110 wValidBitsPerSample = @ref.wValidBitsPerSample;
111 ChannelMask = @ref.dwChannelMask;
112 GuidSubFormat = @ref.subFormat;
116 internal void __MarshalTo(ref __Native @ref)
118 __MarshalTo(ref @ref.waveFormat);
119 @ref.wValidBitsPerSample = wValidBitsPerSample;
120 @ref.dwChannelMask = ChannelMask;
121 @ref.subFormat = GuidSubFormat;
124 internal static __Native __NewNative()
127 __Native temp =
default(__Native);
128 temp.waveFormat.extraSize = 22;
136 public override string ToString()
138 return String.Format(
139 CultureInfo.InvariantCulture,
140 "{0} wBitsPerSample:{1} ChannelMask:{2} SubFormat:{3} extraSize:{4}",