private void Dispose(bool Disposing) { if (disposed) { return; } disposed = true; Log.Global.WriteLine(MessageType.Info, "Closing wave in device."); if (waveIn != IntPtr.Zero) { Winmm.waveInStop(waveIn); } if (buffers != null) { foreach (InBuffer i in buffers) { i.Dispose(Disposing); } buffers = null; } if (waveIn != IntPtr.Zero) { Winmm.waveInClose(waveIn); } waveIn = IntPtr.Zero; }
public OutBuffer(IntPtr WaveOut, WAVEFORMATEX Format, int Count) : base(Format, Count) { waveOut = WaveOut; MmException.CheckThrow(Winmm.waveOutPrepareHeader(WaveOut, header, Marshal.SizeOf(header))); header.dwFlags |= WaveHdrFlags.WHDR_DONE; }
private void Dispose(bool Disposing) { if (disposed) { return; } disposed = true; Log.Global.WriteLine(MessageType.Info, "Closing wave out device."); if (waveOut != IntPtr.Zero) { Winmm.waveOutReset(waveOut); } if (buffers != null) { foreach (Buffer i in buffers) { i.Dispose(Disposing); } buffers = null; } if (waveOut != IntPtr.Zero) { Winmm.waveOutClose(waveOut); } waveOut = IntPtr.Zero; callback = null; }
public override void Dispose(bool Disposing) { if (disposed) { return; } Winmm.waveOutUnprepareHeader(waveOut, header, Marshal.SizeOf(header)); base.Dispose(Disposing); }
public override void Dispose(bool Disposing) { if (disposed) { return; } // Not checked intentionally. Winmm.waveInUnprepareHeader(waveIn, header, Marshal.SizeOf(header)); base.Dispose(Disposing); }
public WaveOut(int Device, WAVEFORMATEX Format, int BufferSize) { Log.Global.WriteLine(MessageType.Info, "Opening wave out device '{0}'.", Device); // Construct waveOut MmException.CheckThrow(Winmm.waveOutOpen(out waveOut, Device, ref Format, callback.SafeWaitHandle.DangerousGetHandle(), IntPtr.Zero, WaveOutOpenFlags.CALLBACK_NULL)); // Create buffers. buffers = new List <OutBuffer>(); for (int i = 0; i < 4; ++i) { buffers.Add(new OutBuffer(waveOut, Format, BufferSize)); } }
public WaveIn(int Device, WAVEFORMATEX Format, int BufferSize) { Log.Global.WriteLine(MessageType.Info, "Opening wave in device '{0}'.", Device); // Construct waveIn MmException.CheckThrow(Winmm.waveInOpen(out waveIn, Device, ref Format, IntPtr.Zero, IntPtr.Zero, WaveInOpenFlags.CALLBACK_NULL)); // Create buffers. buffers = new List <InBuffer>(); for (int i = 0; i < 4; ++i) { InBuffer b = new InBuffer(waveIn, Format, BufferSize); b.Record(); buffers.Add(b); } MmException.CheckThrow(Winmm.waveInStart(waveIn)); }
public Device() : base("Windows Audio") { List <Channel> channels = new List <Channel>(); int count = Winmm.waveOutGetNumDevs(); for (int i = 0; i < count; ++i) { WAVEOUTCAPS caps = new WAVEOUTCAPS(); MmException.CheckThrow(Winmm.waveOutGetDevCaps(new IntPtr(i), ref caps, (uint)Marshal.SizeOf(caps))); channels.Add(new Channel(caps.szPname, i)); } outputs = channels.ToArray(); channels = new List <Channel>(); count = Winmm.waveInGetNumDevs(); for (int i = 0; i < count; ++i) { WAVEINCAPS caps = new WAVEINCAPS(); MmException.CheckThrow(Winmm.waveInGetDevCaps(new IntPtr(i), ref caps, (uint)Marshal.SizeOf(caps))); channels.Add(new Channel(caps.szPname, i)); } inputs = channels.ToArray(); }
public void Play() { header.dwFlags &= ~WaveHdrFlags.WHDR_DONE; MmException.CheckThrow(Winmm.waveOutWrite(waveOut, header, Marshal.SizeOf(header))); }
public void Record() { header.dwFlags &= ~WaveHdrFlags.WHDR_DONE; MmException.CheckThrow(Winmm.waveInAddBuffer(waveIn, header, Marshal.SizeOf(header))); }
public InBuffer(IntPtr WaveIn, WAVEFORMATEX Format, int Count) : base(Format, Count) { waveIn = WaveIn; MmException.CheckThrow(Winmm.waveInPrepareHeader(waveIn, ref header, Marshal.SizeOf(header))); }