public static void StartTitleMusic() { lock (staticMutationLock) { var soundToLoad = AssetLocator.BackgroundMusic[11]; if (soundToLoad == prevSound) { return; } string musicFile = Path.Combine(AssetLocator.AudioDir, @"BGM\") + TITLE_MUSIC_FILE; prevSound = curSound; curSound = soundToLoad; int instanceId = AudioModule.CreateSoundInstance(musicFile); curSound.AddInstance(instanceId); AudioModule.PlaySoundInstance(instanceId, true, Config.MusicVolume); prevMusicInstanceID = curMusicInstanceID; curMusicInstanceID = instanceId; prevMusicVol = 0f; curMusicVol = Config.MusicVolume; if (prevSound != null) { prevSound.StopAllInstances(); } } }
public static void CrossFadeToWorldMusic(byte worldIndex) { lock (staticMutationLock) { var soundToLoad = AssetLocator.BackgroundMusic[worldIndex]; if (soundToLoad == curSound) { return; } if (prevSound != null) { prevSound.StopAllInstances(); } string musicFile = Path.Combine(AssetLocator.AudioDir, @"BGM\") + worldIndex + ".mp3"; prevSound = curSound; curSound = soundToLoad; int instanceId = AudioModule.CreateSoundInstance(musicFile); curSound.AddInstance(instanceId); AudioModule.PlaySoundInstance(instanceId, true, 0f); prevMusicInstanceID = curMusicInstanceID; curMusicInstanceID = instanceId; prevMusicVol = curMusicVol; curMusicVol = 0f; } }