示例#1
0
        private void SimpleAsio_Load(object sender, System.EventArgs e)
        {
            //BassNet.Registration("your email", "your regkey");

            // get the Asio devices and init them
            this.comboBoxAsioOutputDevice.Items.AddRange(BassAsio.BASS_ASIO_GetDeviceInfos());
            for (int i = 0; i < this.comboBoxAsioOutputDevice.Items.Count; i++)
            {
                if (!BassAsio.BASS_ASIO_Init(i, BASSASIOInit.BASS_ASIO_DEFAULT))
                {
                    this.comboBoxAsioOutputDevice.Items[i] = BassAsio.BASS_ASIO_ErrorGetCode();
                }
            }
            this.comboBoxAsioOutputDevice.SelectedIndex = 0;
            this.comboBoxAsioInputDevice.Items.AddRange(BassAsio.BASS_ASIO_GetDeviceInfos());
            this.comboBoxAsioInputDevice.SelectedIndex = this.comboBoxAsioOutputDevice.SelectedIndex;

            // get the bass devices, init them and set the default one
            this.comboBoxBassDevice.Items.AddRange(Bass.BASS_GetDeviceInfos());
            int n = 0;

            foreach (BASS_DEVICEINFO info in this.comboBoxBassDevice.Items)
            {
                Bass.BASS_Init(n, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle);
                if (info.IsDefault)
                {
                    this.comboBoxBassDevice.SelectedItem = info;
                }
                n++;
            }
        }
示例#2
0
        public static string[] GetAllASIODevices()
        {
            List <string> asioDeviceList = new List <string>();

            try
            {
                BASS_ASIO_DEVICEINFO[] bassAsioDevInfo = BassAsio.BASS_ASIO_GetDeviceInfos();
                if (bassAsioDevInfo.Length == 0)
                {
                    asioDeviceList.Add("None");
                }
                else
                {
                    for (int i = 0; i < bassAsioDevInfo.Length; i++)
                    {
                        asioDeviceList.Add(bassAsioDevInfo[i].name);
                        //Trace.TraceInformation( "ASIO Device {0}: {1}", i, bassAsioDevInfo[ i ].name );
                    }
                }
            }
            catch
            {
                asioDeviceList.Add("None");
            }

            return(asioDeviceList.ToArray());
        }
示例#3
0
        private int getDeviceNum(string DeviceName)
        {
            BASS_ASIO_DEVICEINFO[] devices = BassAsio.BASS_ASIO_GetDeviceInfos();
            for (int i = 0; i < devices.Length; i++)
            {
                if (devices[i].name == deviceName)
                {
                    return(i);
                }
            }

            return(-1);
        }
示例#4
0
        public static string[] GetDeviceNames()
        {
            needsUnload = true;

            BASS_ASIO_DEVICEINFO[] devices = BassAsio.BASS_ASIO_GetDeviceInfos();
            string[] devs = new string[devices.Length];
            for (int i = 0; i < devices.Length; i++)
            {
                devs[i] = devices[i].name;
            }

            return(devs);
        }
示例#5
0
        public static int GetDeviceIndex(string name)
        {
            int index = -1;

            BASS_ASIO_DEVICEINFO[] devices = BassAsio.BASS_ASIO_GetDeviceInfos();
            for (int i = 0; i < devices.Length; i++)
            {
                if (devices[i].name == name)
                {
                    index = i;
                }
            }

            return(index);
        }
示例#6
0
        public static bool DeviceExists(string Name)
        {
            needsUnload = true;

            BASS_ASIO_DEVICEINFO[] devices = BassAsio.BASS_ASIO_GetDeviceInfos();
            foreach (BASS_ASIO_DEVICEINFO di in devices)
            {
                if (di.name == Name)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#7
0
        /// <summary>
        /// Load ASIO Settings
        /// </summary>
        public override void LoadSettings()
        {
            using (Settings xmlreader = new MPSettings())
            {
                bool   _useASIO            = xmlreader.GetValueAsBool("audioplayer", "asio", false);
                string _asioDeviceSelected = xmlreader.GetValueAsString("audioplayer", "asiodevice", "None");
                hScrollBarBalance.Value = xmlreader.GetValueAsInt("audioplayer", "asiobalance", 0);
                useASIOCheckBox.Checked = _useASIO;

                if (_useASIO)
                {
                    BASS_ASIO_DEVICEINFO[] asioDevices = BassAsio.BASS_ASIO_GetDeviceInfos();
                    // Check if the ASIO device read is amongst the one retrieved
                    bool found = false;
                    for (int i = 0; i < asioDevices.Length; i++)
                    {
                        if (asioDevices[i].name == _asioDeviceSelected)
                        {
                            found = true;
                            bool rc = BassAsio.BASS_ASIO_Init(i);
                            break;
                        }
                    }
                    if (found)
                    {
                        asioDeviceComboBox.SelectedItem = _asioDeviceSelected;
                    }
                    else
                    {
                        Log.Warn("Selected ASIO Device not found. {0}", _asioDeviceSelected);
                    }
                }
                else
                {
                    asioDeviceComboBox.Enabled = false;
                    btSettings.Enabled         = false;
                }
            }
        }
示例#8
0
        private void useASIOCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            asioDeviceComboBox.Items.Clear();
            asioDeviceComboBox.Enabled = useASIOCheckBox.Checked;
            if (useASIOCheckBox.Checked)
            {
                // We must not have checked the "Upmixing" checkbox in the Music setting the same time
                SectionSettings section = GetSection("Music");

                if (section != null)
                {
                    bool mixing = (bool)section.GetSetting("mixing");
                    if (mixing)
                    {
                        useASIOCheckBox.Checked = false;
                        MessageBox.Show(this, "ASIO and Upmixing (in the Music Tab) must not be used at the same time",
                                        "MediaPortal - Setup", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                // Get all available ASIO devices and add them to the combo box
                BASS_ASIO_DEVICEINFO[] asioDevices = BassAsio.BASS_ASIO_GetDeviceInfos();
                if (asioDevices.Length == 0)
                {
                    MessageBox.Show(this, "No ASIO Devices available in the system.",
                                    "MediaPortal - Setup", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    asioDeviceComboBox.Enabled = false;
                    btSettings.Enabled         = false;
                    useASIOCheckBox.Checked    = false;
                }
                else
                {
                    asioDeviceComboBox.Items.AddRange(asioDevices);
                    asioDeviceComboBox.SelectedIndex = 0;
                    btSettings.Enabled = true;
                }
            }
        }
示例#9
0
        /// <summary>
        /// Get the sound devices for the selected Player
        /// </summary>
        /// <param name="player">
        /// 0 - Bass Directshow
        /// 1 - ASIO
        /// 2 - WASAPI
        /// 3 - Internal Dshow Player
        /// </param>
        private void GetAvailableSoundDevices(int player)
        {
            switch (player)
            {
            case (int)AudioPlayer.Bass:
            case (int)AudioPlayer.DShow:

                // Get all available devices and add them to the combo box
                BASS_DEVICEINFO[] soundDevices = Bass.BASS_GetDeviceInfos();

                // For Directshow player, we need to have the exact wording here
                if (audioPlayerComboBox.SelectedIndex == 1)
                {
                    soundDeviceComboBox.Items.Add(new SoundDeviceItem("Default DirectSound Device", ""));
                }
                else
                {
                    soundDeviceComboBox.Items.Add(new SoundDeviceItem("Default Sound Device", ""));
                }

                // Fill the combo box, starting at 1 to skip the "No Sound" device
                for (int i = 1; i < soundDevices.Length; i++)
                {
                    soundDeviceComboBox.Items.Add(new SoundDeviceItem(soundDevices[i].name, soundDevices[i].id));
                }

                break;

            case (int)AudioPlayer.Asio:

                // Get all available ASIO devices and add them to the combo box
                BASS_ASIO_DEVICEINFO[] asioDevices = BassAsio.BASS_ASIO_GetDeviceInfos();
                if (asioDevices.Length == 0)
                {
                    MessageBox.Show(this, "No ASIO Devices available in the system.",
                                    "MediaPortal - Setup", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    // Default back to BASS Player
                    audioPlayerComboBox.SelectedIndex = 0;
                }
                else
                {
                    foreach (BASS_ASIO_DEVICEINFO deviceInfo in asioDevices)
                    {
                        soundDeviceComboBox.Items.Add(new SoundDeviceItem(deviceInfo.name, deviceInfo.driver));
                    }
                }

                break;

            case (int)AudioPlayer.WasApi:
                // Get all available ASIO devices and add them to the combo box
                BASS_WASAPI_DEVICEINFO[] wasapiDevices = BassWasapi.BASS_WASAPI_GetDeviceInfos();
                if (wasapiDevices.Length == 0)
                {
                    MessageBox.Show(this, "No WASAPI Devices available in the system.",
                                    "MediaPortal - Setup", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    // Default back to BASS Player
                    audioPlayerComboBox.SelectedIndex = 0;
                }
                else
                {
                    foreach (BASS_WASAPI_DEVICEINFO deviceInfo in wasapiDevices)
                    {
                        // Only add enabled and output devices to the list
                        if (deviceInfo.IsEnabled && !deviceInfo.IsInput)
                        {
                            soundDeviceComboBox.Items.Add(new SoundDeviceItem(deviceInfo.name, deviceInfo.id));
                        }
                    }
                }
                if (soundDeviceComboBox.Items.Count == 0)
                {
                    // Add default sound device to avoid crash.
                    soundDeviceComboBox.Items.Add(new SoundDeviceItem("Default Sound Device", ""));
                    soundDeviceComboBox.Items[0] = new SoundDeviceItem("Default Sound Device", "");
                }
                break;
            }
        }