Example #1
0
        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;
        }
Example #2
0
        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;
        }
Example #3
0
        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;
        }
Example #4
0
        public override void Dispose(bool Disposing)
        {
            if (disposed)
            {
                return;
            }

            Winmm.waveOutUnprepareHeader(waveOut, header, Marshal.SizeOf(header));

            base.Dispose(Disposing);
        }
Example #5
0
        public override void Dispose(bool Disposing)
        {
            if (disposed)
            {
                return;
            }

            // Not checked intentionally.
            Winmm.waveInUnprepareHeader(waveIn, header, Marshal.SizeOf(header));

            base.Dispose(Disposing);
        }
Example #6
0
        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));
            }
        }
Example #7
0
        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));
        }
Example #8
0
        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();
        }
Example #9
0
 public void Play()
 {
     header.dwFlags &= ~WaveHdrFlags.WHDR_DONE;
     MmException.CheckThrow(Winmm.waveOutWrite(waveOut, header, Marshal.SizeOf(header)));
 }
Example #10
0
 public void Record()
 {
     header.dwFlags &= ~WaveHdrFlags.WHDR_DONE;
     MmException.CheckThrow(Winmm.waveInAddBuffer(waveIn, header, Marshal.SizeOf(header)));
 }
Example #11
0
        public InBuffer(IntPtr WaveIn, WAVEFORMATEX Format, int Count) : base(Format, Count)
        {
            waveIn = WaveIn;

            MmException.CheckThrow(Winmm.waveInPrepareHeader(waveIn, ref header, Marshal.SizeOf(header)));
        }