Beispiel #1
0
        /// <summary>
        /// Check and fix any problem with hardware.
        /// </summary>
        private void CheckDriver()
        {
            //Get number of driver available
            int DriverNumber = 0;

            CheckError(m_System.getNumDrivers(ref DriverNumber));

            //Driver checking
            #region Solve hardware problems
            //If there's 0 driver, no sound
            if (DriverNumber <= 0)
            {
                CheckError(m_System.setOutput(OUTPUTTYPE.NOSOUND));
            }
            else
            {
                //Get driver capability
                int         MinFreq = 0, MaxFreq = 0;
                CAPS        Capability  = CAPS.NONE;
                SPEAKERMODE Speakermode = SPEAKERMODE.STEREO;
                CheckError(m_System.getDriverCaps(0, ref Capability, ref MinFreq, ref MaxFreq, ref Speakermode));

                //Set spearker mode according to the driver
                CheckError(m_System.setSpeakerMode(Speakermode));

                //Set buffer if not using hardware accceleration
                if ((Capability & CAPS.HARDWARE_EMULATED) == CAPS.HARDWARE_EMULATED)
                {
                    CheckError(m_System.setDSPBufferSize(Global.EMULATED_BUFFERSIZE, Global.EMULATED_BUFFERCOUNT));
                }

                //Get user driver data
                GUID          Guid       = new GUID();
                StringBuilder DriverName = new StringBuilder(Global.MAX_DRIVERNAME);
                CheckError(m_System.getDriverInfo(0, DriverName, Global.MAX_DRIVERNAME, ref Guid));

                //If driver is sigmatel
                if (DriverName.Equals(new StringBuilder((Global.SIGMATEL_DRIVERNAME))))
                {
                    //Fix crackling
                    CheckError(m_System.setSoftwareFormat(
                                   Global.SIGMATEL_SAMPLERATE,
                                   SOUND_FORMAT.PCMFLOAT,
                                   0,
                                   0,
                                   DSP_RESAMPLER.LINEAR));
                }
            }
            #endregion
        }
Beispiel #2
0
        ///<summary>
        ///    Return an array of strings which are the driver names for the playback devices.
        ///</summary>
        public string[] GetAllPlaybackDevices(FMOD.System fmod)
        {
            FMOD.RESULT   result;
            int           numPlaybackDevices = 0;
            StringBuilder drivername         = new StringBuilder(256);

            // Get playback drivers
            result = fmod.getNumDrivers(ref numPlaybackDevices);
            CheckRetCode(result);

            string[] playbackDeviceNames = new string[numPlaybackDevices];

            for (int count = 0; count < numPlaybackDevices; count++)
            {
                FMOD.GUID guid = new FMOD.GUID();
                result = fmod.getDriverInfo(count, drivername, drivername.Capacity, ref guid);
                // result = fmod.getDriverName(count, drivername, drivername.Capacity);
                CheckRetCode(result);
                playbackDeviceNames[count] = drivername.ToString();
            }
            return(playbackDeviceNames);
        }
Beispiel #3
0
        private void comboBoxOutput_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            FMOD.RESULT   result     = FMOD.RESULT.OK;
            StringBuilder drivername = new StringBuilder(256);
            int           numdrivers = 0;

            switch (comboBoxOutput.SelectedIndex)
            {
            case 0:
                result = system.setOutput(FMOD.OUTPUTTYPE.DSOUND);
                break;

            case 1:
                result = system.setOutput(FMOD.OUTPUTTYPE.WINMM);
                break;

            case 2:
                result = system.setOutput(FMOD.OUTPUTTYPE.ASIO);
                break;
            }
            ERRCHECK(result);

            /*
             *  Get Playback drivers
             */
            result = system.getNumDrivers(ref numdrivers);
            ERRCHECK(result);

            for (int count = 0; count < numdrivers; count++)
            {
                result = system.getDriverInfo(count, drivername, drivername.Capacity, ref guid);
                ERRCHECK(result);

                comboBoxPlayback.Items.Add(drivername.ToString());
            }

            comboBoxPlayback.Enabled = true;
        }
Beispiel #4
0
        // ========================================================================================================================================
        #region User support
        /// <summary>
        /// Enumerates available audio outputs in the system and returns their names.
        /// </summary>
        /// <returns></returns>
        public List <string> AvailableOutputs()
        {
            List <string> availableDriversNames = new List <string>();

            int numDrivers;

            result = system.getNumDrivers(out numDrivers);
            ERRCHECK(result, "system.getNumDrivers");

            for (int i = 0; i < numDrivers; ++i)
            {
                int namelen = 255;
                System.Text.StringBuilder name = new System.Text.StringBuilder(namelen);
                System.Guid      guid;
                int              systemrate;
                FMOD.SPEAKERMODE speakermode;
                int              speakermodechannels;

                result = system.getDriverInfo(i, name, namelen, out guid, out systemrate, out speakermode, out speakermodechannels);
                ERRCHECK(result, "system.getDriverInfo");

                availableDriversNames.Add(name.ToString());

                LOG(LogLevel.DEBUG, "{0}{1}guid: {2}{3}systemrate: {4}{5}speaker mode: {6}{7}channels: {8}"
                    , name
                    , System.Environment.NewLine
                    , guid
                    , System.Environment.NewLine
                    , systemrate
                    , System.Environment.NewLine
                    , speakermode
                    , System.Environment.NewLine
                    , speakermodechannels
                    );
            }

            return(availableDriversNames);
        }
Beispiel #5
0
        private void MultipleSoundCard_Load(object sender, System.EventArgs e)
        {
            FMOD.RESULT   result;
            uint          version    = 0;
            int           numdrivers = 0;
            StringBuilder drivername = new StringBuilder(256);

            FMOD.GUID guid = new FMOD.GUID();

            playA.Enabled = false;
            playB.Enabled = false;

            /*
             *  Create Sound Card A
             */
            result = FMOD.Factory.System_Create(ref systemA);
            ERRCHECK(result);

            result = systemA.getVersion(ref version);
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                Application.Exit();
            }

            result = systemA.getNumDrivers(ref numdrivers);
            ERRCHECK(result);

            for (int count = 0; count < numdrivers; count++)
            {
                result = systemA.getDriverInfo(count, drivername, drivername.Capacity, ref guid);
                ERRCHECK(result);

                comboBox1.Items.Add(drivername.ToString());
            }

            /*
             *  Create Sound Card B
             */
            result = FMOD.Factory.System_Create(ref systemB);
            ERRCHECK(result);

            result = systemB.getVersion(ref version);
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                Application.Exit();
            }

            result = systemB.getNumDrivers(ref numdrivers);
            ERRCHECK(result);

            for (int count = 0; count < numdrivers; count++)
            {
                result = systemB.getDriverInfo(count, drivername, drivername.Capacity, ref guid);
                ERRCHECK(result);

                comboBox2.Items.Add(drivername.ToString());
            }
        }
Beispiel #6
0
        private void PitchDetection_Load(object sender, System.EventArgs e)
        {
            int  numdrivers = 0;
            uint version    = 0;

            FMOD.RESULT   result;
            StringBuilder drivername = new StringBuilder(256);

            FMOD.GUID guid = new FMOD.GUID();

            comboBoxOutput.Enabled   = true;
            comboBoxPlayback.Enabled = false;
            comboBoxRecord.Enabled   = false;

            /*
             *  Global Settings
             */
            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result);

            result = system.getVersion(ref version);
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                MessageBox.Show("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                Application.Exit();
            }

            /*
             *  Get output modes
             */
            comboBoxOutput.Items.Add("DirectSound");
            comboBoxOutput.Items.Add("Windows Multimedia WaveOut");
            comboBoxOutput.Items.Add("ASIO");

            /*
             *  Get Playback drivers
             */
            result = system.getNumDrivers(ref numdrivers);
            ERRCHECK(result);

            for (int count = 0; count < numdrivers; count++)
            {
                result = system.getDriverInfo(count, drivername, drivername.Capacity, ref guid);
                ERRCHECK(result);

                comboBoxPlayback.Items.Add(drivername.ToString());
            }

            /*
             *  Get Record drivers
             */
            result = system.getRecordNumDrivers(ref numdrivers);
            ERRCHECK(result);

            for (int count = 0; count < numdrivers; count++)
            {
                result = system.getRecordDriverInfo(count, drivername, drivername.Capacity, ref guid);
                ERRCHECK(result);

                comboBoxRecord.Items.Add(drivername.ToString());
            }
        }