public static void MakeEcho(MainWindow window, CheckBox checkBoxEcho) { if (!string.IsNullOrEmpty(FilePath)) { using (var file = new WaveStream(FilePath)) { var desc = new SoundBufferDescription { SizeInBytes = (int)file.Length, Flags = BufferFlags.ControlEffects, Format = file.Format }; var directorySound = new DirectSound(); directorySound.SetCooperativeLevel(window.Handle, CooperativeLevel.Priority); var secondarySoundBuffer = new SecondarySoundBuffer(directorySound, desc); if (checkBoxEcho.Checked) { var echo = SoundEffectGuid.StandardEcho; var guids = new[] { echo }; secondarySoundBuffer.SetEffects(guids); var data = new byte[desc.SizeInBytes]; file.Read(data, 0, (int)file.Length); secondarySoundBuffer.Write(data, 0, LockFlags.None); secondarySoundBuffer.Play(0, PlayFlags.None); checkBoxEcho.Enabled = false; } } } }
public DirectXDevice(AudioSource audio, IntPtr owner) : base(audio) { m_SoundDevice = new DS.DirectSound(); m_SoundDevice.SetCooperativeLevel(owner, CooperativeLevel.Normal); }