Exemple #1
0
        ///<summary>
        ///    Return an array of strings which are the driver names for the "microphone" devices.
        ///</summary>
        public string[] GetAllMicrophoneDevices(FMOD.System fmod)
        {
            FMOD.RESULT   result;
            int           numSoundSources = 0;
            StringBuilder drivername      = new StringBuilder(256);

//             result = system.setDriver(selected);
//             ERRCHECK(result);

            // Get Record drivers
            result = fmod.getRecordNumDrivers(ref numSoundSources);
            CheckRetCode(result);

            string[] soundSourceNames = new string[numSoundSources];

            for (int count = 0; count < numSoundSources; count++)
            {
                FMOD.GUID guid = new FMOD.GUID();
                result = fmod.getRecordDriverInfo(count, drivername, drivername.Capacity, ref guid);
                // result = fmod.getRecordDriverName(count, drivername, drivername.Capacity);
                CheckRetCode(result);
                soundSourceNames[count] = drivername.ToString();
            }
            return(soundSourceNames);
        }
        public EventNotFoundException(EventReference eventReference)
            : base("[FMOD] Event not found: " + eventReference.ToString())
        {
            Guid = eventReference.Guid;

#if UNITY_EDITOR
            Path = eventReference.Path;
#endif
        }
Exemple #3
0
        public List <string> GetSoundDevices()
        {
            List <string> soundDevices     = new List <string>();
            int           iNumberOfDrivers = 0;

            this.system.getNumDrivers(ref iNumberOfDrivers);

            for (int i = 0; i < iNumberOfDrivers; i++)
            {
                StringBuilder name = new StringBuilder(200);
                FMOD.GUID     guid = new FMOD.GUID();
                system.getDriverInfo(i, name, 200, ref guid);
                soundDevices.Add(name.ToString());
            }

            return(soundDevices);
        }
Exemple #4
0
        private void comboBoxOutput_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            FMOD.RESULT   result     = FMOD.RESULT.OK;
            StringBuilder drivername = new StringBuilder(256);
            int           numdrivers = 0;

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

            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;

            default:
                return;
            }
            ERRCHECK(result);

            /*
             *  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());
            }

            comboBoxOutput.Enabled = false;
            comboBoxRecord.Enabled = true;
        }
Exemple #5
0
        public static string[] GetOutputDevices()
        {
            List <string> outputDevices = new List <string>();

            int numdrivers = 0;

            SoundEngine.FMODSystem.getNumDrivers(ref numdrivers);

            for (int i = 0; i < numdrivers; i++)
            {
                StringBuilder sb = new StringBuilder();
                sb.Capacity = 1000;
                FMOD.GUID dummy = new FMOD.GUID();
                SoundEngine.FMODSystem.getDriverInfo(i, sb, 1000, ref dummy);
                outputDevices.Add(sb.ToString());
            }

            return(outputDevices.ToArray());
        }
Exemple #6
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);
        }
Exemple #7
0
        private void LogDeviceInformation(int id)
        {
            FMOD.CAPS driverCaps = FMOD.CAPS.NONE;
            int       minfrequency = 0, maxfrequency = 0;

            FMOD.SPEAKERMODE speakermode = FMOD.SPEAKERMODE.STEREO;

            FMOD.RESULT result = FMODSystem.getDriverCaps(id, ref driverCaps, ref minfrequency, ref maxfrequency, ref speakermode);
            LogInit("Checking driver caps... " + result.ToString());
            ERRCHECK(result);
            LogInit("\tDriver caps: " + driverCaps);
            LogInit("\tFrequency range: {0}-{1}", minfrequency, maxfrequency);
            LogInit("\tSpeaker mode: {0}", speakermode);

            StringBuilder name = new StringBuilder(256);

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

            result = FMODSystem.getDriverInfo(id, name, 256, ref guid);
            LogInit("Fetching driver {0}. {1}", id, result.ToString());
            ERRCHECK(result);
            LogInit("\tName: " + name);

            string tmpGuidStr = "";

            for (int i = 0; i < guid.Data4.Length; i++)
            {
                tmpGuidStr += guid.Data4[i].ToString("X");
                if (i == 1)
                {
                    tmpGuidStr += "-";
                }
            }

            LogInit("\tGUID: {0}-{1}-{2}-{3}", guid.Data1.ToString("X"), guid.Data2.ToString("X"), guid.Data3.ToString("X"), tmpGuidStr);
        }
Exemple #8
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());
            }
        }
        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());
            }
        }
        private void threeD_Load(object sender, System.EventArgs e)
        {
            uint version = 0;

            FMOD.RESULT result;

            trackBarPosition.Enabled = false;

            /*
             *  Create a System object and initialize.
             */
            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();
            }

            FMOD.CAPS        caps        = FMOD.CAPS.NONE;
            FMOD.SPEAKERMODE speakermode = FMOD.SPEAKERMODE.STEREO;

            int           outputrate = 0;
            StringBuilder name       = new StringBuilder(128);

            result = system.getDriverCaps(0, ref caps, ref outputrate, ref speakermode);
            ERRCHECK(result);

            result = system.setSpeakerMode(speakermode);                                         /* Set the user selected speaker mode. */
            ERRCHECK(result);

            if ((caps & FMOD.CAPS.HARDWARE_EMULATED) == FMOD.CAPS.HARDWARE_EMULATED)             /* The user has the 'Acceleration' slider set to off!  This is really bad for latency!. */
            {                                                                                    /* You might want to warn the user about this. */
                result = system.setDSPBufferSize(1024, 10);                                      /* At 48khz, the latency between issuing an fmod command and hearing it will now be about 213ms. */
                ERRCHECK(result);
            }

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

            result = system.getDriverInfo(0, name, 256, ref guid);
            ERRCHECK(result);

            if (name.ToString().IndexOf("SigmaTel") != -1)               /* Sigmatel sound devices crackle for some reason if the format is pcm 16bit.  pcm floating point output seems to solve it. */
            {
                result = system.setSoftwareFormat(48000, FMOD.SOUND_FORMAT.PCMFLOAT, 0, 0, FMOD.DSP_RESAMPLER.LINEAR);
                ERRCHECK(result);
            }

            result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER)
            {
                result = system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO);                             /* Ok, the speaker mode selected isn't supported by this soundcard.  Switch it back to stereo... */
                ERRCHECK(result);

                result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);                        /* Replace with whatever channel count and flags you use! */
                ERRCHECK(result);
            }

            /*
             *  Set the distance units. (meters/feet etc).
             */
            result = system.set3DSettings(1.0f, DISTANCEFACTOR, 1.0f);
            ERRCHECK(result);

            /*
             *  Load some sounds
             */
            result = system.createSound("../../../../../examples/media/drumloop.wav", (FMOD.MODE.HARDWARE | FMOD.MODE._3D), ref sound1);
            ERRCHECK(result);
            result = sound1.set3DMinMaxDistance(2.0f * DISTANCEFACTOR, 10000.0f * DISTANCEFACTOR);
            ERRCHECK(result);
            result = sound1.setMode(FMOD.MODE.LOOP_NORMAL);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/jaguar.wav", (FMOD.MODE.HARDWARE | FMOD.MODE._3D), ref sound2);
            ERRCHECK(result);
            result = sound2.set3DMinMaxDistance(2.0f * DISTANCEFACTOR, 10000.0f * DISTANCEFACTOR);
            ERRCHECK(result);
            result = sound2.setMode(FMOD.MODE.LOOP_NORMAL);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/swish.wav", (FMOD.MODE.HARDWARE | FMOD.MODE._2D), ref sound3);
            ERRCHECK(result);

            /*
             *  Play sounds at certain positions
             */
            {
                FMOD.VECTOR pos1 = new FMOD.VECTOR();
                pos1.x = -10.0f * DISTANCEFACTOR; pos1.y = -0.0f; pos1.z = 0.0f;

                FMOD.VECTOR vel1 = new FMOD.VECTOR();
                vel1.x = 0.0f; vel1.y = 0.0f; vel1.z = 0.0f;

                result = system.playSound(FMOD.CHANNELINDEX.FREE, sound1, true, ref channel1);
                ERRCHECK(result);
                result = channel1.set3DAttributes(ref pos1, ref vel1);
                ERRCHECK(result);
                result = channel1.setPaused(false);
                ERRCHECK(result);
            }

            {
                FMOD.VECTOR pos2 = new FMOD.VECTOR();
                pos2.x = 15.0f * DISTANCEFACTOR; pos2.y = -0.0f; pos2.z = -0.0f;

                FMOD.VECTOR vel2 = new FMOD.VECTOR();
                vel2.x = 0.0f; vel2.y = 0.0f; vel2.z = 0.0f;

                result = system.playSound(FMOD.CHANNELINDEX.FREE, sound2, true, ref channel2);
                ERRCHECK(result);
                result = channel2.set3DAttributes(ref pos2, ref vel2);
                ERRCHECK(result);
                result = channel2.setPaused(false);
                ERRCHECK(result);
            }

            lastpos.x = 0.0f;
            lastpos.y = 0.0f;
            lastpos.z = 0.0f;

            listenerpos.x = 0.0f;
            listenerpos.y = 0.0f;
            listenerpos.z = -1.0f * DISTANCEFACTOR;
        }
Exemple #11
0
        private void threeD_Load(object sender, System.EventArgs e)
        {
            uint            version = 0;
            FMOD.RESULT     result;

            trackBarPosition.Enabled = false;

            /*
                Create a System object and initialize.
            */
            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();
            }

            FMOD.CAPS        caps        = FMOD.CAPS.NONE;
            FMOD.SPEAKERMODE speakermode = FMOD.SPEAKERMODE.STEREO;

            int	 minfrequency = 0, maxfrequency = 0;
            StringBuilder name = new StringBuilder(128);

            result = system.getDriverCaps(0, ref caps, ref minfrequency, ref maxfrequency, ref speakermode);
            ERRCHECK(result);

            result = system.setSpeakerMode(speakermode);                             /* Set the user selected speaker mode. */
            ERRCHECK(result);

            if ((caps & FMOD.CAPS.HARDWARE_EMULATED) == FMOD.CAPS.HARDWARE_EMULATED) /* The user has the 'Acceleration' slider set to off!  This is really bad for latency!. */
            {                                                                        /* You might want to warn the user about this. */
                result = system.setDSPBufferSize(1024, 10);	                     /* At 48khz, the latency between issuing an fmod command and hearing it will now be about 213ms. */
                ERRCHECK(result);
            }

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

            result = system.getDriverInfo(0, name, 256, ref guid);
            ERRCHECK(result);

            if (name.ToString().IndexOf("SigmaTel") != -1)   /* Sigmatel sound devices crackle for some reason if the format is pcm 16bit.  pcm floating point output seems to solve it. */
            {
                result = system.setSoftwareFormat(48000, FMOD.SOUND_FORMAT.PCMFLOAT, 0,0, FMOD.DSP_RESAMPLER.LINEAR);
                ERRCHECK(result);
            }

            result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER)
            {
                result = system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO);             /* Ok, the speaker mode selected isn't supported by this soundcard.  Switch it back to stereo... */
                ERRCHECK(result);

                result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null);        /* Replace with whatever channel count and flags you use! */
                ERRCHECK(result);
            }

            /*
                Set the distance units. (meters/feet etc).
            */
            result = system.set3DSettings(1.0f, DISTANCEFACTOR, 1.0f);
            ERRCHECK(result);

            /*
                Load some sounds
            */
            result = system.createSound("../../../../../examples/media/drumloop.wav", (FMOD.MODE.HARDWARE | FMOD.MODE._3D), ref sound1);
            ERRCHECK(result);
            result = sound1.set3DMinMaxDistance(2.0f * DISTANCEFACTOR, 10000.0f * DISTANCEFACTOR);
            ERRCHECK(result);
            result = sound1.setMode(FMOD.MODE.LOOP_NORMAL);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/jaguar.wav", (FMOD.MODE.HARDWARE | FMOD.MODE._3D), ref sound2);
            ERRCHECK(result);
            result = sound2.set3DMinMaxDistance(2.0f * DISTANCEFACTOR, 10000.0f * DISTANCEFACTOR);
            ERRCHECK(result);
            result = sound2.setMode(FMOD.MODE.LOOP_NORMAL);
            ERRCHECK(result);

            result = system.createSound("../../../../../examples/media/swish.wav", (FMOD.MODE.HARDWARE | FMOD.MODE._2D), ref sound3);
            ERRCHECK(result);

            /*
                Play sounds at certain positions
            */
            {
                FMOD.VECTOR pos1 = new FMOD.VECTOR();
                pos1.x = -10.0f * DISTANCEFACTOR; pos1.y = -0.0f; pos1.z = 0.0f;

                FMOD.VECTOR vel1 = new FMOD.VECTOR();
                vel1.x = 0.0f; vel1.y =  0.0f; vel1.z = 0.0f;

                result = system.playSound(FMOD.CHANNELINDEX.FREE, sound1, true, ref channel1);
                ERRCHECK(result);
                result = channel1.set3DAttributes(ref pos1, ref vel1);
                ERRCHECK(result);
                result = channel1.setPaused(false);
                ERRCHECK(result);
            }

            {
                FMOD.VECTOR pos2 = new FMOD.VECTOR();
                pos2.x = 15.0f * DISTANCEFACTOR; pos2.y = -0.0f; pos2.z = -0.0f;

                FMOD.VECTOR vel2 = new FMOD.VECTOR();
                vel2.x = 0.0f; vel2.y = 0.0f; vel2.z = 0.0f;

                result = system.playSound(FMOD.CHANNELINDEX.FREE, sound2, true, ref channel2);
                ERRCHECK(result);
                result = channel2.set3DAttributes(ref pos2, ref vel2);
                ERRCHECK(result);
                result = channel2.setPaused(false);
                ERRCHECK(result);
            }

            lastpos.x = 0.0f;
            lastpos.y = 0.0f;
            lastpos.z = 0.0f;

            listenerpos.x = 0.0f;
            listenerpos.y = 0.0f;
            listenerpos.z = -1.0f * DISTANCEFACTOR;
        }
        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());
            }
        }
Exemple #13
0
        public static bool Init()
        {
            FMOD.RESULT result;

            CONTROLS[(int)CONTROLTYPE.DIRECT]   = new ControlInfo(new PointF(0.0f, 1.0f), new PointF(0.5f, 0.0f), new PointF(1.0f, 0.6f), new PointF(-0.5f, 0.0f));
            CONTROLS[(int)CONTROLTYPE.REVERB]   = new ControlInfo(new PointF(0.0f, 0.3f), new PointF(0.5f, 0.0f), new PointF(1.0f, 0.0f), new PointF(-0.5f, 0.0f));
            CONTROLS[(int)CONTROLTYPE.LOWPASS]  = new ControlInfo(new PointF(0.0f, 1.0f), new PointF(0.5f, 0.0f), new PointF(1.0f, 0.0f), new PointF(-0.5f, 0.0f));
            CONTROLS[(int)CONTROLTYPE.ROLLOFF]  = new ControlInfo(new PointF(0.0f, 1.0f), new PointF(0.5f, 0.0f), new PointF(1.0f, 0.7f), new PointF(-0.5f, 0.0f));
            CONTROLS[(int)CONTROLTYPE.PANLEVEL] = new ControlInfo(new PointF(0.0f, 0.0f), new PointF(0.5f, 0.0f), new PointF(0.7f, 1.0f), new PointF(-0.5f, 0.0f));

            result = FMOD.Factory.System_Create(ref system);
            ERRCHECK(result);

            uint version = 0;

            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();
            }

            FMOD.CAPS        caps        = FMOD.CAPS.NONE;
            FMOD.SPEAKERMODE speakermode = FMOD.SPEAKERMODE.STEREO;

            int           minfrequency = 0, maxfrequency = 0;
            StringBuilder name = new StringBuilder(128);

            result = system.getDriverCaps(0, ref caps, ref minfrequency, ref maxfrequency, ref speakermode);
            ERRCHECK(result);

            result = system.setSpeakerMode(speakermode);
            ERRCHECK(result);

            if ((caps & FMOD.CAPS.HARDWARE_EMULATED) == FMOD.CAPS.HARDWARE_EMULATED)
            {
                result = system.setDSPBufferSize(1024, 10);
                ERRCHECK(result);
            }

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

            result = system.getDriverInfo(0, name, 256, ref guid);
            ERRCHECK(result);

            if (name.ToString().IndexOf("SigmaTel") != -1)
            {
                result = system.setSoftwareFormat(48000, FMOD.SOUND_FORMAT.PCMFLOAT, 0, 0, FMOD.DSP_RESAMPLER.LINEAR);
                ERRCHECK(result);
            }

            result = system.init(32, FMOD.INITFLAGS.NORMAL | FMOD.INITFLAGS._3D_RIGHTHANDED, (IntPtr)null);
            if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER)
            {
                result = system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO);
                ERRCHECK(result);

                result = system.init(32, FMOD.INITFLAGS.NORMAL | FMOD.INITFLAGS._3D_RIGHTHANDED, (IntPtr)null);
                ERRCHECK(result);
            }

            result = system.set3DSettings(2.0f, 100.0f, 1.0f);
            ERRCHECK(result);

            result = system.set3DRolloffCallback(ROLLOFFCALLBACK);
            ERRCHECK(result);

            FMOD.VECTOR pos; pos.x = 0.0f; pos.y = 0.0f; pos.z = 0.0f;
            FMOD.VECTOR vel; vel.x = 0.0f; vel.y = 0.0f; vel.z = 0.0f;
            FMOD.VECTOR dir; dir.x = 0.0f; dir.y = 1.0f; dir.z = 0.0f;
            FMOD.VECTOR up; up.x   = 0.0f; up.y = 0.0f; up.z = 1.0f;
            result = system.get3DListenerAttributes(0, ref pos, ref vel, ref dir, ref up);
            ERRCHECK(result);

            FMOD.PRESET preset = new FMOD.PRESET();
            REVERB[(int)REVERBTYPE.OFF]              = preset.OFF();
            REVERB[(int)REVERBTYPE.GENERIC]          = preset.GENERIC();
            REVERB[(int)REVERBTYPE.PADDEDCELL]       = preset.PADDEDCELL();
            REVERB[(int)REVERBTYPE.ROOM]             = preset.ROOM();
            REVERB[(int)REVERBTYPE.BATHROOM]         = preset.BATHROOM();
            REVERB[(int)REVERBTYPE.LIVINGROOM]       = preset.LIVINGROOM();
            REVERB[(int)REVERBTYPE.STONEROOM]        = preset.STONEROOM();
            REVERB[(int)REVERBTYPE.AUDITORIUM]       = preset.AUDITORIUM();
            REVERB[(int)REVERBTYPE.CONCERTHALL]      = preset.CONCERTHALL();
            REVERB[(int)REVERBTYPE.CAVE]             = preset.CAVE();
            REVERB[(int)REVERBTYPE.ARENA]            = preset.ARENA();
            REVERB[(int)REVERBTYPE.HANGAR]           = preset.HANGAR();
            REVERB[(int)REVERBTYPE.CARPETTEDHALLWAY] = preset.CARPETTEDHALLWAY();
            REVERB[(int)REVERBTYPE.HALLWAY]          = preset.HALLWAY();
            REVERB[(int)REVERBTYPE.STONECORRIDOR]    = preset.STONECORRIDOR();
            REVERB[(int)REVERBTYPE.ALLEY]            = preset.ALLEY();
            REVERB[(int)REVERBTYPE.FOREST]           = preset.FOREST();
            REVERB[(int)REVERBTYPE.CITY]             = preset.CITY();
            REVERB[(int)REVERBTYPE.MOUNTAINS]        = preset.MOUNTAINS();
            REVERB[(int)REVERBTYPE.QUARRY]           = preset.QUARRY();
            REVERB[(int)REVERBTYPE.PLAIN]            = preset.PLAIN();
            REVERB[(int)REVERBTYPE.PARKINGLOT]       = preset.PARKINGLOT();
            REVERB[(int)REVERBTYPE.SEWERPIPE]        = preset.SEWERPIPE();
            REVERB[(int)REVERBTYPE.UNDERWATER]       = preset.UNDERWATER();
            SetReverb(REVERBTYPE.OFF);

            return(true);
        }
Exemple #14
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());
            }
        }
        ///<summary>
        ///    Return an array of strings which are the driver names for the "microphone" devices.
        ///</summary>
        public string[] GetAllMicrophoneDevices(FMOD.System fmod)
        {
            FMOD.RESULT result;
            int numSoundSources = 0;
            StringBuilder drivername = new StringBuilder(256);

            //             result = system.setDriver(selected);
            //             ERRCHECK(result);

            // Get Record drivers
            result = fmod.getRecordNumDrivers(ref numSoundSources);
            CheckRetCode(result);

            string[] soundSourceNames = new string[numSoundSources];

            for (int count=0; count<numSoundSources; count++) {
                FMOD.GUID guid = new FMOD.GUID();
                result = fmod.getRecordDriverInfo(count, drivername, drivername.Capacity, ref guid);
                // result = fmod.getRecordDriverName(count, drivername, drivername.Capacity);
                CheckRetCode(result);
                soundSourceNames[count] = drivername.ToString();
            }
            return soundSourceNames;
        }
    public FMOD.Studio.EventInstance GetEvent(string path)
    {
        FMOD.Studio.EventInstance instance = null;

        if (string.IsNullOrEmpty(path))
        {
            FMOD.Studio.UnityUtil.LogError("Empty event path!");
            return null;
        }

        if (eventDescriptions.ContainsKey(path))
        {
            ERRCHECK(eventDescriptions[path].createInstance(out instance));
        }
        else
        {
            FMOD.GUID id = new FMOD.GUID();

            if (path.StartsWith("{"))
            {
                ERRCHECK(FMOD.Studio.Util.ParseID(path, out id));
            }
            else if (path.StartsWith("event:"))
            {
                ERRCHECK(system.lookupID(path, out id));
            }
            else
            {
                FMOD.Studio.UnityUtil.LogError("Expected event path to start with 'event:/'");
            }

            FMOD.Studio.EventDescription desc = null;
            ERRCHECK(system.getEventByID(id, out desc));

            if (desc != null && desc.isValid())
            {
                eventDescriptions.Add(path, desc);
                ERRCHECK(desc.createInstance(out instance));
            }
        }

        if (instance == null)
        {
            FMOD.Studio.UnityUtil.Log("GetEvent FAILED: \"" + path + "\"");
        }

        return instance;
    }
Exemple #17
0
 public EventNotFoundException(FMOD.GUID guid)
     : base("[FMOD] Event not found: " + guid)
 {
     Guid = guid;
 }
        ///<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;
        }
Exemple #19
0
        public string GetAllKindsOfInformation()
        {
            StringBuilder sb = new StringBuilder();

            uint version = 0;

            FMODSystem.getVersion(ref version);
            sb.AppendLine("FMOD Version: " + version);

            float cpuDSP = 0, cpuStream = 0, cpuGeometry = 0, cpuUpdate = 0, cpuTotal = 0;

            ERRCHECK(FMODSystem.getCPUUsage(ref cpuDSP, ref cpuStream, ref cpuGeometry, ref cpuUpdate, ref cpuTotal));
            sb.AppendFormat("CPU usage: (dsp {0:0.000}%, stream {1:0.000}%, geometry {2:0.000}%, update {3:0.000}%, total {4:0.000}%) {5}", cpuDSP, cpuStream, cpuGeometry, cpuUpdate, cpuTotal, Environment.NewLine);
            FMOD.MEMORY_USAGE_DETAILS memoryUsageDetails = new FMOD.MEMORY_USAGE_DETAILS();
            uint memoryUsed = 0;

            ERRCHECK(FMODSystem.getMemoryInfo((uint)FMOD.MEMBITS.ALL, (uint)FMOD.EVENT_MEMBITS.ALL, ref memoryUsed, ref memoryUsageDetails));
            sb.AppendFormat("Memory usage: {0:0,0} B{1}", memoryUsed, Environment.NewLine);

            /* // Sound RAM is dedicated RAM that exists on some devices, not ours though.
             * int ramCurrentAllocated = 0, ramMaxAllocated = 0, ramTotal = 0;
             * ERRCHECK(FMODSystem.getSoundRAM(ref ramCurrentAllocated, ref ramMaxAllocated, ref ramTotal));
             * sb.AppendFormat("Sound RAM (current alloc., max alloc., total): ({0}, {1}, {2}){3}",
             *  ramCurrentAllocated, ramMaxAllocated, ramTotal, Environment.NewLine); */
            sb.AppendLine("");

            int nDrivers = 0;

            ERRCHECK(FMODSystem.getNumDrivers(ref nDrivers));

            /*  // Caps cannot be called while the system is up and running
             * FMOD.CAPS caps = new FMOD.CAPS();
             * int hardwareMinFrequency = 0, hardwareMaxFrequency = 0;
             * FMOD.SPEAKERMODE controlPanelSpeakerMode = new FMOD.SPEAKERMODE();
             * for (int i = 0; i < nDrivers; i++)
             * {
             *  ERRCHECK(FMODSystem.getDriverCaps(i, ref caps, ref hardwareMinFrequency, ref hardwareMaxFrequency, ref controlPanelSpeakerMode));
             *
             *  sb.AppendLine("Driver id: " + i);
             *  sb.AppendLine("Caps: " + caps.ToString());
             *  sb.AppendLine("Hardware minimum frequency: " + hardwareMinFrequency);
             *  sb.AppendLine("Hardware maximum frequency: " + hardwareMaxFrequency);
             *  sb.AppendLine("Control panel speaker mode: " + controlPanelSpeakerMode.ToString());
             * }*/

            int currentDriver = -0;

            ERRCHECK(FMODSystem.getDriver(ref currentDriver));
            sb.AppendLine("Current driver: " + currentDriver);
            StringBuilder driverName = new StringBuilder(200);

            FMOD.GUID driverGuid = new FMOD.GUID();
            for (int i = 0; i < nDrivers; i++)
            {
                ERRCHECK(FMODSystem.getDriverInfo(i, driverName, 200, ref driverGuid));

                sb.AppendLine("Driver id: " + i + (currentDriver == i ? " (Selected)" : ""));
                sb.AppendLine("Device name: " + driverName.ToString());
                sb.AppendFormat("Driver GUID: ({0}, {1}, {2}){3}", driverGuid.Data1, driverGuid.Data2, driverGuid.Data3, Environment.NewLine);
                if (i == 0)
                {
                    sb.AppendLine("Drivers caps: " + driverCaps.ToString());
                }
                sb.AppendLine("");
            }

            int numHardwareChannels2D = 0, numHardwareChannels3D = 0, numHardwareChannelsTotal = 0;

            ERRCHECK(FMODSystem.getHardwareChannels(ref numHardwareChannels2D, ref numHardwareChannels3D, ref numHardwareChannelsTotal));
            sb.AppendFormat("Hardware channels: {0} ({1} 2D + {2} 3D){3}", numHardwareChannelsTotal, numHardwareChannels2D, numHardwareChannels3D, Environment.NewLine);
            int numSoftwareChannels2D = 0, numSoftwareChannels3D = 0, numSoftwareChannelsTotal = 0;

            ERRCHECK(FMODSystem.getHardwareChannels(ref numSoftwareChannels2D, ref numSoftwareChannels3D, ref numSoftwareChannelsTotal));
            sb.AppendFormat("Software channels: {0} ({1} 2D + {2} 3D){3}", numSoftwareChannelsTotal, numSoftwareChannels2D, numSoftwareChannels3D, Environment.NewLine);
            FMOD.SPEAKERMODE speakerMode = new FMOD.SPEAKERMODE();
            FMODSystem.getSpeakerMode(ref speakerMode);
            sb.AppendLine("Speaker mode: " + speakerMode.ToString());
            sb.AppendLine("Active speakers: ");
            foreach (FMOD.SPEAKER speaker in Enum.GetValues(typeof(FMOD.SPEAKER)))
            {
                if (speaker == FMOD.SPEAKER.MAX || speaker == FMOD.SPEAKER.MONO || speaker == FMOD.SPEAKER.NULL ||
                    speaker == FMOD.SPEAKER.SBL || speaker == FMOD.SPEAKER.SBR)
                {
                    continue;
                }

                float x = 0, y = 0;
                bool  active = false;
                ERRCHECK(FMODSystem.get3DSpeakerPosition(speaker, ref x, ref y, ref active));
                if (active)
                {
                    sb.AppendFormat("  {0} ({1}, {2}) {3}", Enum.GetName(speaker.GetType(), speaker), x, y, Environment.NewLine);
                }
            }

            sb.AppendLine("");

            uint selectedOutputPlugin = 0;

            ERRCHECK(FMODSystem.getOutputByPlugin(ref selectedOutputPlugin));
            FMOD.OUTPUTTYPE outputType = new FMOD.OUTPUTTYPE();
            ERRCHECK(FMODSystem.getOutput(ref outputType));
            sb.AppendLine("Output type: " + outputType);
            int nOutputPlugins = 0;

            ERRCHECK(FMODSystem.getNumPlugins(FMOD.PLUGINTYPE.OUTPUT, ref nOutputPlugins));
            IntPtr outputPluginHandle = new IntPtr();

            ERRCHECK(FMODSystem.getOutputHandle(ref outputPluginHandle));
            sb.AppendLine("Output handle: " + outputPluginHandle.ToInt32());
            sb.AppendLine("Plugins: ");
            for (int i = 0; i < nOutputPlugins; i++)
            {
                uint pluginHandle = 0;
                ERRCHECK(FMODSystem.getPluginHandle(FMOD.PLUGINTYPE.OUTPUT, i, ref pluginHandle));
                StringBuilder   pluginName    = new StringBuilder(100);
                uint            pluginVersion = 0;
                FMOD.PLUGINTYPE pluginType    = FMOD.PLUGINTYPE.OUTPUT;
                ERRCHECK(FMODSystem.getPluginInfo(pluginHandle, ref pluginType, pluginName, 100, ref pluginVersion));

                sb.AppendFormat("{0}{1} ({2} {3}) {4}", selectedOutputPlugin == pluginHandle ? "* " : "  ", pluginName, pluginType.ToString(), pluginVersion, Environment.NewLine);
            }
            sb.AppendLine();

            sb.AppendLine("Reverb properties: ");
            FMOD.REVERB_PROPERTIES reverbProperties = new FMOD.REVERB_PROPERTIES();
            ERRCHECK(FMODSystem.getReverbProperties(ref reverbProperties));
            sb.Append(StringifyStructure <FMOD.REVERB_PROPERTIES>(reverbProperties, "  "));
            sb.AppendLine("");

            sb.AppendLine("Ambient Reverb properties: ");
            FMOD.REVERB_PROPERTIES reverbAmbientProperties = new FMOD.REVERB_PROPERTIES();
            ERRCHECK(FMODSystem.getReverbAmbientProperties(ref reverbAmbientProperties));
            sb.Append(StringifyStructure <FMOD.REVERB_PROPERTIES>(reverbAmbientProperties, "  "));
            sb.AppendLine("");

            // Returns non-initialised values for some reason
            sb.AppendLine("Advanced settings: ");
            FMOD.ADVANCEDSETTINGS advancedSettings = new FMOD.ADVANCEDSETTINGS();
            ERRCHECK(FMODSystem.getAdvancedSettings(ref advancedSettings));
            sb.Append(StringifyStructure <FMOD.ADVANCEDSETTINGS>(advancedSettings, "  "));
            sb.AppendLine("");

            return(sb.ToString());
        }
Exemple #20
0
        public void Init(AudioDevice audioDevice, Vector2 minMaxDistance, int nSoundChannels, JMOD.CustomReadFileMethodDelegate customReadFileMethodDelegate)
        {
            // NOTE: Ignore customReadFileMethodDelegate for now... This is getting messy...

            // NOTE: This isn't implemented, but we'll just ignore the choice of audio device (you're not supposed to use FMOD anyway)
            //if (AudioDevice.DeviceID.Length > 0)
            //    throw new NotImplementedException();

            uint version = 0;

            FMOD.RESULT result;
            FMOD.System system = null;
            this.minMaxDistance = minMaxDistance;

            LogInit("Init() running with arguments ({0}, {1})", minMaxDistance, nSoundChannels);

            LogInit(false, "Creating system... ");
            result = FMOD.Factory.System_Create(ref system);
            LogInit(result.ToString());
            ERRCHECK(result);

            FMODSystem = system;
            SystemGlue = new FMODSystem(system);
            LogInit("Created SystemGlue");

            result = FMODSystem.getVersion(ref version);
            LogInit("FMOD version {0}, {1} required", version.ToString("X"), FMOD.VERSION.number.ToString("X"));
            ERRCHECK(result);
            if (version < FMOD.VERSION.number)
            {
                LogInit("ERROR: Version mismatch");
                throw new Exception("Error!  You are using an old version of FMOD " + version.ToString("X") + ".  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
            }

            result = FMODSystem.setHardwareChannels(0, 0, 0, 0);        // Skip EAX probe which can crash/corrupt some bad drivers
            LogInit("Disabling hardware channels. {0}", result.ToString());
            ERRCHECK(result);

            int nDrivers = -1;

            LogInit(false, "Checking number of drivers... ");
            result = FMODSystem.getNumDrivers(ref nDrivers);
            LogInit("{0} ({1})", result.ToString(), nDrivers);
            ERRCHECK(result);
            if (nDrivers == 0)
            {
                result = FMODSystem.setOutput(FMOD.OUTPUTTYPE.NOSOUND);
                LogInit("Output set to NOSOUND. " + result.ToString());
                ERRCHECK(result);
            }
            else
            {
                driverCaps = FMOD.CAPS.NONE;
                int minfrequency = 0, maxfrequency = 0;
                FMOD.SPEAKERMODE speakermode = FMOD.SPEAKERMODE.STEREO;

                result = FMODSystem.getDriverCaps(0, ref driverCaps, ref minfrequency, ref maxfrequency, ref speakermode);
                LogInit("Checking driver caps... " + result.ToString());
                ERRCHECK(result);
                LogInit("\tDriver caps: " + driverCaps);
                LogInit("\tFrequency range: {0}-{1}", minfrequency, maxfrequency);
                LogInit("\tSpeaker mode: {0}", speakermode);

                result = FMODSystem.setSpeakerMode(speakermode);
                LogInit("Set speaker mode to {0}. {1}", speakermode, result.ToString());
                ERRCHECK(result);

                if ((driverCaps & FMOD.CAPS.HARDWARE_EMULATED) == FMOD.CAPS.HARDWARE_EMULATED)      // The user has the 'Acceleration' slider set to off!  This is really bad for latency!
                {
                    LogInit("WARNING: Acceleration slider set to off");
                    result = FMODSystem.setDSPBufferSize(1024, 10);
                    LogInit("Set DSP buffer size to 10 * 1024. {0}", result.ToString());
                    ERRCHECK(result);
                }

                StringBuilder name = new StringBuilder(256);
                FMOD.GUID     guid = new FMOD.GUID();

                result = FMODSystem.getDriverInfo(0, name, 256, ref guid);
                LogInit("Fetching driver 0. {0}", result.ToString());
                ERRCHECK(result);
                LogInit("\tName: " + name);

                string tmpGuidStr = "";
                for (int i = 0; i < guid.Data4.Length; i++)
                {
                    tmpGuidStr += guid.Data4[i].ToString("X");
                    if (i == 1)
                    {
                        tmpGuidStr += "-";
                    }
                }

                LogInit("\tGUID: {0}-{1}-{2}-{3}", guid.Data1.ToString("X"), guid.Data2.ToString("X"), guid.Data3.ToString("X"), tmpGuidStr);

                if (name.ToString().IndexOf("SigmaTel") != -1)
                {
                    result = FMODSystem.setSoftwareFormat(48000, FMOD.SOUND_FORMAT.PCMFLOAT, 0, 0, FMOD.DSP_RESAMPLER.LINEAR);
                    LogInit("Set SigmaTel-specific software format settings. {0}", result.ToString());
                    ERRCHECK(result);
                }

                if (nDrivers > 1)
                {
                    LogInit("======================================");
                    LogInit("Drivers:");
                    for (int i = 0; i < nDrivers; i++)
                    {
                        LogInit("--------------------------------------");
                        LogDeviceInformation(i);
                    }
                    LogInit("======================================");
                }
            }

            result = FMODSystem.init(nSoundChannels, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
            LogInit("Running init({0}, {1}, null). {2}", nSoundChannels, FMOD.INITFLAGS.NORMAL, result.ToString());
            if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER)
            {
                LogInit("ERROR: Could not create buffer");
                result = FMODSystem.setSpeakerMode(FMOD.SPEAKERMODE.STEREO);
                LogInit("Set speaker mode to STEREO. {0}", result.ToString());
                ERRCHECK(result);

                result = FMODSystem.init(nSoundChannels, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
                LogInit("Running init({0}, {1}, null). {2}", nSoundChannels, FMOD.INITFLAGS.NORMAL, result.ToString());

                if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER)
                {
                    LogInit("ERROR: Could not create buffer");
                    result = FMODSystem.setOutput(FMOD.OUTPUTTYPE.WINMM);
                    LogInit("Set output to WINMM. {0}", result.ToString());
                    ERRCHECK(result);

                    result = FMODSystem.init(nSoundChannels, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
                    LogInit("Running init({0}, {1}, null). {2}", nSoundChannels, FMOD.INITFLAGS.NORMAL, result.ToString());
                    ERRCHECK(result);
                }
            }

            result = FMODSystem.set3DSettings(1f, 1f, 1f);
            LogInit("Set 3D-settings to (1, 1, 1). {0}", result.ToString());
            ERRCHECK(result);

            NonBlockCallback = new FMOD.SOUND_NONBLOCKCALLBACK(NonBlockCallbackMethod);
        }
        private void comboBoxOutput_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            FMOD.RESULT     result     = FMOD.RESULT.OK;
            StringBuilder   drivername = new StringBuilder(256);
            int             numdrivers = 0;
            FMOD.GUID       guid = new FMOD.GUID();

            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;
                default:
                    return;
            }
            ERRCHECK(result);

            /*
                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());
            }

            comboBoxOutput.Enabled = false;
            comboBoxRecord.Enabled = true;
        }
    public FMOD.Studio.EventInstance getEvent(string path)
    {
        FMOD.Studio.EventInstance instance = null;

        if (string.IsNullOrEmpty(path))
        {
            Debug.LogError("Empty event path!");
            return null;
        }

        if (eventDescriptions.ContainsKey(path))
        {
            ERRCHECK(eventDescriptions[path].createInstance(out instance));
        }
        else
        {
            FMOD.GUID id = new FMOD.GUID();

            if (path.StartsWith("{"))
            {
                ERRCHECK(FMOD.Studio.Util.ParseID(path, out id));
            }
            else if (path.StartsWith("/"))
            {
                ERRCHECK(system.lookupEventID(path, out id));
            }
            else
            {
                Debug.LogError("Expected event path to start with '/'");
            }

            FMOD.Studio.EventDescription desc = null;
            ERRCHECK(system.getEvent(id, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out desc));

            eventDescriptions.Add(path, desc);
            ERRCHECK(desc.createInstance(out instance));
        }

        //		Debug.Log("get event: " + (instance != null ? "suceeded!!" : "failed!!")); //PAS

        return instance;
    }