예제 #1
0
        public bool StopSound(uint channelIndex)
        {
            channelIndex %= MAX_CHANNEL;

            if (channelIndex >= MAX_CHANNEL)
            {
                return(false);
            }

            FMODEX.Channel channel = _channels[channelIndex];
            if (channel == null)
            {
                return(false);
            }

            bool isPlaying = false;

            FMODEX.RESULT iresult = channel.isPlaying(ref isPlaying);
            if (iresult == FMODEX.RESULT.OK && isPlaying)
            {
                iresult = channel.stop();
            }

            return(iresult == FMODEX.RESULT.OK);
        }
예제 #2
0
        public bool PauseSound(uint channelIndex)
        {
            channelIndex %= MAX_CHANNEL;

            if (channelIndex >= MAX_CHANNEL)
            {
                return(false);
            }

            FMODEX.Channel channel = _channels[channelIndex];
            if (channel == null)
            {
                return(false);
            }

            bool paused = false;

            FMODEX.RESULT iresult = channel.getPaused(ref paused);
            if (iresult == FMODEX.RESULT.OK)
            {
                channel.setPaused(!paused);
            }

            return(iresult == FMODEX.RESULT.OK);
        }
예제 #3
0
        public bool PlaySound(uint channelIndex, uint soundIndex, float volume, byte pan, uint offset = 0)
        {
            channelIndex %= MAX_CHANNEL;

            if ((soundIndex >= MAX_SOUND) || (channelIndex >= MAX_CHANNEL))
            {
                return(false);
            }

            FMODEX.Channel channel = _channels[channelIndex];

            if (channel != null)
            {
                bool          isPlaying = false;
                FMODEX.RESULT iresult   = channel.isPlaying(ref isPlaying);
                if (iresult == FMODEX.RESULT.OK && isPlaying)
                {
                    //channel.stop();
                    //channel.setPaused(true);
                }
            }

            if (m_sounds[soundIndex] == null)
            {
                return(false);
            }

            // convert pan settings
            float fpan = 0;

            if (64 < (int)pan)
            {
                fpan = (float)(((double)pan - 64.0) / 63.0);
            }
            else
            {
                fpan = (float)(((double)pan - 64.0) / 64.0);
            }

            FMODEX.Channel chan   = null;
            FMODEX.RESULT  result = m_system.playSound(FMODEX.CHANNELINDEX.FREE, m_sounds[soundIndex], true, ref _channels[channelIndex]);
            if (result == FMODEX.RESULT.OK)
            {
                chan = _channels[channelIndex];
                chan.setVolume(volume);
                chan.setPan(fpan);
                chan.setPaused(false);

                if (offset != 0)
                {
                    Logs.Write("Seek sound {0} to position {1} ms", soundIndex, offset);
                    chan.setPosition(offset, FMODEX.TIMEUNIT.PCM);
                }
            }

            return(result == FMODEX.RESULT.OK);
        }
예제 #4
0
        public bool SetVolume(uint channelIndex, float volume)
        {
            channelIndex %= MAX_CHANNEL;

            FMODEX.Channel channel = _channels[channelIndex];

            if (channel == null)
            {
                return(false);
            }

            FMODEX.RESULT result = channel.setVolume(volume);

            return(result == FMODEX.RESULT.OK);
        }
예제 #5
0
        public uint GetPosition(uint channelIndex)
        {
            channelIndex %= MAX_CHANNEL;

            uint result = 0;

            FMODEX.Channel channel = _channels[channelIndex];

            if (channel != null)
            {
                FMODEX.RESULT fmodResult =
                    channel.getPosition(ref result, FMODEX.TIMEUNIT.PCM);
            }

            return(result);
        }