public Boolean IsSoundEffectPlaying(Int32 soundIndex) { SoundDatabase[] array = new SoundDatabase[] { this.gameSoundDatabase, this.sceneSoundDatabase, this.onTheFlySoundDatabase }; SoundDatabase[] array2 = array; for (Int32 i = 0; i < (Int32)array2.Length; i++) { SoundDatabase soundDatabase = array2[i]; foreach (KeyValuePair <Int32, SoundProfile> keyValuePair in soundDatabase.ReadAll()) { SoundProfile value = keyValuePair.Value; if (value.SoundIndex == soundIndex) { Int32 soundID = value.SoundID; if (this.playedEffectSet.Contains(soundID)) { return(true); } SoundLib.Log("soundID: " + soundID + " not found"); } } } SoundLib.Log("soundIndex: " + soundIndex + " not found in DB"); return(false); }
public void SetVolume(Single volume) { SoundDatabase[] array = new SoundDatabase[] { this.gameSoundDatabase, this.sceneSoundDatabase, this.onTheFlySoundDatabase }; SoundDatabase[] array2 = array; for (Int32 i = 0; i < (Int32)array2.Length; i++) { SoundDatabase soundDatabase = array2[i]; foreach (KeyValuePair <Int32, SoundProfile> keyValuePair in soundDatabase.ReadAll()) { SoundProfile value = keyValuePair.Value; Int32 soundID = value.SoundID; if (this.playedEffectSet.Contains(soundID)) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundID, volume, 0); SoundLib.Log("Set volume to soundID: " + soundID + " finished"); } else { SoundLib.Log("soundID: " + soundID + " not found"); } } } this.playerVolume = volume; }
public void StopSoundEffect(Int32 soundIndex) { SoundDatabase[] array = new SoundDatabase[] { this.gameSoundDatabase, this.sceneSoundDatabase, this.onTheFlySoundDatabase }; SoundDatabase[] array2 = array; for (Int32 i = 0; i < (Int32)array2.Length; i++) { SoundDatabase soundDatabase = array2[i]; foreach (KeyValuePair <Int32, SoundProfile> keyValuePair in soundDatabase.ReadAll()) { SoundProfile value = keyValuePair.Value; if (value.SoundIndex == soundIndex) { Int32 soundID = value.SoundID; if (this.playedEffectSet.Contains(soundID)) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(soundID, 0); this.playedEffectSet.Remove(soundID); SoundLib.Log("Force stop success"); } else { SoundLib.Log("soundID: " + soundID + " not found"); } } } } }
private void RegisterBankAsCallback(SoundProfile profile, SoundDatabase soundDatabase) { if (profile != null && soundDatabase != null) { soundDatabase.Create(profile); this.resourceLoadingCounter--; if (this.resourceLoadingCounter == 0) { this.activeCallback(soundDatabase, false); } else { SoundLib.Log("resourceLoadingCounter > 0! resourceLoadingCounter: " + this.resourceLoadingCounter); this.activeCallback(soundDatabase, true); } } else { SoundLib.Log("either profile OR soundDatabase is null"); this.resourceLoadingCounter--; if (this.resourceLoadingCounter == 0) { this.activeCallback(soundDatabase, true); } else { SoundLib.Log("resourceLoadingCounter > 0! resourceLoadingCounter: " + this.resourceLoadingCounter); this.activeCallback(soundDatabase, true); } } }
public override void Load(SoundProfile profile, ISoundLoader.ResultCallback callback, SoundDatabase soundDatabase) { String text = AssetManagerUtil.GetStreamingAssetsPath() + "/Sounds/" + profile.ResourceID; SoundLib.Log("Load: " + text); FileInfo fileInfo = new FileInfo(text); Byte[] array = null; if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.IPhonePlayer) { array = File.ReadAllBytes(text); } else if (Application.platform == RuntimePlatform.Android) { } if (array != null) { IntPtr intPtr = Marshal.AllocHGlobal((Int32)fileInfo.Length); Marshal.Copy(array, 0, intPtr, (Int32)fileInfo.Length); Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(intPtr); profile.AkbBin = intPtr; profile.BankID = bankID; } else { SoundLib.Log("akbBytes is null"); } callback(profile, soundDatabase); }
public static void StopMovieMusic(String movieName, Boolean isForceStop = false) { if (SoundLib.instance == (UnityEngine.Object)null) { return; } if (!isForceStop) { if (String.Equals(movieName, "FMV000")) { SoundLib.Log("Don't stop sound for " + movieName + " if it is NOT forced to stop."); } else { SoundLib.movieAudioPlayer.StopMusic(); } } else if (String.Equals(movieName, "FMV000")) { Int32 ticks = 90; Int32 fadeOut = AllSoundDispatchPlayer.ConvertTickToMillisec(ticks); SoundLib.movieAudioPlayer.StopMusic(fadeOut); } else { SoundLib.movieAudioPlayer.StopMusic(); } }
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 static SoundProfile GetSoundProfile(Int32 soundIndex, SoundProfileType type) { String text = String.Empty; switch (type) { case SoundProfileType.Music: text = SoundMetaData.MusicIndex[soundIndex]; break; case SoundProfileType.SoundEffect: text = SoundMetaData.SoundEffectIndex[soundIndex]; break; case SoundProfileType.MovieAudio: text = SoundMetaData.MovieAudioIndex[soundIndex]; break; case SoundProfileType.Song: text = SoundMetaData.SongIndex[soundIndex]; break; case SoundProfileType.Sfx: SoundLib.Log("GetSoundProfile does not support type SoundProfileType.Sfx"); return((SoundProfile)null); } return(new SoundProfile { Code = soundIndex.ToString(), Name = text, SoundIndex = soundIndex, ResourceID = text, SoundProfileType = type }); }
private void OnDestroy() { SoundLib.Log("Unload all sound resources"); SoundLib.UnloadAllSoundEffect(); SoundLib.UnloadMusic(); SoundLib.UnloadAllResidentSfxSoundData(); }
public void LoadSfxSoundGroup(Int32 specialEffectID) { DateTime now = DateTime.Now; SoundLib.LoadSfxSoundData(specialEffectID); DateTime now2 = DateTime.Now; SoundLib.Log("Sound effect Loading time: " + (now2 - now).Milliseconds); }
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); } }
private void FinalizePlugin() { if (!this.m_isInitialized) { return; } SoundLib.Log("FinalizePlugin()"); ISdLibAPIProxy.Instance.SdSoundSystem_Release(); this.m_isInitialized = false; }
public void CreateSound(SoundProfile soundProfile) { Int32 num = ISdLibAPIProxy.Instance.SdSoundSystem_CreateSound(soundProfile.BankID); if (num == 0) { SoundLib.Log("CreateSound failure"); return; } soundProfile.SoundID = num; SoundLib.Log("CreateSound Success"); }
private void LoadSoundResourceCallback(SoundDatabase soundDatabase, Boolean isError) { if (!isError) { SoundLib.Log("LoadSoundResource is success"); } else { SoundLib.LogError("LoadSoundResource has Error"); this.soundDatabase.Delete(this.loadingSoundProfile); } }
private void LoadOnTheFlySoundResourceCallback(SoundDatabase soundDatabase, Boolean isError) { if (!isError) { if (this.onTheFlyLoadedSoundProfile != null) { this.PlayMusic(this.onTheFlyLoadedSoundProfile, this.onTheFlyLoadedFadeIn); } } else { SoundLib.Log("LoadOnTheFlySoundResourceCallback is Error"); } }
public void UnregisterBank(SoundProfile soundProfile) { SoundLib.Log("UnregisterBank: " + soundProfile.Name); if (soundProfile.BankID != 0) { ISdLibAPIProxy.Instance.SdSoundSystem_RemoveData(soundProfile.BankID); soundProfile.BankID = 0; } if (IntPtr.Zero != soundProfile.AkbBin) { Marshal.FreeHGlobal(soundProfile.AkbBin); soundProfile.AkbBin = IntPtr.Zero; } }
private void LoadOnTheFlySoundResourceCallback(SoundDatabase soundDatabase, Boolean isError) { if (!isError) { if (this.activeSoundEffect != null) { this.PlaySoundEffect(this.activeSoundEffect); } } else { SoundLib.Log("LoadOnTheFlySoundResourceCallback is Error"); } }
public static Int32 GetSoundIndex(String soundName, SoundProfileType type) { if (type != SoundProfileType.MovieAudio) { SoundLib.Log("No implementation"); return(-1); } if (SoundMetaData.MovieAudioStringIndex.ContainsKey(soundName)) { return(SoundMetaData.MovieAudioStringIndex[soundName]); } SoundLib.Log("Movie audio, Name: " + soundName + " not found!"); return(-1); }
public void StartSound(SoundProfile soundProfile, Single playerVolume = 1f) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(soundProfile.SoundID) == 0) { SoundLib.Log("failed to play sound"); soundProfile.SoundID = 0; return; } ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, soundProfile.SoundVolume * playerVolume, 0); SoundLib.Log("Panning: " + soundProfile.Panning); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPanning(soundProfile.SoundID, soundProfile.Panning, 0); ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetPitch(soundProfile.SoundID, soundProfile.Pitch, 0); SoundLib.Log("StartSound Success"); }
public Boolean InitializePlugin() { SoundLib.Log("InitializePlugin()"); if (this.m_isInitialized) { return(true); } Int32 num = ISdLibAPIProxy.Instance.SdSoundSystem_Create(String.Empty); if (num < 0) { return(false); } this.m_isInitialized = true; return(true); }
public void SeekActiveSound(Int32 offsetTimeMSec) { if (this.activeSoundProfile == null) { SoundLib.Log("(activeSoundProfile == null"); return; } ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(this.activeSoundProfile.SoundID, 0); this.activeSoundProfile.SoundID = ISdLibAPIProxy.Instance.SdSoundSystem_CreateSound(this.activeSoundProfile.BankID); Int32 num = ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(this.activeSoundProfile.SoundID, offsetTimeMSec); if (num != 0) { SoundLib.LogError("startSoundErrno errors with value: " + num); } }
private void StartSoundCrossfadeIn(SoundProfile soundProfile) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Start(soundProfile.SoundID, 0); if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(soundProfile.SoundID) == 0) { SoundLib.Log("failed to play sound"); soundProfile.SoundID = 0; return; } ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, 0f, 0); soundProfile.SoundVolume = this.playerVolume * this.optionVolume; ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetVolume(soundProfile.SoundID, this.playerVolume * this.optionVolume, (Int32)(this.fadeInDuration * 1000f)); this.SetMusicPanning(this.playerPanning, soundProfile); this.SetMusicPitch(this.playerPitch, soundProfile); this.upcomingSoundProfile = soundProfile; }
public void NextLoopRegion(Int32 soundIndex) { SoundProfile soundProfile = this.soundDatabase.Read(soundIndex); if (soundProfile == null) { soundProfile = this.onTheFlySoundDatabase.Read(soundIndex); } if (soundProfile != null) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_SetNextLoopRegion(soundProfile.SoundID); } else { SoundLib.Log("NextLoopRegion(), soundProfile is null!"); } }
public override void Update() { foreach (Int32 num in this.playedEffectSet) { if (ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_IsExist(num) == 0) { ISdLibAPIProxy.Instance.SdSoundSystem_SoundCtrl_Stop(num, 0); this.playedEffectRemoveList.Add(num); SoundLib.Log("Sound End, Stop success"); } } foreach (Int32 item in this.playedEffectRemoveList) { if (!this.playedEffectSet.Remove(item)) { SoundLib.Log("Remove playedEffectSet failure!"); } } this.playedEffectRemoveList.Clear(); }
private Boolean InitializePlugin() { if (this.m_isInitialized) { return(true); } SoundLib.Log("InitializePlugin()"); Int32 num = ISdLibAPIProxy.Instance.SdSoundSystem_Create(String.Empty); if (num < 0) { return(false); } this.m_isInitialized = true; GameObject gameObject = new GameObject("SoundLibWndProc"); SoundLibWndProc soundLibWndProc = gameObject.AddComponent <SoundLibWndProc>(); gameObject.transform.parent = base.transform; return(true); }
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 override void Load(SoundProfile profile, ISoundLoader.ResultCallback callback, SoundDatabase soundDatabase) { String text = "Sounds/" + profile.ResourceID + ".akb"; TextAsset textAsset = AssetManager.Load <TextAsset>(text, false); SoundLib.Log("Load: " + text); if ((UnityEngine.Object)null == textAsset) { SoundLib.LogError("File not found AT path: " + text); callback((SoundProfile)null, (SoundDatabase)null); return; } Byte[] bytes = textAsset.bytes; IntPtr intPtr = Marshal.AllocHGlobal((Int32)textAsset.bytes.Length); Marshal.Copy(bytes, 0, intPtr, (Int32)textAsset.bytes.Length); Int32 bankID = ISdLibAPIProxy.Instance.SdSoundSystem_AddData(intPtr); profile.AkbBin = intPtr; profile.BankID = bankID; callback(profile, soundDatabase); }
public Int32 Transition(SoundProfile soundProfile, SdLibSoundProfileStateGraph.TransitionDelegate transition) { if (!this.transitionDictionary.ContainsKey(transition)) { SoundLib.Log("Transition not found"); return(1); } Dictionary <SoundProfileState, SoundProfileState> dictionary = this.transitionDictionary[transition]; if (soundProfile == null) { SoundLib.Log("Sound profile is null"); return(1); } if (!dictionary.ContainsKey(soundProfile.SoundProfileState)) { SoundLib.Log("State: " + soundProfile.SoundProfileState + " does not exist for requested transition."); return(1); } transition(soundProfile); soundProfile.SoundProfileState = dictionary[soundProfile.SoundProfileState]; return(0); }
public static void UnloadMovieResources() { SoundLib.Log("No implementation"); }
public static void LoadMovieResources(String basePath, String[] movies) { SoundLib.Log("No implementation"); }