Example #1
0
 public void Load(SoundFile sound)
 {
     file = sound;
     AL.Source(source, ALSourceb.SourceRelative, true);
     AL.BufferData(buffer, file.SoundFormat, file.data, file.data.Length, file.sampleRate);
     AL.Source(source, ALSourcei.Buffer, buffer);
 }
Example #2
0
        /*
         *
         * SFX PLAYER(S)
         *
         * used for unlimited sound effects to be played at once, and in 3d if needed.
         *
         */

        public static void PlaySound(string file, float volume = 100, bool looping = false)
        {
            SoundFile sound = cache.GetSound(file);

            if (sound == null || !sound.Ready())
            {
                return;
            }

            AudioPlayer player = new AudioPlayer();

            player.Load(sound);

            player.SetVolume(volume);
            player.SetLooping(looping);

            player.Play();
            nowPlaying.Add(player);
        }
Example #3
0
        /*
         *
         * MUSIC PLAYER
         *
         * used for music tracks and soundtrack exclusively. allows for one hefty file at a time.
         *
         */

        public static void PlayTrack(string file, float volume = 100, bool looping = false)
        {
            SoundFile sound = cache.GetSound(file, false);

            if (sound == null || !sound.Ready())
            {
                return;
            }

            musicPlayer = new AudioPlayer();
            if (musicPlayer.IsPlaying())
            {
                musicPlayer.Stop();
            }
            musicPlayer.Load(sound);

            musicPlayer.SetVolume(volume);
            musicPlayer.SetLooping(looping);

            musicPlayer.Play();
        }