private void cbConfigs_SelectedIndexChanged(object sender, EventArgs e) { while (_settings.Sounds.Any(x => x.WaveOut != null)) { foreach (var sound in _settings.Sounds.Where(x => x.WaveOut != null)) { sound.StartStopRequest = StartStop.Stop; } Thread.Sleep(1); } var s = new SoundGeneratorSettings(); ProcessorBase.LoadSettings(ref s, cbConfigs.SelectedItem + "." + _settings.FileExtension); _settings.SelectedLabels = s.SelectedLabels; _settings.OnTimes = s.OnTimes; _settings.OffTimes = s.OffTimes; _settings.Volume = s.Volume; _settings.Sounds = s.Sounds; // start any sounds as necessary foreach (var sound in _settings.Sounds.Where(x => x.Started && x.WaveOut == null)) { sound.StartStopRequest = StartStop.Start; } SetupUI(); }
public void SoundGenerator(MaxLifxBulbController bulbController, Random random) { _r = random; if (Settings == null) { Settings = new SoundGeneratorSettings(); } var f = Directory.GetFiles( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\MaxLifx\\Sounds\\Loops", "*.wav"); var enu = f.GetEnumerator(); while (enu.MoveNext()) { SettingsCast.Sounds.Add( new Sound( enu.Current.ToString() .Replace( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\MaxLifx\\Sounds\\Loops\\", "") .Replace(".wav", ""), enu.Current.ToString(), Sound.SoundTypes.Looping)); } f = Directory.GetFiles( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\MaxLifx\\Sounds\\Random", "*.wav"); enu = f.GetEnumerator(); while (enu.MoveNext()) { SettingsCast.Sounds.Add( new Sound( enu.Current.ToString() .Replace( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\MaxLifx\\Sounds\\Random\\", "") .Replace(".wav", ""), enu.Current.ToString(), Sound.SoundTypes.Random)); } var de = new MMDeviceEnumerator(); de.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia); DoMainLoop(); }
public SoundGeneratorUI(SoundGeneratorSettings settings) { InitializeComponent(); _settings = settings; SetupUI(); }