예제 #1
0
파일: WaveIn.cs 프로젝트: EnergonV/BestCS
 /// <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");
     }
     DeviceNumber = 0;
     WaveFormat = new WaveFormat(8000, 16, 1);
     BufferMilliseconds = 100;
     NumberOfBuffers = 3;
     callback = Callback;
     this.callbackInfo = callbackInfo;
     callbackInfo.Connect(callback);
 }
예제 #2
0
파일: WaveIn.cs 프로젝트: EnergonV/BestCS
 /// <summary>
 /// Dispose pattern
 /// </summary>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (recording)
             StopRecording();
         CloseWaveInDevice();
         if (callbackInfo != null)
         {
             callbackInfo.Disconnect();
             callbackInfo = null;
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Prepares a Wave input device for recording
 /// </summary>
 public WaveIn()
     : this(WaveCallbackInfo.NewWindow())
 {
 }
예제 #4
0
 /// <summary>
 /// Creates a WaveIn device using the specified window handle for callbacks
 /// </summary>
 /// <param name="windowHandle">A valid window handle</param>
 public WaveIn(IntPtr windowHandle)
     : this(WaveCallbackInfo.ExistingWindow(windowHandle))
 {
 }
예제 #5
0
파일: WaveOut.cs 프로젝트: EnergonV/BestCS
        /// <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);
        }