private void CreateWaveOut() { CloseWaveOut(); int latency = (int)comboBoxLatency.SelectedItem; if (radioButtonWaveOut.Checked) { WaveCallbackInfo callbackInfo = checkBoxWaveOutWindow.Checked ? WaveCallbackInfo.NewWindow() : WaveCallbackInfo.FunctionCallback(); WaveOut outputDevice = new WaveOut(callbackInfo); outputDevice.DesiredLatency = latency; waveOut = outputDevice; } else if (radioButtonDirectSound.Checked) { waveOut = new DirectSoundOut(latency); } else if (radioButtonAsio.Checked) { waveOut = new AsioOut((String)comboBoxAsioDriver.SelectedItem); buttonControlPanel.Enabled = true; } else { waveOut = new WasapiOut( checkBoxWasapiExclusiveMode.Checked ? AudioClientShareMode.Exclusive : AudioClientShareMode.Shared, checkBoxWasapiEventCallback.Checked, latency); } }
private void CreatePlayer() { if (player == null) { WaveOut waveOut = new WaveOut(WaveCallbackInfo.NewWindow()); waveOut.DesiredLatency = 200; // 200ms waveOut.NumberOfBuffers = 2; waveOut.DeviceNumber = 0; // default device player = waveOut; } }
public IWavePlayer CreateDevice(int latency) { IWavePlayer device; WaveCallbackStrategy strategy = CallbackStrategy;// waveOutSettingsPanel.CallbackStrategy; if (strategy == WaveCallbackStrategy.Event) { var waveOut = new WaveOutEvent(); waveOut.DeviceNumber = SelectedDeviceNumber;// waveOutSettingsPanel.SelectedDeviceNumber; waveOut.DesiredLatency = latency; device = waveOut; } else { WaveCallbackInfo callbackInfo = strategy == WaveCallbackStrategy.NewWindow ? WaveCallbackInfo.NewWindow() : WaveCallbackInfo.FunctionCallback(); WaveOut outputDevice = new WaveOut(callbackInfo); outputDevice.DeviceNumber = SelectedDeviceNumber;// waveOutSettingsPanel.SelectedDeviceNumber; outputDevice.DesiredLatency = latency; device = outputDevice; } // TODO: configurable number of buffers return(device); }
/// <summary> /// Creates a default WaveOut device /// WARNING: only use this constructor on a GUI thread /// </summary> public WaveOut() : this(WaveCallbackInfo.NewWindow()) { }
private void CreateWaveOut() { CloseWaveOut(); int latency = 300; int deviceId = GetDeviceId(comboxPlayDevices.SelectedItem as string); if (_waveCallbackStrategy == WaveCallbackStrategy.Event) { var waveOut = new WaveOutEvent(); waveOut.DeviceNumber = deviceId; waveOut.DesiredLatency = latency; _waveOut = waveOut; } else { WaveCallbackInfo callbackInfo = _waveCallbackStrategy == WaveCallbackStrategy.NewWindow ? WaveCallbackInfo.NewWindow() : WaveCallbackInfo.FunctionCallback(); WaveOut outputDevice = new WaveOut(callbackInfo); outputDevice.DeviceNumber = deviceId; outputDevice.DesiredLatency = latency; _waveOut = outputDevice; } _waveOut.PlaybackStopped += OnPlaybackStoped; }
public void graj() { WaveMixerStream32 mixer = new WaveMixerStream32 { AutoStop = false, }; IWavePlayer waveOutDevice; AudioFileReader audioFileReader; //waveOutDevice = new WaveOut(); waveOutDevice = new WaveOut(WaveCallbackInfo.NewWindow()); //if (stop_but.Checked) break; //Thread thread2 = new Thread(graj); //thread2.Start(); for (int i = 0; i <= 15; i++)//foreach nie zdał tu egzaminu, puszczał dzwiek dwa razy { if (stop == 1) { break; } if (tab[i] == 0) { //while(i<=15) //ilosc_sampli = 1; Thread.Sleep(ms); //if (i <= 14) progress++; //if (i == 15) progress = 0; } if (tab[i] == 1) { //ilosc_sampli = 1; //if (i <= 14) progress++; // if (i == 15) progress = 0; { // DeviceNumber = 1, // DesiredLatency = 300, // NumberOfBuffers = 3, }; // waveOutDevice.Init(mixer); try { AudioFileReader afr = new AudioFileReader(sampel); waveOutDevice.Init(afr); waveOutDevice.Play(); //int le = waveOutDevice.Play.; //if (waveOutDevice.PlaybackState == PlaybackState.Playing) //{ //while (i <= 15) Thread.Sleep(ms); } catch { if (string.IsNullOrEmpty(sampel)) { MessageBox.Show("wygląda na to, że zapomniałeś gdzieś wybrać jaki dźwiek mam grać :) wybierz sample klikając przyciski obok siatki, a następnie kliknij stop "); break; } //else continue; } //if (progressBar1.Value == 15) progressBar1.Value = 0; } } }
private void initWaveout(Object nothing) { WaveOut waveOut = new WaveOut(WaveCallbackInfo.NewWindow()); }
/// <summary> /// Creates the device. /// </summary> /// <param name="latency">The latency.</param> /// <returns></returns> public IWavePlayer CreateDevice(int latency) { IWavePlayer device; //Existing Window is the default, probably most suitable for Replayer. WaveCallbackStrategy strategy = WaveCallbackStrategy.ExistingWindow; WaveCallbackInfo callbackInfo = strategy == WaveCallbackStrategy.NewWindow ? WaveCallbackInfo.NewWindow() : WaveCallbackInfo.FunctionCallback(); WaveOut outputDevice = new WaveOut(callbackInfo) { DeviceNumber = waveOutSettingsPanel.SelectedDeviceNumber, DesiredLatency = latency }; device = outputDevice; return(device); }
/// <summary> /// Creates a default WaveOut device /// Will use window callbacks if called from a GUI thread, otherwise function /// callbacks /// </summary> public WaveOut() : this(SynchronizationContext.Current == null ? WaveCallbackInfo.FunctionCallback() : WaveCallbackInfo.NewWindow()) { }