예제 #1
0
        public static void EnableFFT()
        {
            FFTEnabled = true;
            system.getMasterChannelGroup(out ChannelGroup);
            system.createDSPByType(FMOD.DSP_TYPE.FFT, out MyDSP);
            ChannelGroup.addDSP(1, MyDSP);

            MyDSP.setActive(true);
        }
예제 #2
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            uint version = 0;

            FMOD.RESULT result;

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

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

            result = system.createSound("../../../../../examples/media/drumloop.wav", FMOD.MODE.SOFTWARE | FMOD.MODE.LOOP_NORMAL, ref sound);
            ERRCHECK(result);

            result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);
            ERRCHECK(result);

            /*
             *  Create DSP unit
             */

            cohar[] nameArray = new char[32];
            dspname.ToCharArray().CopyTo(nameArray, 0);

            dspdesc.name     = nameArray;
            dspdesc.channels = 0;
            dspdesc.read     = dspreadcallback;

            result = system.createDSP(ref dspdesc, ref mydsp);
            ERRCHECK(result);

            result = system.addDSP(mydsp, ref dspconnectiontemp);
            ERRCHECK(result);

            result = mydsp.setActive(true);
            ERRCHECK(result);

            result = mydsp.setBypass(true);
            ERRCHECK(result);
        }
예제 #3
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            uint version = 0;

            FMOD.RESULT        result;
            FMOD.DSPConnection dspconnectiontemp = null;

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

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

            result = system.createSound("../../../../../examples/media/drumloop.wav", FMOD.MODE.SOFTWARE | FMOD.MODE.LOOP_NORMAL, ref sound);
            ERRCHECK(result);

            result = system.playSound(FMOD.CHANNELINDEX.FREE, sound, false, ref channel);
            ERRCHECK(result);

            /*
             *  Create the DSP effects.
             */
            result = system.createDSPByType(FMOD.DSP_TYPE.LOWPASS, ref dsplowpass);
            ERRCHECK(result);

            result = system.createDSPByType(FMOD.DSP_TYPE.CHORUS, ref dspchorus);
            ERRCHECK(result);

            /*
             *  Connect up the DSP network
             */

            /*
             *  When a sound is played, a subnetwork is set up in the DSP network which looks like this.
             *  Wavetable is the drumloop sound, and it feeds its data from right to left.
             *
             *  [DSPHEAD]<------------[DSPCHANNELMIXER]
             */
            result = system.getDSPHead(ref dsphead);
            ERRCHECK(result);

            result = dsphead.getInput(0, ref dspchannelmixer, ref dspconnectiontemp);
            ERRCHECK(result);

            /*
             *  Now disconnect channeldsp head from wavetable to look like this.
             *
             *  [DSPHEAD]             [DSPCHANNELMIXER]
             */
            result = dsphead.disconnectFrom(dspchannelmixer);
            ERRCHECK(result);

            /*
             *  Now connect the 2 effects to channeldsp head.
             *
             *            [DSPLOWPASS]
             *           /
             *  [DSPHEAD]             [DSPCHANNELMIXER]
             \
             \            [DSPCHORUS]
             */
            result = dsphead.addInput(dsplowpass, ref dsplowpassconnection);
            ERRCHECK(result);
            result = dsphead.addInput(dspchorus, ref dspchorusconnection);
            ERRCHECK(result);

            /*
             *  Now connect the wavetable to the 2 effects
             *
             *            [DSPLOWPASS]
             *           /           \
             *  [DSPHEAD]             [DSPCHANNELMIXER]
             \           /
             \            [DSPCHORUS]
             */
            result = dsplowpass.addInput(dspchannelmixer, ref dspconnectiontemp);
            ERRCHECK(result);
            result = dspchorus.addInput(dspchannelmixer, ref dspconnectiontemp);
            ERRCHECK(result);

            /*
             *  Now the drumloop will be twice as loud, because it is being split into 2, then recombined at the end.
             *  What we really want is to only feed the dspchannelmixer->dsplowpass through the left speaker, and
             *  dspchannelmixer->dspchorus to the right speaker.
             *  We can do that simply by setting the pan, or speaker levels of the connections.
             *
             *            [DSPLOWPASS]
             *           /1,0        \
             *  [DSPHEAD]             [DSPCHANNELMIXER]
             \0,1        /
             *            [DSPCHORUS]
             */
            {
                float[] leftinputon  = { 1.0f, 0.0f };
                float[] rightinputon = { 0.0f, 1.0f };
                float[] inputsoff    = { 0.0f, 0.0f };

                result = dsplowpassconnection.setLevels(FMOD.SPEAKER.FRONT_LEFT, leftinputon, 2);
                ERRCHECK(result);
                result = dsplowpassconnection.setLevels(FMOD.SPEAKER.FRONT_RIGHT, inputsoff, 2);
                ERRCHECK(result);

                result = dsplowpassconnection.setLevels(FMOD.SPEAKER.FRONT_LEFT, inputsoff, 2);
                ERRCHECK(result);
                result = dsplowpassconnection.setLevels(FMOD.SPEAKER.FRONT_RIGHT, rightinputon, 2);
                ERRCHECK(result);
            }

            result = dsplowpass.setBypass(true);
            result = dspchorus.setBypass(true);

            result = dsplowpass.setActive(true);
            result = dspchorus.setActive(true);
        }