Exemple #1
0
        public SoundController(Layer layer) : base(layer)
        {
            MusicGroup = AudioMgr.CreateChannelGroup("music");
            SoundGroup = AudioMgr.CreateChannelGroup("sound");

            MusicGroup.setVolume(MusicVolume);
            SoundGroup.setVolume(SoundVolume);
        }
Exemple #2
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            int  count   = 0;
            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.LOOP_NORMAL, ref sound[0]);
            ERRCHECK(result);
            result = system.createSound("../../../../../examples/media/jaguar.wav", FMOD.MODE.LOOP_NORMAL, ref sound[1]);
            ERRCHECK(result);
            result = system.createSound("../../../../../examples/media/swish.wav", FMOD.MODE.LOOP_NORMAL, ref sound[2]);
            ERRCHECK(result);
            result = system.createSound("../../../../../examples/media/c.ogg", FMOD.MODE.LOOP_NORMAL, ref sound[3]);
            ERRCHECK(result);
            result = system.createSound("../../../../../examples/media/d.ogg", FMOD.MODE.LOOP_NORMAL, ref sound[4]);
            ERRCHECK(result);
            result = system.createSound("../../../../../examples/media/e.ogg", FMOD.MODE.LOOP_NORMAL, ref sound[5]);
            ERRCHECK(result);

            result = system.createChannelGroup("Group A", ref groupA);
            ERRCHECK(result);

            result = system.createChannelGroup("Group B", ref groupB);
            ERRCHECK(result);

            result = system.getMasterChannelGroup(ref masterGroup);
            ERRCHECK(result);

            /*
             *  Instead of being independent, set the group A and B to be children of the master group.
             */
            result = masterGroup.addGroup(groupA);
            ERRCHECK(result);

            result = masterGroup.addGroup(groupB);
            ERRCHECK(result);

            /*
             *  Start all the sounds!
             */
            for (count = 0; count < 6; count++)
            {
                result = system.playSound(FMOD.CHANNELINDEX.FREE, sound[count], true, ref channel[count]);
                ERRCHECK(result);
                if (count < 3)
                {
                    result = channel[count].setChannelGroup(groupA);
                }
                else
                {
                    result = channel[count].setChannelGroup(groupB);
                }
                ERRCHECK(result);

                result = channel[count].setPaused(false);
                ERRCHECK(result);
            }

            /*
             *  Change the volume of each group, just because we can!  (And makes it less noise).
             */
            result = groupA.setVolume(0.5f);
            ERRCHECK(result);
            result = groupB.setVolume(0.5f);
            ERRCHECK(result);
        }