Beispiel #1
0
        public PlayState(StateManager stateManager, GameWorld gameWolrd)
            : base(stateManager)
        {
            _gameWorld = gameWolrd;

            backgroundSound = new AudioClip(Path.Combine("Content", "Sounds", "rainfall.ogg"));
            backgroundSound.Play();
        }
Beispiel #2
0
        /// <summary>
        /// Plays the audio clip on the first free channel.
        /// </summary>
        /// <param name="clip">The audio clip to play.</param>
        public void PlayClip(AudioClip clip)
        {
            // TODO: If all channels are busy, the clip will be ignored.  There must be a more elegant way.
            foreach (AudioChannel channel in Channels)
            {

                    if (channel.IsFree)
                    {
                        channel.Init(clip);
                        channel.Play();
                        return;
                    }
            }
        }
Beispiel #3
0
        public void Init(AudioClip clip)
        {
            ALSourceState state = AL.GetSourceState(Source);
            if (state == ALSourceState.Playing || state == ALSourceState.Paused)
            {
                Stop();
            }
            if (clip != CurrentClip)
            {
                CloseReader();
                CurrentClip = clip;
                OpenReader();

                CurrentFormat = Reader.Channels == 1 ? ALFormat.Mono16 : ALFormat.Stereo16;
                CurrentRate = Reader.SampleRate;
            }
        }
Beispiel #4
0
 internal void AddClip(AudioClip clip)
 {
     lock (workWithListMutex)
     {
         StaticClips.Add(clip);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Plays the audio clip on the first free channel.
        /// </summary>
        /// <param name="clip">The audio clip to play.</param>
        public AudioRemoteControll PlayClip(AudioClip clip)
        {
            // TODO: If all channels are busy, the clip will be ignored.  There must be a more elegant way.
            lock (workWithListMutex)
            {
                foreach (AudioChannel channel in Channels)
                {

                    if (channel.IsFree)
                    {
                        channel.Init(clip);
                        channel.Play();
                        return channel.CreateRemote();
                    }
                }
                return null; // All channels are busy
            }
        }