コード例 #1
0
ファイル: WaveInStream.cs プロジェクト: teetow/teevegas
		/// <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, Control callbackWindow)
		{
			waveFormat = desiredFormat;
			callback = Callback;
			if (callbackWindow == null)
			{
				MmException.Try(
					WaveInterop.waveInOpen(out waveInHandle, (IntPtr) deviceNumber, desiredFormat, callback, IntPtr.Zero,
					                       WaveInterop.CallbackFunction), "waveInOpen");
			}
			else
			{
				waveInWindow = new WaveWindowNative(callback);
				MmException.Try(
					WaveInterop.waveInOpenWindow(out waveInHandle, (IntPtr) deviceNumber, desiredFormat, callbackWindow.Handle,
					                             IntPtr.Zero, 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
ファイル: WaveInStream.cs プロジェクト: teetow/teevegas
        /// <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, Control callbackWindow)
        {
            waveFormat = desiredFormat;
            callback   = Callback;
            if (callbackWindow == null)
            {
                MmException.Try(
                    WaveInterop.waveInOpen(out waveInHandle, (IntPtr)deviceNumber, desiredFormat, callback, IntPtr.Zero,
                                           WaveInterop.CallbackFunction), "waveInOpen");
            }
            else
            {
                waveInWindow = new WaveWindowNative(callback);
                MmException.Try(
                    WaveInterop.waveInOpenWindow(out waveInHandle, (IntPtr)deviceNumber, desiredFormat, callbackWindow.Handle,
                                                 IntPtr.Zero, 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
ファイル: WaveIn.cs プロジェクト: teetow/teevegas
		private void CreateBuffers()
		{
			// Default to three buffers of 100ms each
			int bufferSize = BufferMilliseconds*WaveFormat.AverageBytesPerSecond/1000;

			buffers = new WaveInBuffer[NumberOfBuffers];
			for (int n = 0; n < buffers.Length; n++)
			{
				buffers[n] = new WaveInBuffer(waveInHandle, bufferSize);
			}
		}