Пример #1
0
        private void sndTestCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            ItemData input  = (ItemData)sndinputComboBox.SelectedItem;
            ItemData output = (ItemData)sndoutputComboBox.SelectedItem;

            if (sndTestCheckBox.Checked)
            {
                //Extract input device and get its default samplerate.
                //WASAPI devices only support one sample rate so it's important to use the correct one.
                SoundDevice[] devs;
                TeamTalk.GetSoundDevices(out devs);

                int in_samplerate = 0;
                foreach (SoundDevice dev in devs)
                {
                    if (dev.nDeviceID == input.id)
                    {
                        in_samplerate = dev.nDefaultSampleRate;
                    }
                }

                SpeexDSP spxdsp = new SpeexDSP(true);
                spxdsp.bEnableAGC              = true;
                spxdsp.bEnableDenoise          = true;
                spxdsp.bEnableEchoCancellation = echocancelCheckBox.Checked;
                soundloop = TeamTalk.StartSoundLoopbackTest(input.id, output.id, in_samplerate, 1, duplexCheckBox.Checked, spxdsp);
                if (soundloop == IntPtr.Zero)
                {
                    MessageBox.Show("Failed to test selected device");
                    sndTestCheckBox.Checked = false;
                }
            }
            else
            {
                TeamTalk.CloseSoundLoopbackTest(soundloop);
            }
        }
Пример #2
0
        private void UpdateSelectedSoundDevices(object sender, EventArgs e)
        {
            if (sndinputComboBox.SelectedItem == null ||
                sndoutputComboBox.SelectedItem == null)
            {
                return;
            }

            int inputid  = ((ItemData)sndinputComboBox.SelectedItem).id;
            int outputid = ((ItemData)sndoutputComboBox.SelectedItem).id;

            SoundDevice[] devs;
            TeamTalk.GetSoundDevices(out devs);

            int in_samplerate = 0, out_samplerate = 0;

            foreach (SoundDevice dev in devs)
            {
                if (dev.nDeviceID == inputid)
                {
                    in_samplerate = dev.nDefaultSampleRate;
                }
                if (dev.nDeviceID == outputid)
                {
                    out_samplerate = dev.nDefaultSampleRate;
                }
            }

            //for duplex mode both input and output sound device must support the same sample rate
            duplexCheckBox.Enabled = in_samplerate == out_samplerate;
            if (in_samplerate != out_samplerate)
            {
                duplexCheckBox.Checked     = false;
                echocancelCheckBox.Checked = false;
            }
            echocancelCheckBox.Enabled = duplexCheckBox.Checked;
        }
Пример #3
0
        void UpdateSoundSystem(object sender, EventArgs e)
        {
            sndinputComboBox.Items.Clear();
            sndoutputComboBox.Items.Clear();

            SoundDevice[] devs;
            TeamTalk.GetSoundDevices(out devs);

            SoundSystem soundsystem = SoundSystem.SOUNDSYSTEM_WASAPI;

            if (dsoundRadioButton.Checked)
            {
                soundsystem = SoundSystem.SOUNDSYSTEM_DSOUND;
                Debug.WriteLine("DirectSound devices");
            }
            else if (winmmRadioButton.Checked)
            {
                soundsystem = SoundSystem.SOUNDSYSTEM_WINMM;
                Debug.WriteLine("WinMM devices");
            }
            else
            {
                Debug.WriteLine("WASAPI devices");
            }

            Debug.WriteLine("INPUT DEVICES");
            foreach (SoundDevice dev in devs)
            {
                if (dev.nSoundSystem != soundsystem)
                {
                    continue;
                }
                Debug.WriteLine("Name " + dev.szDeviceName);
                Debug.WriteLine("\tID #" + dev.nDeviceID);
                Debug.WriteLine("\tUnique ID #" + dev.szDeviceID);
                Debug.WriteLine("\tWaveDeviceID #" + dev.nWaveDeviceID);
                string tmp = "";
                if (WindowsMixer.GetWaveInName(dev.nWaveDeviceID, ref tmp))
                {
                    Debug.WriteLine("\tMixer name: " + tmp);
                }
                for (int i = 0; i < WindowsMixer.GetWaveInControlCount(dev.nWaveDeviceID); i++)
                {
                    if (WindowsMixer.GetWaveInControlName(dev.nWaveDeviceID, i, ref tmp))
                    {
                        Debug.WriteLine("\t\tControl name: " + tmp);
                        Debug.WriteLine("\t\tSelected: " + WindowsMixer.GetWaveInControlSelected(dev.nWaveDeviceID, i));
                    }
                }

                if (dev.nMaxInputChannels > 0)
                {
                    int index = sndinputComboBox.Items.Add(new ItemData(dev.szDeviceName, dev.nDeviceID));
                    if (dev.nDeviceID == settings.sndinputid)
                    {
                        sndinputComboBox.SelectedIndex = index;
                    }
                }
                if (dev.nMaxOutputChannels > 0)
                {
                    int index = sndoutputComboBox.Items.Add(new ItemData(dev.szDeviceName, dev.nDeviceID));
                    if (dev.nDeviceID == settings.sndoutputid)
                    {
                        sndoutputComboBox.SelectedIndex = index;
                    }
                }
            }
            if (sndinputComboBox.SelectedIndex < 0 && sndinputComboBox.Items.Count > 0)
            {
                sndinputComboBox.SelectedIndex = 0;
            }
            if (sndoutputComboBox.SelectedIndex < 0 && sndoutputComboBox.Items.Count > 0)
            {
                sndoutputComboBox.SelectedIndex = 0;
            }
        }