Esempio n. 1
0
        private MusicPlayer()
        {
            result = FMOD.Factory.System_Create(out FMODSystem);

            if (result != FMOD.RESULT.OK)
            {
                throw new Exception("This crap didn't work!!");
            }

            result = FMODSystem.setDSPBufferSize(1024, 10);
            result = FMODSystem.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)0);

            var info = new FMOD.CREATESOUNDEXINFO();
            var song = new FMOD.Sound();

            ChannelGroup = new FMOD.ChannelGroup();
            ChannelGroup.clearHandle();

            result = FMODSystem.createStream("rain.ogg", FMOD.MODE.DEFAULT, out song);

            result = FMODSystem.playSound(song, ChannelGroup, false, out Channel);



            bool isPlaying = false;

            Channel.isPlaying(out isPlaying);

            Channel.setVolume(1);
            Channel.setMode(FMOD.MODE.LOOP_NORMAL);
            Channel.setLoopCount(-1);

            int t = 1;
        }
 public FMODChannel(FMOD.Channel channel, bool looping)
 {
     this.channel = channel;
     FMODManager.Instance.SetChannelMapping(channel.getRaw().ToInt32(), this);
     FMODManager.ERRCHECK(channel.setCallback(ChannelCallback));
     if (looping)
         channel.setMode(FMOD.MODE.LOOP_NORMAL);
 }
Esempio n. 3
0
 public FMODChannel(FMOD.Channel channel, bool looping)
 {
     this.channel = channel;
     FMODManager.Instance.SetChannelMapping(channel.getRaw().ToInt32(), this);
     FMODManager.ERRCHECK(channel.setCallback(ChannelCallback));
     if (looping)
     {
         channel.setMode(FMOD.MODE.LOOP_NORMAL);
     }
 }
Esempio n. 4
0
        public void PlaySound(int soundId)
        {
            if (soundId >= 0 && soundId < NUM_SFX && SoundFX[soundId] != null)
            {
                FMOD.RESULT r = FMODSystem.playSound(SoundFX[soundId], null, false, out SoundChannel);
                //UpdateVolume(1.0f);
                SoundChannel.setMode(FMOD.MODE.LOOP_OFF);
                SoundChannel.setLoopCount(-1);

                Console.WriteLine("Playing sound " + soundId + ", got result " + r);

                m_iCurrentSongID = soundId;
            }
        }
Esempio n. 5
0
        public void Play(int songId)
        {
            if (m_iCurrentSongID != songId)
            {
                Stop();

                if (songId >= 0 && songId < NUM_SONGS && Music[songId] != null)
                {
                    FMOD.RESULT r = FMODSystem.playSound(Music[songId], null, false, out MusicChannel);
                    UpdateVolume(1.0f);
                    MusicChannel.setMode(FMOD.MODE.LOOP_NORMAL);
                    MusicChannel.setLoopCount(-1);

                    //Console.WriteLine("Playing track " + songId + ", got result" + r);

                    m_iCurrentSongID = songId;
                }
            }
        }
Esempio n. 6
0
        protected void UpdateMode()
        {
            if (channel == null)
            {
                return;
            }

            FMOD.MODE mode;

            if (ambient)
            {
                mode = FMOD.MODE.HARDWARE | FMOD.MODE._2D;
            }
            else
            {
                mode = FMOD.MODE.HARDWARE | FMOD.MODE._3D;
            }

            if (looping)
            {
                mode |= FMOD.MODE.LOOP_NORMAL;
            }
            else
            {
                mode |= FMOD.MODE.LOOP_OFF;
            }

            if (linearAttenuation)
            {
                mode |= FMOD.MODE._3D_LINEARROLLOFF;
            }
            else
            {
                mode |= FMOD.MODE._3D_LOGROLLOFF;
            }

            FMOD.RESULT result = channel.setMode(mode);
            CheckRetCode(result);
        }
Esempio n. 7
0
        public static void Play(string key, int speaker, float volume = 1f, bool loop = false)
        {
            #if NO_AUDIO
            return;
            #endif


            // play audio
            FMOD.RESULT result = system.playSound(FMOD.CHANNELINDEX.FREE, sounds[key], true, ref channel);
            ERRCHECK(result);

            result = channel.setVolume(volume);
            ERRCHECK(result);

            int index = 0;
            channel.getIndex(ref index);
            channelIDs.Add(index);


            FMOD.MODE loopAudio = (loop) ? FMOD.MODE.LOOP_NORMAL : FMOD.MODE.LOOP_OFF;
            result = channel.setMode(loopAudio);

            //SPEAKER 1 (Satelite Audio, Side Specific)
            if (speaker == 0)
            {
                result = channel.setSpeakerMix(0, 0, 0, 0, 0, 0, 1.0f, 0);
                ERRCHECK(result);
            }

            //SPEAKER 2 (Satelite Audio, Side Specific)
            if (speaker == 1)
            {
                result = channel.setSpeakerMix(0, 0, 0, 0, 0, 0, 0, 1.0f);
                ERRCHECK(result);
            }

            //SPEAKER 3 (Satelite Audio, Side Specific)
            if (speaker == 2)
            {
                result = channel.setSpeakerMix(0, 0, 0, 0, 1.0f, 0, 0, 0);
                ERRCHECK(result);
            }

            //SPEAKER (Satelite Audio, Side Specific)
            if (speaker == 3)
            {
                result = channel.setSpeakerMix(0, 0, 0, 0, 0, 1.0f, 0, 0);
                ERRCHECK(result);
            }

            //SPEAKER 5 (Subwoofer)
            if (speaker == 4)
            {
                result = channel.setSpeakerMix(0, 0, 1.0f, 0, 0, 0, 0, 0);
                ERRCHECK(result);
            }

            if (isMuted)
            {
                channel.setMute(isMuted);
            }

            result = channel.setPaused(false);

            ERRCHECK(result);
        }