/// <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); } }
/// <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); }
internal void Connect(WaveInterop.WaveCallback callback) { if (Strategy == WaveCallbackStrategy.NewWindow) { _waveOutWindow = new WaveWindow(callback); _waveOutWindow.CreateControl(); Handle = _waveOutWindow.Handle; } }
/// <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); }
/// <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(); }
/// <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(); }
/// <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); }
/// <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(); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
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); } }
// 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); } }
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); }
/// <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); }
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); * } */ }
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); } }
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); }
/// <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); }
/// <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); }
internal void Connect(WaveInterop.WaveCallback callback) { }
public WaveWindowNative(WaveInterop.WaveCallback waveCallback) { this.waveCallback = waveCallback; }
public static extern MmResult waveInOpen(out IntPtr hWaveIn, IntPtr uDeviceID, WaveFormat lpFormat, WaveInterop.WaveCallback dwCallback, IntPtr dwInstance, WaveInterop.WaveInOutOpenFlags dwFlags);
public WaveWindow(WaveInterop.WaveCallback waveCallback) { _waveCallback = waveCallback; }
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); }