コード例 #1
0
        /// <summary>
        ///     Get input and output MIDI devices
        /// </summary>
        public void GetMidiDevices()
        {
            var inputDevices  = new BindableCollection <MidiInputDeviceInfo>();
            var outputDevices = new BindableCollection <MidiOutputDeviceInfo>();

            for (var i = 0; i < InputDevice.DeviceCount; i++)
            {
                inputDevices.Add(new MidiInputDeviceInfo(InputDevice.GetDeviceCapabilities(i)));
            }

            for (var i = 0; i < OutputDeviceBase.DeviceCount; i++)
            {
                outputDevices.Add(new MidiOutputDeviceInfo(OutputDeviceBase.GetDeviceCapabilities(i)));
            }

            _logger.Info($"Found {inputDevices.Count} input devices");
            _logger.Info($"Found {outputDevices.Count} output devices");

            InputDevices  = inputDevices;
            OutputDevices = outputDevices;

            var jdXiInput  = InputDevices.FirstOrDefault(d => d.Name == "JD-Xi");
            var jdXiOutput = OutputDevices.FirstOrDefault(d => d.Name == "JD-Xi");

            SelectedInputDeviceId  = jdXiInput == null ? -1 : InputDevices.IndexOf(jdXiInput);
            SelectedOutputDeviceId = jdXiOutput == null ? -1 : OutputDevices.IndexOf(jdXiOutput);

            if (jdXiInput != null)
            {
                _logger.Info($"JD-XI Input device found (ID: {SelectedInputDeviceId})");
            }

            if (jdXiOutput != null)
            {
                _logger.Info($"JD-XI Output device found (ID: {SelectedOutputDeviceId})");
            }
        }
コード例 #2
0
        public AudioTabViewModel()
            : base(NameKey, SettingsTabCategory.Audio)
        {
            OutputDevices = ClientModel.Player.Devices;
            InputDevices  = ClientModel.Recorder.Devices;
            InputConfigs  = new[]
            {
                new AudioQuality(1, 8, 22050),
                new AudioQuality(1, 16, 22050),
                new AudioQuality(1, 8, 44100),
                new AudioQuality(1, 16, 44100)
            };

            SelectedOutputIndex = OutputDevices.IndexOf(Settings.Current.OutputAudioDevice);
            SelectedInputIndex  = InputDevices.IndexOf(Settings.Current.InputAudioDevice);
            SelectedConfigIndex = InputConfigs.IndexOf(new AudioQuality(1, Settings.Current.Bits, Settings.Current.Frequency));

            if (SelectedOutputIndex == -1)
            {
                SelectedOutputIndex = 0;
            }

            if (SelectedInputIndex == -1)
            {
                SelectedInputIndex = 0;
            }

            if (SelectedConfigIndex == -1)
            {
                SelectedConfigIndex = 0;
            }

            SelectButtonName = Settings.Current.RecorderKey.ToString();

            SelectKeyCommand = new Command(SelectKey);
        }