コード例 #1
0
        /// <summary>
        /// Creates a new Wave input stream
        /// </summary>
        /// <param name="deviceNumber">The device to open - 0 is default</param>
        /// <param name="desiredFormat">The PCM format to record in</param>
        /// <param name="callbackWindow">If this parameter is non-null, the Wave In Messages
        /// will be sent to the message loop of the supplied control. This is considered a
        /// safer way to use the waveIn functionality</param>
        public WaveInStream(int deviceNumber, WaveFormat desiredFormat, System.Windows.Forms.Control callbackWindow)
        {
            this.waveFormat = desiredFormat;
            callback = new WaveInterop.WaveCallback(Callback);
            if (callbackWindow == null)
            {
                MmException.Try(WaveInterop.waveInOpen(out waveInHandle, deviceNumber, desiredFormat, callback, 0, WaveInterop.CallbackFunction), "waveInOpen");
            }
            else
            {
                waveInWindow = new WaveWindowNative(callback);
                MmException.Try(WaveInterop.waveInOpenWindow(out waveInHandle, deviceNumber, desiredFormat, callbackWindow.Handle, 0, WaveInterop.CallbackWindow), "waveInOpen");
                waveInWindow.AssignHandle(callbackWindow.Handle);
            }

            // Default to three buffers of 100ms each
            int bufferSize = desiredFormat.AverageBytesPerSecond / 10;
            numBuffers = 3;

            buffers = new WaveInBuffer[numBuffers];
            for (int n = 0; n < numBuffers; n++)
            {
                buffers[n] = new WaveInBuffer(waveInHandle, bufferSize);
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates a new Wave input stream
        /// </summary>
        /// <param name="deviceNumber">The device to open - 0 is default</param>
        /// <param name="desiredFormat">The PCM format to record in</param>
        /// <param name="callbackWindow">If this parameter is non-null, the Wave In Messages
        /// will be sent to the message loop of the supplied control. This is considered a
        /// safer way to use the waveIn functionality</param>
        public WaveInStream(int deviceNumber, WaveFormat desiredFormat, System.Windows.Forms.Control callbackWindow)
        {
            this.waveFormat = desiredFormat;
            callback        = new WaveInterop.WaveCallback(Callback);
            if (callbackWindow == null)
            {
                MmException.Try(WaveInterop.waveInOpen(out waveInHandle, deviceNumber, desiredFormat, callback, 0, WaveInterop.CallbackFunction), "waveInOpen");
            }
            else
            {
                waveInWindow = new WaveWindowNative(callback);
                MmException.Try(WaveInterop.waveInOpenWindow(out waveInHandle, deviceNumber, desiredFormat, callbackWindow.Handle, 0, WaveInterop.CallbackWindow), "waveInOpen");
                waveInWindow.AssignHandle(callbackWindow.Handle);
            }

            // Default to three buffers of 100ms each
            int bufferSize = desiredFormat.AverageBytesPerSecond / 10;

            numBuffers = 3;

            buffers = new WaveInBuffer[numBuffers];
            for (int n = 0; n < numBuffers; n++)
            {
                buffers[n] = new WaveInBuffer(waveInHandle, bufferSize);
            }
        }
コード例 #3
0
 /// <summary>
 /// Controls playback of a sound stream.
 /// </summary>
 /// <param name="device">The playback device.</param>
 public WavePlayer(Device device)
 {
     _device       = device;
     _syncContext  = SynchronizationContext.Current;
     _callback     = new WaveInterop.WaveCallback(Callback);
     _callbackInfo = WaveCallbackInfo.NewWindow();
     _callbackInfo.Connect(_callback);
 }
コード例 #4
0
 internal void Connect(WaveInterop.WaveCallback callback)
 {
     if (Strategy == WaveCallbackStrategy.NewWindow)
     {
         _waveOutWindow = new WaveWindow(callback);
         _waveOutWindow.CreateControl();
         Handle = _waveOutWindow.Handle;
     }
 }
コード例 #5
0
ファイル: WaveIn.cs プロジェクト: teetow/teevegas
		/// <summary>
		/// Prepares a Wave input device for recording
		/// </summary>
		public WaveIn(WaveCallbackInfo callbackInfo)
		{
			DeviceNumber = 0;
			WaveFormat = new WaveFormat(8000, 16, 1);
			BufferMilliseconds = 100;
			NumberOfBuffers = 3;
			callback = Callback;
			this.callbackInfo = callbackInfo;
			callbackInfo.Connect(callback);
		}
コード例 #6
0
 /// <summary>
 /// Prepares a Wave input device for recording
 /// </summary>
 public WaveIn(WaveCallbackInfo callbackInfo)
 {
     DeviceNumber       = 0;
     WaveFormat         = new WaveFormat(8000, 16, 1);
     BufferMilliseconds = 100;
     NumberOfBuffers    = 3;
     callback           = Callback;
     this.callbackInfo  = callbackInfo;
     callbackInfo.Connect(callback);
 }
コード例 #7
0
 /// <summary>
 /// Opens a WaveOut device
 /// </summary>
 /// <param name="devNumber">This is the device number to open. 
 /// This must be between 0 and <see>DeviceCount</see> - 1.</param>
 /// <param name="desiredLatency">The number of milliseconds of audio to read before 
 /// streaming to the audio device. This will be broken into 3 buffers</param>
 public WaveOutThreadSafe(int devNumber, int desiredLatency)
 {
     this.devNumber = devNumber;
     this.desiredLatency = desiredLatency;
     this.callback = new WaveInterop.WaveCallback(Callback);
     actionQueue = new Queue<WaveOutAction>();
     workAvailable = new AutoResetEvent(false);
     waveOutThread = new Thread(new ThreadStart(ThreadProc));
     waveOutThread.Start();
 }
コード例 #8
0
 /// <summary>
 /// Opens a WaveOut device
 /// </summary>
 /// <param name="devNumber">This is the device number to open.
 /// This must be between 0 and <see>DeviceCount</see> - 1.</param>
 /// <param name="desiredLatency">The number of milliseconds of audio to read before
 /// streaming to the audio device. This will be broken into 3 buffers</param>
 public WaveOutThreadSafe(int devNumber, int desiredLatency)
 {
     this.devNumber      = devNumber;
     this.desiredLatency = desiredLatency;
     this.callback       = new WaveInterop.WaveCallback(Callback);
     actionQueue         = new Queue <WaveOutAction>();
     workAvailable       = new AutoResetEvent(false);
     waveOutThread       = new Thread(new ThreadStart(ThreadProc));
     waveOutThread.Start();
 }
コード例 #9
0
ファイル: WaveIn.cs プロジェクト: Punloeu/karaoke
 /// <summary>
 /// Prepares a Wave input device for recording
 /// </summary>
 public WaveIn(WaveCallbackInfo callbackInfo)
 {
     this.DeviceNumber = 0;
     this.WaveFormat = new WaveFormat(8000, 16, 1);
     this.BufferMillisconds = 100;
     this.NumberOfBuffers = 3;
     this.callback = new WaveInterop.WaveCallback(Callback);
     this.callbackInfo = callbackInfo;
     callbackInfo.Connect(this.callback);
 }
コード例 #10
0
ファイル: WaveIn.cs プロジェクト: hainam2101/karaoke
 /// <summary>
 /// Prepares a Wave input device for recording
 /// </summary>
 public WaveIn(WaveCallbackInfo callbackInfo)
 {
     this.DeviceNumber      = 0;
     this.WaveFormat        = new WaveFormat(8000, 16, 1);
     this.BufferMillisconds = 100;
     this.NumberOfBuffers   = 3;
     this.callback          = new WaveInterop.WaveCallback(Callback);
     this.callbackInfo      = callbackInfo;
     callbackInfo.Connect(this.callback);
 }
コード例 #11
0
        /// <summary>
        /// Opens a WaveOut device
        /// </summary>
        public WaveOut()
        {
            syncContext = SynchronizationContext.Current;
            WaveFilters = new List <IWaveFilter>();
            // set default values up
            DesiredLatency  = 300;
            NumberOfBuffers = 3;

            callback      = Callback;
            waveOutLock   = new object();
            disposingLock = new object();
        }
コード例 #12
0
        /// <summary>
        /// Opens a WaveOut device
        /// </summary>
        public WaveOut(WaveCallbackInfo callbackInfo)
        {
            // set default values up
            DeviceNumber    = 0;
            DesiredLatency  = 300;
            NumberOfBuffers = 3;

            callback          = Callback;
            waveOutLock       = new object();
            this.callbackInfo = callbackInfo;
            callbackInfo.Connect(callback);
        }
コード例 #13
0
        /// <summary>
        /// Opens a WaveOut device
        /// </summary>
        public WaveOut(WaveCallbackInfo callbackInfo)
        {
            syncContext = SynchronizationContext.Current;
            // set default values up
            DesiredLatency  = 300;
            NumberOfBuffers = 2;

            callback          = Callback;
            waveOutLock       = new object();
            this.callbackInfo = callbackInfo;
            callbackInfo.Connect(callback);
        }
コード例 #14
0
ファイル: WaveOut.cs プロジェクト: teetow/teevegas
		/// <summary>
		/// Opens a WaveOut device
		/// </summary>
		public WaveOut(WaveCallbackInfo callbackInfo)
		{
			// set default values up
			DeviceNumber = 0;
			DesiredLatency = 300;
			NumberOfBuffers = 3;

			callback = Callback;
			waveOutLock = new object();
			this.callbackInfo = callbackInfo;
			callbackInfo.Connect(callback);
		}
コード例 #15
0
ファイル: WaveOut.cs プロジェクト: hainam2101/karaoke
        /// <summary>
        /// Opens a WaveOut device
        /// </summary>
        public WaveOut(WaveCallbackInfo callbackInfo)
        {
            // set default values up
            this.DeviceNumber    = 0;
            this.DesiredLatency  = 300;
            this.NumberOfBuffers = 3;

            this.callback     = new WaveInterop.WaveCallback(Callback);
            this.waveOutLock  = new object();
            this.callbackInfo = callbackInfo;
            callbackInfo.Connect(this.callback);
        }
コード例 #16
0
ファイル: WaveOut.cs プロジェクト: RasterCode/OtterUI
        /// <summary>
        /// Opens a WaveOut device
        /// </summary>
        public WaveOut(WaveCallbackInfo callbackInfo)
        {
            // set default values up
            this.DeviceNumber = 0;
            this.DesiredLatency = 300;
            this.NumberOfBuffers = 3;

            this.callback = new WaveInterop.WaveCallback(Callback);
            this.waveOutLock = new object();
            this.callbackInfo = callbackInfo;
            callbackInfo.Connect(this.callback);
        }
コード例 #17
0
ファイル: WaveOut.cs プロジェクト: senlinms/naudio
        /// <summary>
        /// Opens a WaveOut device
        /// </summary>
        public WaveOut(WaveCallbackInfo callbackInfo)
        {
            this.syncContext = SynchronizationContext.Current;
            // set default values up
            this.DeviceNumber    = 0;
            this.DesiredLatency  = 300;
            this.NumberOfBuffers = 2;

            this.callback     = new WaveInterop.WaveCallback(Callback);
            this.waveOutLock  = new object();
            this.callbackInfo = callbackInfo;
            callbackInfo.Connect(this.callback);
        }
コード例 #18
0
ファイル: WaveOut.cs プロジェクト: aljordan/NAJAudio
        /// <summary>
        /// Opens a WaveOut device
        /// </summary>
        public WaveOut(WaveCallbackInfo callbackInfo)
        {
            this.syncContext = SynchronizationContext.Current;
            // set default values up
            this.DeviceNumber = 0;
            this.DesiredLatency = 300;
            this.NumberOfBuffers = 2;

            this.callback = new WaveInterop.WaveCallback(Callback);
            this.waveOutLock = new object();
            this.callbackInfo = callbackInfo;
            callbackInfo.Connect(this.callback);
        }
コード例 #19
0
ファイル: WaveCallbackInfo.cs プロジェクト: teetow/teevegas
 internal void Connect(WaveInterop.WaveCallback callback)
 {
     if (Strategy == WaveCallbackStrategy.NewWindow)
     {
         waveOutWindow = new WaveWindow(callback);
         waveOutWindow.CreateControl();
         Handle = waveOutWindow.Handle;
     }
     else if (Strategy == WaveCallbackStrategy.ExistingWindow)
     {
         waveOutWindowNative = new WaveWindowNative(callback);
         waveOutWindowNative.AssignHandle(Handle);
     }
 }
コード例 #20
0
 // Token: 0x060009E5 RID: 2533 RVA: 0x0001C7C8 File Offset: 0x0001A9C8
 internal void Connect(WaveInterop.WaveCallback callback)
 {
     if (this.Strategy == WaveCallbackStrategy.NewWindow)
     {
         this.waveOutWindow = new WaveWindow(callback);
         this.waveOutWindow.CreateControl();
         this.Handle = this.waveOutWindow.Handle;
         return;
     }
     if (this.Strategy == WaveCallbackStrategy.ExistingWindow)
     {
         this.waveOutWindowNative = new WaveWindowNative(callback);
         this.waveOutWindowNative.AssignHandle(this.Handle);
     }
 }
コード例 #21
0
 public WaveIn(WaveCallbackInfo callbackInfo)
 {
     this.syncContext = SynchronizationContext.Current;
     if ((callbackInfo.Strategy == WaveCallbackStrategy.NewWindow || callbackInfo.Strategy == WaveCallbackStrategy.ExistingWindow) && this.syncContext == null)
     {
         throw new InvalidOperationException("Use WaveInEvent to record on a background thread");
     }
     this.DeviceNumber       = 0;
     this.WaveFormat         = new WaveFormat(8000, 16, 1);
     this.BufferMilliseconds = 100;
     this.NumberOfBuffers    = 3;
     this.callback           = new WaveInterop.WaveCallback(this.Callback);
     this.callbackInfo       = callbackInfo;
     callbackInfo.Connect(this.callback);
 }
コード例 #22
0
 /// <summary>
 /// Prepares a Wave input device for recording
 /// </summary>
 public WaveIn(WaveCallbackInfo callbackInfo)
 {
     syncContext = SynchronizationContext.Current;
     if ((callbackInfo.Strategy == WaveCallbackStrategy.NewWindow || callbackInfo.Strategy == WaveCallbackStrategy.ExistingWindow) &&
         syncContext == null)
     {
         throw new InvalidOperationException("Use WaveInEvent to record on a background thread");
     }
     this.DeviceNumber = 0;
     this.WaveFormat = new WaveFormat(8000, 16, 1);
     this.BufferMilliseconds = 100;
     this.NumberOfBuffers = 3;
     this.callback = new WaveInterop.WaveCallback(Callback);
     this.callbackInfo = callbackInfo;
     callbackInfo.Connect(this.callback);
 }
コード例 #23
0
 internal void Connect(WaveInterop.WaveCallback callback)
 {
     /*
      * if (Strategy == WaveCallbackStrategy.NewWindow)
      * {
      * waveOutWindow = new WaveWindow(callback);
      * waveOutWindow.CreateControl();
      * this.Handle = waveOutWindow.Handle;
      * }
      * else if (Strategy == WaveCallbackStrategy.ExistingWindow)
      * {
      * waveOutWindowNative = new WaveWindowNative(callback);
      * waveOutWindowNative.AssignHandle(this.Handle);
      * }
      */
 }
コード例 #24
0
ファイル: WaveCallbackInfo.cs プロジェクト: phot-awe/NAudio
        internal void Connect(WaveInterop.WaveCallback callback)
        {
            if (Strategy == WaveCallbackStrategy.NewWindow)
            {
                throw new Exception("can't do on uwp'");
                //waveOutWindow = new WaveWindow(callback);
                //waveOutWindow.CreateControl();
                //this.Handle = waveOutWindow.Handle;
            }
            else if (Strategy == WaveCallbackStrategy.ExistingWindow)
            {
                throw new Exception("can't do on uwp'");
//                waveOutWindowNative = new WaveWindowNative(callback);
//              waveOutWindowNative.AssignHandle(this.Handle);
            }
        }
コード例 #25
0
ファイル: WaveCallbackInfo.cs プロジェクト: teetow/teevegas
        internal MmResult WaveInOpen(out IntPtr waveInHandle, int deviceNumber, WaveFormat waveFormat,
                                     WaveInterop.WaveCallback callback)
        {
            MmResult result;

            if (Strategy == WaveCallbackStrategy.FunctionCallback)
            {
                result = WaveInterop.waveInOpen(out waveInHandle, (IntPtr)deviceNumber, waveFormat, callback, IntPtr.Zero,
                                                WaveInterop.CallbackFunction);
            }
            else
            {
                result = WaveInterop.waveInOpenWindow(out waveInHandle, (IntPtr)deviceNumber, waveFormat, Handle, IntPtr.Zero,
                                                      WaveInterop.CallbackWindow);
            }
            return(result);
        }
コード例 #26
0
        /// <summary>
        /// Prepares a Wave input device for recording
        /// </summary>
        public WaveIn(WaveCallbackInfo callbackInfo)
        {
            syncContext = SynchronizationContext.Current;
            if ((callbackInfo.Strategy == WaveCallbackStrategy.NewWindow ||
                 callbackInfo.Strategy == WaveCallbackStrategy.ExistingWindow) &&
                syncContext == null)
            {
                throw new InvalidOperationException("使用Wave In Event在后台线程上录制");
            }

            DeviceNumber       = 0;
            WaveFormat         = new WaveFormat(8000, 16, 1);
            BufferMilliseconds = 100;
            NumberOfBuffers    = 3;
            callback           = Callback;
            this.callbackInfo  = callbackInfo;
            callbackInfo.Connect(callback);
        }
コード例 #27
0
        /// <summary>
        /// Prepares a Wave input device for recording
        /// </summary>
        public WaveIn(WaveCallbackInfo callbackInfo)
        {
            if (Application.Current != null)
            {
                dispatcher = Application.Current.Dispatcher;
            }

            syncContext = SynchronizationContext.Current;
            if ((callbackInfo.Strategy == WaveCallbackStrategy.NewWindow || callbackInfo.Strategy == WaveCallbackStrategy.ExistingWindow) && syncContext == null)
            {
                throw new InvalidOperationException("Use WaveInEvent to record on a background thread");
            }
            DeviceNumber       = 0;
            WaveFormat         = new WaveFormat(8000, 16, 1);
            BufferMilliseconds = 100;
            NumberOfBuffers    = 3;
            callback           = Callback;
            this.callbackInfo  = callbackInfo;
            callbackInfo.Connect(callback);
        }
コード例 #28
0
 internal void Connect(WaveInterop.WaveCallback callback)
 {
 }
コード例 #29
0
ファイル: WaveWindow.cs プロジェクト: aljordan/NAJAudio
 public WaveWindowNative(WaveInterop.WaveCallback waveCallback)
 {
     this.waveCallback = waveCallback;
 }
コード例 #30
0
ファイル: WaveInterop.cs プロジェクト: h4ltYu/EOS
 public static extern MmResult waveInOpen(out IntPtr hWaveIn, IntPtr uDeviceID, WaveFormat lpFormat, WaveInterop.WaveCallback dwCallback, IntPtr dwInstance, WaveInterop.WaveInOutOpenFlags dwFlags);
コード例 #31
0
ファイル: WaveWindowNative.cs プロジェクト: teetow/teevegas
 public WaveWindowNative(WaveInterop.WaveCallback waveCallback)
 {
     this.waveCallback = waveCallback;
 }
コード例 #32
0
ファイル: WaveWindow.cs プロジェクト: rdacomp/spectnetide
 public WaveWindow(WaveInterop.WaveCallback waveCallback)
 {
     _waveCallback = waveCallback;
 }
コード例 #33
0
        internal MmResult WaveOutOpen(out IntPtr waveOutHandle, int deviceNumber, WaveFormat waveFormat, WaveInterop.WaveCallback callback)
        {
            var result = Strategy == WaveCallbackStrategy.FunctionCallback
                ? WaveInterop.waveOutOpen(out waveOutHandle, (IntPtr)deviceNumber, waveFormat, callback, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackFunction)
                : WaveInterop.waveOutOpenWindow(out waveOutHandle, (IntPtr)deviceNumber, waveFormat, Handle, IntPtr.Zero, WaveInterop.WaveInOutOpenFlags.CallbackWindow);

            return(result);
        }