public void PlayMusic(Int32 soundIndex, Int32 fadeIn, SoundProfileType type = SoundProfileType.Music) { SoundProfile soundProfile = this.soundDatabase.Read(soundIndex); if (soundProfile == null) { soundProfile = this.onTheFlySoundDatabase.Read(soundIndex); } if (soundProfile != null) { this.PlayMusic(soundProfile, fadeIn); } else { soundProfile = SoundMetaData.GetSoundProfile(soundIndex, type); this.onTheFlyLoadedSoundProfile = soundProfile; this.onTheFlyLoadedFadeIn = fadeIn; if (this.onTheFlySoundDatabase.ReadAll().Count >= 10) { SoundLib.Log("Unload on the fly sound database."); base.UnloadResource(this.onTheFlySoundDatabase); } base.LoadResource(soundProfile, this.onTheFlySoundDatabase, new SoundPlayer.LoadResourceCallback(this.LoadOnTheFlySoundResourceCallback)); } }
public void ReloadSoundMetaData() { SoundMetaData.LoadMetaData(); this.ParseSoundList(); SoundLib.UnloadSoundEffect(); SoundLib.LoadGameSoundEffect(SoundMetaData.SoundEffectMetaData); SoundLib.UnloadMusic(); SoundLib.LoadMusic(SoundMetaData.MusicMetaData); }
private static void LoadMetaDataFromStreamingAssets() { Int32 num = 0; List <SoundMetaDataProfile> list = new List <SoundMetaDataProfile>(); List <SoundMetaDataProfile> list2 = new List <SoundMetaDataProfile>(); String item = AssetManagerUtil.GetStreamingAssetsPath() + "/Sounds"; Queue <String> queue = new Queue <String>(); queue.Enqueue(item); while (queue.Count > 0) { String text = queue.Peek(); String[] directories = Directory.GetDirectories(text); String[] array = directories; for (Int32 i = 0; i < (Int32)array.Length; i++) { String item2 = array[i]; queue.Enqueue(item2); } String[] files = Directory.GetFiles(text); String[] array2 = files; for (Int32 j = 0; j < (Int32)array2.Length; j++) { String text2 = array2[j]; String[] array3 = text2.Split(new Char[] { '.' }); String a = array3[(Int32)array3.Length - 1]; if (!String.Equals(a, "meta")) { String[] array4 = text.Split(new Char[] { '/' }); String[] array5 = array4[(Int32)array4.Length - 1].Split(new Char[] { '\\' }); String text3 = array5[(Int32)array5.Length - 1]; String fileName = Path.GetFileName(text2); if (String.Equals(text3, "BGM_") || String.Equals(text3, "Movie_") || String.Equals(text3, "song_") || String.Equals(text3, "OldBGM")) { list2.Add(new SoundMetaDataProfile(text3 + "/" + fileName, num++, "Music")); } else { list.Add(new SoundMetaDataProfile(text3 + "/" + fileName, num++, "SoundEffect")); } } } queue.Dequeue(); } SoundMetaData.SoundEffectMetaData = SoundMetaData.ComposeMetaDataJsonString(list); SoundMetaData.MusicMetaData = SoundMetaData.ComposeMetaDataJsonString(list2); }
public void PlayMusic(String soundName, Int32 fadeIn = 0) { Int32 soundIndex = SoundMetaData.GetSoundIndex(soundName, SoundProfileType.MovieAudio); SoundLib.Log("PlayMuvieAudio movieName: " + soundName); if (soundIndex != -1) { base.PlayMusic(soundIndex, fadeIn, SoundProfileType.MovieAudio); } }
/// <summary> /// Setup a step sound for a cube type /// </summary> /// <param name="cubeId"></param> /// <param name="sound"></param> private void RegisterStepSound(byte cubeId, SoundMetaData sound) { if (_stepsSounds.ContainsKey(cubeId)) { _stepsSounds[cubeId].Add(sound); } else { _stepsSounds.Add(cubeId, new List <SoundMetaData> { sound }); } }
private static void LoadMetaDataFromResources() { List <SoundMetaDataProfile> list = new List <SoundMetaDataProfile>(); list.Add(new SoundMetaDataProfile("SE_BT_AB01_00", 0, "SoundEffect")); list.Add(new SoundMetaDataProfile("SE_BT_AB01_01", 1, "SoundEffect")); List <SoundMetaDataProfile> list2 = new List <SoundMetaDataProfile>(); list2.Add(new SoundMetaDataProfile("FF4Bat1", 2, "Music")); list2.Add(new SoundMetaDataProfile("FF4Damushian", 3, "Music")); list2.Add(new SoundMetaDataProfile("FF5Dungeon", 4, "Music")); list2.Add(new SoundMetaDataProfile("music102", 5, "Music")); SoundMetaData.SoundEffectMetaData = SoundMetaData.ComposeMetaDataJsonString(list); SoundMetaData.MusicMetaData = SoundMetaData.ComposeMetaDataJsonString(list2); }
private List <SoundProfile> GetPlaylist(Int32 playListIndex) { List <Int32> list = null; if (this.activeType == SoundProfileType.Music) { list = this.allMusicIndex; } else if (this.activeType == SoundProfileType.SoundEffect) { list = this.allSoundEffectIndex; } else if (this.activeType == SoundProfileType.Song) { list = this.allSongIndex; } else if (this.activeType == SoundProfileType.Sfx) { SoundLib.LogWarning("GetPlaylist does not support SoundProfileType.Sfx"); } else if (this.activeType == SoundProfileType.MovieAudio) { list = this.allMovieAudioIndex; } if (list == null) { return(null); } if (this.currentPlaylist < 0) { return(null); } if (this.currentPlaylist > list.Count) { return(null); } Int32 num = this.currentPlaylist * 100; List <SoundProfile> list2 = new List <SoundProfile>(); Int32 num2 = num; while (num2 < num + 100 && num2 < list.Count) { list2.Add(SoundMetaData.GetSoundProfile(list[num2], this.activeType)); num2++; } return(list2); }
public static void LazyLoadSoundResources() { try { if (!SoundLib.hasLoadedSoundResources) { SoundMetaData.LoadMetaData(); FF9SndMetaData.LoadBattleEncountBgmMetaData(); SoundLib.LoadAllResidentSfxSoundData(); SoundLib.hasLoadedSoundResources = true; } } catch (Exception message) { SoundLib.LogError(message); } }
protected void PlaySoundEffect(Int32 soundIndex, Single soundVolume = 1f, Single panning = 0f, Single pitch = 1f, SoundProfileType type = SoundProfileType.SoundEffect) { SoundProfile soundProfile = this.gameSoundDatabase.Read(soundIndex); if (soundProfile == null) { soundProfile = this.sceneSoundDatabase.Read(soundIndex); } if (soundProfile == null) { soundProfile = this.onTheFlySoundDatabase.Read(soundIndex); } if (soundProfile != null) { soundProfile.SoundVolume = soundVolume * this.playerVolume; soundProfile.Panning = panning; soundProfile.Pitch = pitch; this.activeSoundEffect = soundProfile; this.PlaySoundEffect(soundProfile); } else { SoundLib.Log(String.Empty + soundIndex + " is not exist"); soundProfile = SoundMetaData.GetSoundProfile(soundIndex, type); soundProfile.SoundVolume = soundVolume * this.playerVolume; soundProfile.Panning = panning; soundProfile.Pitch = pitch; if (soundProfile == null) { SoundLib.LogError("soundIndex: " + soundIndex + " is not exist"); return; } this.activeSoundEffect = soundProfile; if (this.onTheFlySoundDatabase.ReadAll().Count >= 20) { SoundLib.Log("Unload on the fly sound database."); base.UnloadResource(this.onTheFlySoundDatabase); } base.LoadResource(soundProfile, this.onTheFlySoundDatabase, new SoundPlayer.LoadResourceCallback(this.LoadOnTheFlySoundResourceCallback)); } }
public async Task <SoundMetaData> GetMetaData(string filePath) { var engine = await EngineProvider.GetSoundEngine(); var soundSource = engine.AddSoundSourceFromFile(filePath); if (soundSource != null) { var metaData = new SoundMetaData() { Length = soundSource.PlayLength }; //cleanup engine.RemoveSoundSource(soundSource.Name); return(metaData); } //could not parse or something return(null); }
public static Int32 GetMovieSoundIndex(String movieName) { String soundName = String.Empty; if (String.Equals(movieName, "FMV000")) { soundName = "Sounds01/BGM_/music033"; } else if (String.Equals(movieName, "FMV059")) { soundName = "Sounds02/Movie_/FMV059A"; } else if (String.Equals(movieName, "FMV060")) { String currentLanguage = FF9StateSystem.Settings.CurrentLanguage; String str = "FMV059C"; if (currentLanguage == "Japanese") { str = "FMV059B"; } soundName = "Sounds02/Movie_/" + str; } else if (String.Equals(movieName, "mbg102")) { soundName = "Sounds02/song_/song0504_0"; } else if (String.Equals(movieName, "mbg103")) { soundName = "Sounds02/song_/song0505_0"; } else if (String.Equals(movieName, "mbg105")) { soundName = "Sounds02/song_/song0503_0"; } else if (String.Equals(movieName, "mbg106")) { soundName = "Sounds02/song_/song0507_0"; } else if (String.Equals(movieName, "mbg107")) { soundName = "Sounds02/song_/song0506_0"; } else if (String.Equals(movieName, "mbg108")) { soundName = "Sounds02/song_/song0501_0"; } else if (String.Equals(movieName, "mbg110")) { soundName = "Sounds02/song_/song0502_0"; } else if (String.Equals(movieName, "mbg111")) { soundName = "Sounds02/song_/song0509_0"; } else if (String.Equals(movieName, "mbg112")) { soundName = "Sounds02/song_/song0510_0"; } else if (String.Equals(movieName, "mbg113")) { soundName = "Sounds02/song_/song0508_0"; } else if (String.Equals(movieName, "mbg115")) { soundName = "Sounds02/song_/song0511_0"; } else if (String.Equals(movieName, "mbg116")) { soundName = "Sounds02/song_/song1040_0"; } else if (String.Equals(movieName, "mbg117")) { soundName = "Sounds02/song_/song0512_0"; } else if (String.Equals(movieName, "mbg118")) { soundName = "Sounds02/song_/song0513_0"; } else { soundName = "Sounds02/Movie_/" + movieName; } return(SoundMetaData.GetSoundIndex(soundName, SoundProfileType.MovieAudio)); }
protected void PreLoadSound(SoundMetaData metaData) { _preLoad.Add(metaData); }
/// <summary> /// Compares two files for equality by comparing all their fields and properties.<br/> /// Performs only a shallow comparison for <see cref="SoundboxDirectory.Children"/> and <see cref="SoundboxNode.ParentDirectory"/> /// unless otherwise specified via <paramref name="deepCompareParents"/> and <paramref name="deepCompareChildren"/>. /// </summary> /// <param name="file1"></param> /// <param name="file2"></param> /// <param name="compareDistinct"> /// True: Returns false if the given files are the same object (<see cref="Object.ReferenceEquals(object, object)"/>). /// </param> /// <returns></returns> protected bool Compare(SoundboxNode file1, SoundboxNode file2, bool compareDistinct = false, bool deepCompareParents = false, bool deepCompareChildren = false) { if (Object.ReferenceEquals(file1, file2)) { if (compareDistinct && file1 != null) { return(false); } return(true); } if (file1 != file2) { return(false); } if ((file1 is SoundboxDirectory) != (file2 is SoundboxDirectory)) { return(false); } if ((file1 is Sound) != (file2 is Sound)) { return(false); } if (file1.Name != file2.Name) { return(false); } if (file1.IconUrl != file2.IconUrl) { return(false); } if (file1.ParentDirectory != file2.ParentDirectory) { return(false); } if (deepCompareParents && !Compare(file1.ParentDirectory, file2.ParentDirectory, compareDistinct: compareDistinct, deepCompareParents: true)) { return(false); } if (!file1.Tags.CollectionsEqual(file2.Tags)) { return(false); } if ((file1 is SoundboxFile nodeFile1) && (file2 is SoundboxFile nodeFile2)) { if (nodeFile1.FileName != nodeFile2.FileName) { return(false); } if (nodeFile1.AbsoluteFileName != nodeFile2.AbsoluteFileName) { return(false); } } if ((file1 is Sound sound1) && (file2 is Sound sound2)) { SoundMetaData meta1 = sound1.MetaData; SoundMetaData meta2 = sound2.MetaData; if (meta1.Length != meta2.Length) { return(false); } } if ((file1 is SoundboxDirectory dir1) && (file2 is SoundboxDirectory dir2)) { if (!dir2.Children.CollectionsEqual(dir2.Children)) { return(false); } if (deepCompareChildren) { var children2 = new List <SoundboxNode>(dir2.Children); foreach (var child1 in dir1.Children) { if (children2.Find(child2 => Compare(child1, child2, compareDistinct: compareDistinct, deepCompareParents: true, deepCompareChildren: true)) == null) { return(false); } } } } return(true); }