public DirectSoundException(DSResult result, string interfaceName, string member) : base(String.Format("{0}.{1} returned 0x{2:x} ({3})", interfaceName, member, result, result), (int)result) { Result = result; InterfaceName = interfaceName; Member = member; }
/// <summary> /// Throws an <see cref="DirectSoundException" /> if the <paramref name="result" /> is not /// <see cref="DSResult.Ok" />. /// </summary> /// <param name="result">Errorcode.</param> /// <param name="interfaceName"> /// Name of the interface which contains the COM-function which returned the specified /// <paramref name="result" />. /// </param> /// <param name="member">Name of the COM-function which returned the specified <paramref name="result" />.</param> public static void Try(DSResult result, string interfaceName, string member) { if (result != DSResult.Ok) { throw new DirectSoundException(result, interfaceName, member); } }
public DirectSoundException(DSResult result, string interfaceName, string member) : base(String.Format("{0}.{1} returned 0x{2:x} ({3})", interfaceName, member, result, result), (int)result) { Result = result; InterfaceName = interfaceName; Member = member; }
/// <summary> /// Returns the attenuation of the sound. /// </summary> /// <returns>The attenuation, in hundredths of a decibel.</returns> public int GetVolume() { int dwvolume; DSResult result = GetVolumeNative(out dwvolume); DirectSoundException.Try(result, InterfaceName, "GetVolume"); return(dwvolume); }
public DSResult GetVolume(out double volume) { int dwvolume; DSResult result = GetVolume(out dwvolume); if (result != DSResult.DS_OK) { volume = 0f; } else { const double z1 = 0.001; //(1/100)/(dv) volume = (MinAttentuation - Math.Pow(2, z1 * dwvolume)) / (MinAttentuation - 1); volume = Math.Min(1, Math.Max(0, volume)); } return(result); }
/// <summary> /// Returns a description of the format of the sound data in the buffer. /// </summary> /// <returns>A description of the format of the sound data in the buffer. The returned description is either of the type <see cref="WaveFormat"/> or of the type <see cref="WaveFormatExtensible"/>.</returns> public WaveFormat GetWaveFormat() { int size; DSResult result = GetFormatNative(IntPtr.Zero, 0, out size); DirectSoundException.Try(result, InterfaceName, "GetWaveFormat"); IntPtr ptr = Marshal.AllocCoTaskMem(size); try { int n; result = GetFormatNative(ptr, size, out n); DirectSoundException.Try(result, InterfaceName, "GetWaveFormat"); return(WaveFormatMarshaler.PointerToWaveFormat(ptr)); } finally { Marshal.FreeCoTaskMem(ptr); } }
/// <summary> /// Initializes a new instance of the <see cref="DirectSoundException" /> class. /// </summary> /// <param name="result">The Errorcode.</param> /// <param name="interfaceName"> /// Name of the interface which contains the COM-function which returned the specified /// <paramref name="result" />. /// </param> /// <param name="member">Name of the COM-function which returned the specified <paramref name="result" />.</param> public DirectSoundException(DSResult result, string interfaceName, string member) : this((int)result, interfaceName, member) { }
public static void Try(DSResult result, string interfaceName, string member) { if (result != DSResult.DS_OK) throw new DirectSoundException(result, interfaceName, member); }
/// <summary> /// Initializes a new instance of the <see cref="DirectSoundException" /> class. /// </summary> /// <param name="result">The Errorcode.</param> /// <param name="interfaceName"> /// Name of the interface which contains the COM-function which returned the specified /// <paramref name="result" />. /// </param> /// <param name="member">Name of the COM-function which returned the specified <paramref name="result" />.</param> public DirectSoundException(DSResult result, string interfaceName, string member) : this((int) result, interfaceName, member) { }