Esempio n. 1
0
 public SoundReversibleInstance CreateInstance(float volume, float pitch, float pan, bool inReverse = false)
 {
     SoundReversibleInstance newInstance = new SoundReversibleInstance(this, audioBytes, sampleRate, (AudioChannels)channels, inReverse);
     newInstance.Volume = volume;
     newInstance.Pitch = pitch;
     newInstance.Pan = pan;
     newInstance.IsReversed = inReverse;
     return newInstance;
 }
Esempio n. 2
0
 public static void Initialize()
 {
     registeredSounds = new HashSet<SoundReversibleInstance>();
     soundsToUnregister = new List<SoundReversibleInstance>();
     HasPlayedMap = new Dictionary<string, bool>();
     currentMusicInstance = null;
     currentMusicName = null;
     targetVolume = DEFAULT_VOLUME;
     currentVolume = targetVolume;
 }
Esempio n. 3
0
 public static void UnregisterSoundInstance(SoundReversibleInstance instance)
 {
     soundsToUnregister.Add(instance);
 }
Esempio n. 4
0
 public static void StopMusic()
 {
     if (currentMusicInstance != null)
     {
         currentMusicInstance.Stop();
         currentMusicInstance = null;
         currentMusicName = null;
     }
 }
Esempio n. 5
0
 public static void RegisterSoundInstance(SoundReversibleInstance instance)
 {
     registeredSounds.Add(instance);
 }
Esempio n. 6
0
 public static void PlaySoundAsMusic(string soundName)
 {
     if (soundName == currentMusicName)
         return;
     else if (soundName == null)
     {
         currentMusicInstance.Stop();
         currentMusicInstance = null;
         return;
     }
     if (SoundMap.ContainsKey(soundName))
     {
         if (currentMusicInstance != null)
         {
             if (soundName == currentMusicName)
             {
                 if (currentMusicInstance.IsDisposed || currentMusicInstance.State == SoundState.Stopped)
                     currentMusicInstance.Play();
             }
             else
             {
                 currentMusicInstance.Stop();
                 SoundReversibleInstance instance = SoundMap[soundName].CreateInstance();
                 instance.IsLooped = true;
                 instance.Volume = musicMasterVolume * currentVolume;
                 instance.Play();
                 currentMusicInstance = instance;
                 currentMusicName = soundName;
                 HasPlayedMap[soundName] = true;
             }
         }
         else
         {
             SoundReversibleInstance instance = SoundMap[soundName].CreateInstance();
             instance.IsLooped = true;
             instance.Volume = musicMasterVolume * currentVolume;
             instance.Play();
             currentMusicInstance = instance;
             currentMusicName = soundName;
             HasPlayedMap[soundName] = true;
         }
     }
 }