void initDevs() { var ov = disregardEvents; disregardEvents = true; gOneS.Items.Clear(); gTwoS.Items.Clear(); gOutS.Items.Clear(); populate(true, gOutS, gOneS); populate(false, gTwoS); LSDevice nil = new LSDevice(); nil.name = "(disabled)"; gTwoS.Items.Insert(0, nil); gOneS.SelectedItem = settings.devRec; gTwoS.SelectedItem = settings.devMic; gOutS.SelectedItem = settings.devOut; if (settings.devMic == null || settings.devMic.mm == null) gTwoS.SelectedIndex = 0; disregardEvents = ov; }
void playFX(LSDevice dev) { if (unFxTimer == null) { unFxTimer = new Timer(); unFxTimer.Interval = 3000; unFxTimer.Tick += delegate(object oa, EventArgs ob) { unFX(); }; } try { if (disregardEvents) return; unFX(); fx_stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Loopstream.res.sc.wav"); //fx_mp3 = new NAudio.Wave.Mp3FileReader(fx_stream); fx_wav = new NAudio.Wave.WaveFileReader(fx_stream); fx_out = new NAudio.Wave.WasapiOut(dev.mm, NAudio.CoreAudioApi.AudioClientShareMode.Shared, false, 100); fx_out.Init(fx_wav); fx_out.Play(); unFxTimer.Start(); } catch { } }
public void init() { List<LSDevice> ldev = new List<LSDevice>(); try { NAudio.CoreAudioApi.MMDeviceEnumerator mde = new NAudio.CoreAudioApi.MMDeviceEnumerator(); Logger.app.a("Created MM enumerator"); try { foreach ( NAudio.CoreAudioApi.MMDevice device in mde.EnumerateAudioEndPoints( NAudio.CoreAudioApi.DataFlow.All, NAudio.CoreAudioApi.DeviceState.All)) { try { LSDevice add = new LSDevice(); add.mm = device; add.isRec = device.DataFlow == NAudio.CoreAudioApi.DataFlow.Capture; add.isPlay = device.DataFlow == NAudio.CoreAudioApi.DataFlow.Render; if (device.DataFlow == NAudio.CoreAudioApi.DataFlow.All) { add.isRec = add.isPlay = true; } Logger.app.a("Df " + add.isPlay + " " + add.isRec); add.id = device.ID; Logger.app.a("ID " + add.id); add.name = device.ToString(); Logger.app.a("Na " + add.name); ldev.Add(add); } catch { Logger.app.a("Failed !"); } } } catch { Logger.app.a("Failed !!"); } } catch { Logger.app.a("Failed !!!"); } devs = ldev.ToArray(); if (string.IsNullOrEmpty(s_devRec)) s_devRec = ""; if (string.IsNullOrEmpty(s_devMic)) s_devMic = ""; if (string.IsNullOrEmpty(s_devOut)) s_devOut = ""; if (!string.IsNullOrEmpty(s_devRec)) devRec = getDevByID(s_devRec); // ?? devs.First(x => x.isPlay); if (!string.IsNullOrEmpty(s_devMic)) devMic = getDevByID(s_devMic); if (!string.IsNullOrEmpty(s_devOut)) devOut = getDevByID(s_devOut); }