private void load(KaraokeRulesetConfigManager config, IBindable <IReadOnlyList <Mod> > mods, IBindable <WorkingBeatmap> beatmap, EditorBeatmap editorBeatmap) { if (editorBeatmap != null) { return; } this.beatmap = beatmap.Value.Beatmap; var disableMicrophoneDeviceByMod = mods.Value.OfType <IApplicableToMicrophone>().Any(x => !x.MicrophoneEnabled); if (disableMicrophoneDeviceByMod) { return; } var beatmapSaitenable = beatmap.Value.Beatmap.IsScorable(); if (!beatmapSaitenable) { return; } var selectedDevice = config.GetBindable <string>(KaraokeRulesetSetting.MicrophoneDevice).Value; var microphoneList = new MicrophoneManager().MicrophoneDeviceNames.ToList(); // Find index by selection id var deviceIndex = microphoneList.IndexOf(selectedDevice); AddHandler(new OsuTKMicrophoneHandler(deviceIndex)); }
private void load(KaraokeRulesetConfigManager config, IBindable <IReadOnlyList <Mod> > mods, IBindable <WorkingBeatmap> beatmap, KaraokeSessionStatics session, EditorBeatmap editorBeatmap) { if (editorBeatmap != null) { session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Edit); return; } this.beatmap = beatmap.Value.Beatmap; var disableMicrophoneDeviceByMod = mods.Value.OfType <IApplicableToMicrophone>().Any(x => !x.MicrophoneEnabled); if (disableMicrophoneDeviceByMod) { session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.AutoPlay); return; } var beatmapSaitenable = beatmap.Value.Beatmap.IsScorable(); if (!beatmapSaitenable) { session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.NotSaitening); return; } try { var selectedDevice = config.Get <string>(KaraokeRulesetSetting.MicrophoneDevice); var microphoneList = new MicrophoneManager().MicrophoneDeviceNames.ToList(); // Find index by selection id var deviceIndex = microphoneList.IndexOf(selectedDevice); AddHandler(new OsuTKMicrophoneHandler(deviceIndex)); session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Saitening); } catch (Exception ex) { Logger.Error(ex, "Microphone initialize error."); // todo : set real error by exception session.SetValue(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.WindowsMicrophonePermissionDeclined); } }
public MicrophoneDevicePreview() { ShowBackground = false; bindableMicrophoneDeviceName.BindValueChanged(x => { // Find index by selection id var microphoneList = new MicrophoneManager().MicrophoneDeviceNames.ToList(); var deviceName = x.NewValue; var deviceIndex = microphoneList.IndexOf(x.NewValue); var hasDevice = !string.IsNullOrEmpty(x.NewValue); Child = new MicrophoneInputManager(deviceIndex) { RelativeSizeAxes = Axes.Both, Child = new MicrophoneSoundVisualizer { Anchor = Anchor.Centre, Origin = Anchor.Centre, DeviceName = deviceName, HasDevice = hasDevice, } }; }, true); }