コード例 #1
0
ファイル: Form1.cs プロジェクト: dexredux/EzAudioDeviceSwitch
        private void UpdateDropdowns()
        {
            var Outputdevices = Controller.GetPlaybackDevices(DeviceState.Active);
            var Inputdevices  = Controller.GetCaptureDevices(DeviceState.Active);

            InputDropdown.Items.Clear();
            OutputDropdown.Items.Clear();

            foreach (var endpoint in Inputdevices)
            {
                InputDropdown.Items.Add(endpoint.FullName);
                //Console.WriteLine(endpoint.Fullname);
            }

            //Console.WriteLine("These are output devices");
            foreach (var endpoint in Outputdevices)
            {
                OutputDropdown.Items.Add(endpoint.FullName);
                //Console.WriteLine(endpoint.FullName);
            }

            var defaultInputDevice  = Controller.GetDefaultDevice(DeviceType.Capture, Role.Multimedia);
            var defaultOutputDevice = Controller.GetDefaultDevice(DeviceType.Playback, Role.Multimedia);

            OutputDropdown.SelectedItem = defaultOutputDevice;
            OutputDropdown.Text         = defaultOutputDevice.FullName;

            InputDropdown.SelectedItem = defaultInputDevice;
            InputDropdown.Text         = defaultInputDevice.FullName;
        }
コード例 #2
0
        public VolumeControl()
        {
            InitializeComponent();
            CoreAudioController coreAudioConteroller = new CoreAudioController();

            App.CoreAudioDevice = coreAudioConteroller.GetDefaultDevice(AudioSwitcher.AudioApi.DeviceType.Playback, AudioSwitcher.AudioApi.Role.Multimedia);
        }
コード例 #3
0
        public static void UpdateLevel(bool reportFix)
        {
            if (audio == null)
            {
                return;
            }

            //Communication capture
            {
                var dev = audio.GetDefaultDevice(AudioSwitcher.AudioApi.DeviceType.Capture, AudioSwitcher.AudioApi.Role.Communications);
                UpdateLevel(dev, reportFix);
            }
            foreach (var dev in audio.GetDevices())
            {
                if (dev.State != AudioSwitcher.AudioApi.DeviceState.Active)
                {
                    continue;
                }

                if ((dev.DeviceType & AudioSwitcher.AudioApi.DeviceType.Capture) != 0)
                {
                    UpdateLevel(dev, reportFix);
                }
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: dexredux/EzAudioDeviceSwitch
        private void Form1_Load(object sender, EventArgs e)
        {
            thisNotifyIcon.Click += ThisNotifyIcon_Click;
            this.FormBorderStyle  = FormBorderStyle.None;
            Controller            = new CoreAudioController();

            var defaultInputDevice     = Controller.GetDefaultDevice(DeviceType.Capture, Role.Multimedia);
            var defaultInputComDevice  = Controller.GetDefaultDevice(DeviceType.Capture, Role.Communications);
            var defaultOutputDevice    = Controller.GetDefaultDevice(DeviceType.Playback, Role.Multimedia);
            var defaultOutputComDevice = Controller.GetDefaultDevice(DeviceType.Playback, Role.Communications);

            DefaultInputLabel.Text     = defaultInputComDevice.FullName;
            DefaultInputComLabel.Text  = defaultInputDevice.FullName;
            DefaultOutputComLabel.Text = defaultOutputComDevice.FullName;
            DefaultOutputLabel.Text    = defaultOutputDevice.FullName;

            /*
             * var Outputdevices = Controller.GetPlaybackDevices(DeviceState.Active);
             *
             * var Inputdevices = Controller.GetCaptureDevices(DeviceState.Active);
             *
             * //Console.WriteLine("These are input devices");
             * foreach (var endpoint in Inputdevices)
             * {
             *  InputDropdown.Items.Add(endpoint.FullName);
             *  //Console.WriteLine(endpoint.Fullname);
             * }
             *
             * //Console.WriteLine("These are output devices");
             * foreach (var endpoint in Outputdevices)
             * {
             *  OutputDropdown.Items.Add(endpoint.FullName);
             *  //Console.WriteLine(endpoint.FullName);
             * }
             */


            OutputDropdown.DropDownStyle = ComboBoxStyle.DropDownList;

            InputDropdown.DropDownStyle = ComboBoxStyle.DropDownList;
            UpdateDropdowns();
        }
コード例 #5
0
        private void cleanUpSessionKeepers()
        {
            var defaultDevice = m_coreAudioController.GetDefaultDevice(DeviceType.Playback, Role.Multimedia);

            IDictionary <string, IAudioSession> currentSessions = new Dictionary <string, IAudioSession>();

            foreach (var session in defaultDevice.GetCapability <IAudioSessionController>())
            {
                currentSessions[session.Id] = session;
            }

            var deadSessions =
                m_sessions.Values.Where(session => !currentSessions.ContainsKey(session.id())).ToList();

            foreach (var session in deadSessions)
            {
                session.Dispose();
                m_sessions.Remove(session.id());
            }
        }
コード例 #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DefaultAudioDevice   = Controller.GetDefaultDevice(AudioSwitcher.AudioApi.DeviceType.Playback, Role.Multimedia);
            txtActualDevice.Text = DefaultAudioDevice.FullName;

            ChargeDevicesList();

            chkStartAtStartUp.Checked = Settings.Default.StartWithWin;
            this.WindowState          = FormWindowState.Minimized;
            this.ShowInTaskbar        = false;
        }
コード例 #7
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            TrayIcon tray = new TrayIcon();

            tray.Display();

            audio       = new CoreAudioController();
            startDevice = audio.GetDefaultDevice(AudioSwitcher.AudioApi.DeviceType.Playback, AudioSwitcher.AudioApi.Role.Multimedia);

            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Elapsed += new ElapsedEventHandler(ProcessTimer);
            timer.Interval = 500;
            timer.Enabled  = true;

            Application.Run();
        }
コード例 #8
0
        static public JObject getDeviceData(bool json, CoreAudioDevice device = null)
        {
            if (device == null)
            {
                mainDevice = controller.GetDefaultDevice(DeviceType.Playback, Role.Console);
                device     = mainDevice;
            }
            IDictionary <string, object> data = new Dictionary <string, object>();

            data.Add("name", mainDevice.FullName);           //Device Name + Interface
            data.Add("type", mainDevice.Name);               //Name Only
            data.Add("interface", mainDevice.InterfaceName); //Interface Only
            data.Add("device", mainDevice.DeviceType);

            data.Add("icon", mainDevice.Icon);
            data.Add("iconPath", mainDevice.IconPath);
            data.Add("id", mainDevice.Id);
            data.Add("realID", mainDevice.RealId);

            data.Add("isMuted", mainDevice.IsMuted);
            data.Add("volume", mainDevice.Volume); //Master Volume
            data.Add("state", mainDevice.State);   //Current State (Active/Disable)
            return((JObject)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(data, Formatting.Indented)));
        }
コード例 #9
0
ファイル: TrayIcon.cs プロジェクト: susch19/ControlMic
        public TrayApplication()
        {
            coreAudioController = new CoreAudioController();
            manager             = new HotKeyManager();

            if (File.Exists("save.mm"))
            {
                using (var r = new BinaryReader(File.OpenRead("save.mm")))
                {
                    if (r.BaseStream.Length >= 40)
                    {
                        var             g   = new Guid(r.ReadString());
                        CoreAudioDevice mic = coreAudioController.GetDevice(g);

                        if (mic != null && mic.State == DeviceState.Active)
                        {
                            microphone = mic;
                        }
                        else
                        {
                            microphone = coreAudioController.GetDefaultDevice(DeviceType.Capture, Role.Communications);
                        }

                        beepEnabled = r.ReadBoolean();
                        Register((ModifierKeys)r.ReadInt32(), (Key)r.ReadInt32(), true);

                        if (r.BaseStream.Position != r.BaseStream.Length)
                        {
                            onBeep.Freq      = r.ReadInt32();
                            onBeep.Duration  = r.ReadInt32();
                            offBeep.Freq     = r.ReadInt32();
                            offBeep.Duration = r.ReadInt32();
                        }
                        else
                        {
                            onBeep.Freq      = 750;
                            onBeep.Duration  = 200;
                            offBeep.Freq     = 300;
                            offBeep.Duration = 200;
                        }

                        if (r.BaseStream.Position != r.BaseStream.Length)
                        {
                            notificationBallForm = new NotificationBallForm
                            {
                                Enabled = r.ReadBoolean()
                            };
                            notificationBallForm.DraggingEnd += (asd, esd) => Save();
                            notificationBallForm.Show();
                            notificationBallForm.Visible  = notificationBallForm.Enabled;
                            notificationBallForm.Location = new Point(r.ReadInt32(), r.ReadInt32());
                        }
                        else
                        {
                            notificationBallForm = new NotificationBallForm
                            {
                                Enabled = false
                            };
                            notificationBallForm.Show();
                            notificationBallForm.Visible = false;
                        }
                    }
                }
            }
            else
            {
                microphone       = coreAudioController.GetDefaultDevice(DeviceType.Capture, Role.Communications);
                beepEnabled      = false;
                onBeep.Freq      = 750;
                onBeep.Duration  = 200;
                offBeep.Freq     = 300;
                offBeep.Duration = 200;

                notificationBallForm = new NotificationBallForm
                {
                    Enabled = false
                };
                notificationBallForm.Show();
                notificationBallForm.Visible = false;

                Register(ModifierKeys.None, Key.None);
            }

            trayMenu = new ContextMenuStrip();
            trayMenu.Items.Add(new ToolStripMenuItem("Toogle Mute", default, ToggleMute));
コード例 #10
0
 private CoreAudioDevice GetDefaultDevice()
 {
     return(AudioController.GetDefaultDevice(DeviceType.Playback, Role.Multimedia));
 }
コード例 #11
0
        public AudioControl()
        {
            var controller = new CoreAudioController();

            _device = controller.GetDefaultDevice(DeviceType.Playback, Role.Multimedia);
        }