private void CallbackHandler(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { if (in_type == AkCallbackType.AK_EndOfEvent) { RemoveAkEvent(in_cookie as AkEvent); } }
void Callback(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { switch (in_type) { case AkCallbackType.AK_EndOfEvent: if (in_cookie != null) { AudioCtrl.EventCallback cb = (AudioCtrl.EventCallback)in_cookie; cb(); } break; case AkCallbackType.AK_Marker: AkMarkerCallbackInfo info = in_info as AkMarkerCallbackInfo; Debug.Log(info.strLabel); break; case AkCallbackType.AK_MusicSyncBeat: //互动音乐节拍点事件 break; default: //AkSoundEngine.LogError("Callback Type not march."); break; } }
// Token: 0x06002722 RID: 10018 RVA: 0x000AA103 File Offset: 0x000A8303 private static void Callback(object cookie, AkCallbackType in_type, AkCallbackInfo in_info) { if (in_type == AkCallbackType.AK_EndOfEvent) { PointSoundManager.FreeEmitter((AkGameObj)cookie); } }
private void MusicEventCallback(object cookie, AkCallbackType in_type, AkCallbackInfo in_info) { TTGL_SurvivorPlugin.instance.Logger.LogMessage("MusicEventCallback Called : " + in_type.ToString()); if (in_type == AkCallbackType.AK_EndOfEvent) { playedMusic = false; } }
private void Callback(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { EventCallbackMsg.type = in_type; EventCallbackMsg.info = in_info; for (var i = 0; i < Callbacks.Count; ++i) { Callbacks[i].CallFunction(EventCallbackMsg); } }
public void ec(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { if (in_type == AkCallbackType.AK_Marker) { if (in_info != null) { Debug.Log(saySomething[Random.Range(0, saySomething.Length)]); } } }
private void EventCallback(object _cookie, AkCallbackType _type, AkCallbackInfo _info) { if (_type == AkCallbackType.AK_EndOfEvent) { var markerInfo = _info as AkMarkerCallbackInfo; if (markerInfo != null) { isPlaying = false; } } }
private static void EventCallback(object cookie, AkCallbackType type, AkCallbackInfo callbackInfo) { if (type == AkCallbackType.AK_EndOfEvent) { var info = callbackInfo as AkEventCallbackInfo; if (info != null) { audioSamplesDelegates.Remove(info.playingID); audioFormatDelegates.Remove(info.playingID); } } }
private void CallbackHandler(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { if (in_type == AkCallbackType.AK_EndOfEvent) { eventIsPlaying = fadeinTriggered = fadeoutTriggered = false; } else if (in_type == AkCallbackType.AK_Duration) { var estimatedDuration = (in_info as AkDurationCallbackInfo).fEstimatedDuration; currentDuration = estimatedDuration * currentDurationProportion / 1000f; } }
private void Callback(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { for (var i = 0; i < m_callbackData.callbackFunc.Count; i++) { if (((int)in_type & m_callbackData.callbackFlags[i]) != 0 && m_callbackData.callbackGameObj[i] != null) { var callbackInfo = new AkEventCallbackMsg { type = in_type, sender = gameObject, info = in_info }; m_callbackData.callbackGameObj[i].SendMessage(m_callbackData.callbackFunc[i], callbackInfo); } } }
private void CallbackHandler(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { if (in_type == AkCallbackType.AK_EndOfEvent) { RemoveAkEvent(in_cookie as AkEvent); var refreshGUI = RefreshGUI; if (refreshGUI != null) { refreshGUI.Invoke(); } } }
public static void OnEventCallback(object cookie, AkCallbackType type, AkCallbackInfo callbackInfo) { if (type == AkCallbackType.AK_EndOfEvent) { audioObjectGenerator.FinishAudio(cookie as AkGameObj); // var info = callbackInfo as AkEventCallbackInfo; // if (info != null) // { //// audioSamplesDelegates.Remove(info.playingID); //// audioFormatDelegates.Remove(info.playingID); // } } }
private void BgmEventCallback(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { EffectAudioSourceItem item = in_cookie as EffectAudioSourceItem; if (in_type == AkCallbackType.AK_EndOfEvent) { item.playingId = string.Empty; if (this == WwiseSoundMan.Instance.BGEffectAudioItem) { WwiseSoundMan.Instance.BGEffectAudioItem = null; } } }
private void EventEndCallback(object _notUsed, AkCallbackType _callbackType, AkCallbackInfo _notUsedEither) { if (_notUsed != null) { // Check for proper callback type if (_callbackType == AkCallbackType.AK_EndOfEvent) { // If this is the last event to finish that's been called on this gameObject, destroy it m_playingEvents -= 1; if (m_playingEvents == 0) { if (m_flagForDeath) { OnAllEventsFinished(); } } } } }
/// <summary> /// 2D音效播放完毕回调 /// </summary> /// <param name="cookie"> 参数</param> /// <param name="type">类型</param> /// <param name="callbackInfo"></param> private void EventCallback2D(object cookie, AkCallbackType type, AkCallbackInfo callbackInfo) { if (type == AkCallbackType.AK_EndOfEvent) { AkEventCallbackInfo info = callbackInfo as AkEventCallbackInfo; if (info != null) { // Debug.LogWarning("--------> 2d 回收! playingID = " + info.playingID ); // Action<uint> endCallback = (Action<uint>)cookie; // endCallback?.Invoke(info.playingID); TAkGameObjEventMonitor eventMonitor = SoundSource2DObj.GetComponent<TAkGameObjEventMonitor>(); if (eventMonitor != null) eventMonitor.DeleOneEvent(info.playingID); } } }
void AkEventCallback(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { switch (in_type) { case AkCallbackType.AK_MusicSyncEntry: AkMusicSyncCallbackInfo musicSyncCallbackInfo = in_info as AkMusicSyncCallbackInfo; CalcMeter(musicSyncCallbackInfo.segmentInfo_fBeatDuration, musicSyncCallbackInfo.segmentInfo_fBarDuration, musicSyncCallbackInfo.segmentInfo_iActiveDuration); break; case AkCallbackType.AK_EndOfEvent: AkEventCallbackInfo endInfo = in_info as AkEventCallbackInfo; if (endInfo.playingID == playingId_) { endOfEvent_ = true; } break; } }
private void EventCallback(object cookie, AkCallbackType type, AkCallbackInfo info) { switch (type) { case AkCallbackType.AK_EndOfEvent: end.Invoke(); break; case AkCallbackType.AK_Marker: marker.Invoke(); break; case AkCallbackType.AK_MusicSyncBeat: beat.Invoke(); break; case AkCallbackType.AK_MusicSyncBar: bar.Invoke(); break; } }
/// <summary> /// 3D音效播放完毕回调 /// </summary> /// <param name="cookie"> 参数</param> /// <param name="type">类型</param> /// <param name="callbackInfo"></param> private void EventCallback3D(object cookie, AkCallbackType type, AkCallbackInfo callbackInfo) { if (type == AkCallbackType.AK_EndOfEvent) { AkEventCallbackInfo info = callbackInfo as AkEventCallbackInfo; if (info != null) { // Debug.LogError("-------->event 结束!gameObjID = " + info.gameObjID); SoundSource3DCallBackData data = (SoundSource3DCallBackData)cookie; if (data != null && data.gameObject != null) { if (!string.IsNullOrEmpty(data.bankName)) { DelePlayIdCoutToBankDic(data.bankName); } if (data.gameObject != null) { TAkGameObjEventMonitor eventMonitor = data.gameObject.GetComponent<TAkGameObjEventMonitor>(); if (eventMonitor != null) { eventMonitor.DeleOneEvent(info.playingID); if (eventMonitor.GetCurrentCout() == 0) { if (SoundSource3DPublicObj.ContainsKey(data.publicObjsEventKey)) SoundSource3DPublicObj.Remove(data.publicObjsEventKey); // Debug.LogWarning("-------->3D gameObject 回收!gameObjID = " + info.gameObjID); data.gameObject.Recycle(); } } } } } } }
internal static IntPtr getCPtr(AkCallbackInfo obj) { return((obj == null) ? IntPtr.Zero : obj.swigCPtr); }
/// <summary> /// Return poolable to the pool when the event is finished /// </summary> private void OnCallback(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { AkSoundEngine.UnregisterGameObj(gameObject); pooler.ReturnToPool(this); }
//the music callback gets fed some information from the wwise engine void MusicCallbackFunction(object in_cookie, AkCallbackType in_type, AkCallbackInfo in_info) { //we only want music-specific information, so we cast this info accordingly AkMusicSyncCallbackInfo _musicInfo; AkMIDIEventCallbackInfo _midiInfo; //check if it's music callback (beat, marker, bar, grid etc) if (in_info is AkMusicSyncCallbackInfo) { //Debug.Log("music callback"); _musicInfo = (AkMusicSyncCallbackInfo)in_info; //we're going to use this switchboard to fire off different events depending on wwise sends switch (_musicInfo.musicSyncType) { case AkCallbackType.AK_MusicSyncUserCue: CustomCues(_musicInfo.userCueName, _musicInfo); break; case AkCallbackType.AK_MusicSyncBeat: OnEveryBeat.Invoke(); break; case AkCallbackType.AK_MusicSyncBar: //I want to make sure that the secondsPerBeat is defined on our first measure. secondsPerBeat = _musicInfo.segmentInfo_fBeatDuration; //Debug.Log("Seconds Per Beat: " + secondsPerBeat); OnEveryBar.Invoke(); break; case AkCallbackType.AK_MusicSyncGrid: //the grid is defined in Wwise - usually on your playlist. It can be as small as a 32nd note OnEveryGrid.Invoke(); break; default: break; } } //Using MIDI Beatmaps! //here are a few examples of how you might use MIDI files to trigger cues //we might not get to these during class if (in_info is AkMIDIEventCallbackInfo) { Debug.Log("midi callback"); _midiInfo = (AkMIDIEventCallbackInfo)in_info; //pay attention to this debug log to get the byte number of your midi notes Debug.Log("MIDI note is: " + _midiInfo.byOnOffNote); //note on cue if (_midiInfo.byType == AkMIDIEventTypes.NOTE_ON) { switch (_midiInfo.byOnOffNote) { case sustainCNoteNumber: //do stuff with sustain note on? Debug.Log("sustain C On"); OnMIDIC4.Invoke(); //note - this doesn't take any cue offest into account - you need to do that for evaluating inputs! //ideally, you'll figure out your offeset when you instantiate your cue, then evaluate it in a similar way to the other cues (except use OnKey or OnButton instead of OnButtonDown) cIsSustaining = true; break; case sustainANoteNumber: Debug.Log("sustain A On"); OnMIDIA4.Invoke(); break; default: break; } } else if (_midiInfo.byType == AkMIDIEventTypes.NOTE_OFF) { switch (_midiInfo.byOnOffNote) { case sustainCNoteNumber: Debug.Log("sustain C Off"); cIsSustaining = false; break; case sustainANoteNumber: Debug.Log("sustain A Off"); break; default: break; } } } }
/// This function dispatches all the accumulated callbacks from the native sound engine. /// It must be called regularly. By default this is called in AkInitializer.cs. static public int PostCallbacks() { if (m_pNotifMem == IntPtr.Zero) { return(0); } try { int numCallbacks = 0; for (IntPtr pNext = AkCallbackSerializer.Lock(); pNext != IntPtr.Zero; pNext = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_pNext_get(pNext), ++numCallbacks) { IntPtr pPackage = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_pPackage_get(pNext); AkCallbackType eType = (AkCallbackType)AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_eType_get(pNext); IntPtr pData = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_GetData(pNext); switch (eType) { case AkCallbackType.AK_AudioInterruption: #if UNITY_IOS && !UNITY_EDITOR if (ms_interruptCallbackPkg != null && ms_interruptCallbackPkg.m_Callback != null) { using (AkAudioInterruptionCallbackInfo info = new AkAudioInterruptionCallbackInfo(pData, false)) ms_interruptCallbackPkg.m_Callback(info.bEnterInterruption, ms_interruptCallbackPkg.m_Cookie); } #endif // #if UNITY_IOS && ! UNITY_EDITOR break; case AkCallbackType.AK_AudioSourceChange: if (ms_sourceChangeCallbackPkg != null && ms_sourceChangeCallbackPkg.m_Callback != null) { using (AkAudioSourceChangeCallbackInfo info = new AkAudioSourceChangeCallbackInfo(pData, false)) ms_sourceChangeCallbackPkg.m_Callback(info.bOtherAudioPlaying, ms_sourceChangeCallbackPkg.m_Cookie); } break; case AkCallbackType.AK_Monitoring: if (m_MonitoringCB != null) { using (AkMonitoringCallbackInfo info = new AkMonitoringCallbackInfo(pData, false)) m_MonitoringCB(info.errorCode, info.errorLevel, info.playingID, info.gameObjID, info.message); } break; case AkCallbackType.AK_Bank: BankCallbackPackage bankPkg = null; if (!m_mapBankCallbacks.TryGetValue((int)pPackage, out bankPkg)) { Debug.LogError("WwiseUnity: BankCallbackPackage not found for <" + pPackage + ">."); return(numCallbacks); } else { m_mapBankCallbacks.Remove((int)pPackage); if (bankPkg != null && bankPkg.m_Callback != null) { using (AkBankCallbackInfo info = new AkBankCallbackInfo(pData, false)) bankPkg.m_Callback(info.bankID, info.inMemoryBankPtr, info.loadResult, (uint)info.memPoolId, bankPkg.m_Cookie); } } break; default: EventCallbackPackage eventPkg = null; if (!m_mapEventCallbacks.TryGetValue((int)pPackage, out eventPkg)) { Debug.LogError("WwiseUnity: EventCallbackPackage not found for <" + pPackage + ">."); return(numCallbacks); } else { AkCallbackInfo info = null; switch (eType) { case AkCallbackType.AK_EndOfEvent: m_mapEventCallbacks.Remove(eventPkg.GetHashCode()); if (eventPkg.m_bNotifyEndOfEvent) { info = new AkEventCallbackInfo(pData, false); } break; case AkCallbackType.AK_MusicPlayStarted: info = new AkEventCallbackInfo(pData, false); break; case AkCallbackType.AK_EndOfDynamicSequenceItem: info = new AkDynamicSequenceItemCallbackInfo(pData, false); break; case AkCallbackType.AK_MIDIEvent: info = new AkMIDIEventCallbackInfo(pData, false); break; case AkCallbackType.AK_Marker: info = new AkMarkerCallbackInfo(pData, false); break; case AkCallbackType.AK_Duration: info = new AkDurationCallbackInfo(pData, false); break; case AkCallbackType.AK_MusicSyncUserCue: case AkCallbackType.AK_MusicSyncBar: case AkCallbackType.AK_MusicSyncBeat: case AkCallbackType.AK_MusicSyncEntry: case AkCallbackType.AK_MusicSyncExit: case AkCallbackType.AK_MusicSyncGrid: case AkCallbackType.AK_MusicSyncPoint: info = new AkMusicSyncCallbackInfo(pData, false); break; case AkCallbackType.AK_MusicPlaylistSelect: info = new AkMusicPlaylistCallbackInfo(pData, false); break; default: Debug.LogError("WwiseUnity: PostCallbacks aborted due to error: Undefined callback type <" + eType + "> found. Callback object possibly corrupted."); return(numCallbacks); } if (info != null) { eventPkg.m_Callback(eventPkg.m_Cookie, eType, info); } } break; } } return(numCallbacks); } finally { AkCallbackSerializer.Unlock(); } }
internal static global::System.IntPtr getCPtr(AkCallbackInfo obj) { return((obj == null) ? global::System.IntPtr.Zero : obj.swigCPtr); }
/// This function dispatches all the accumulated callbacks from the native sound engine. /// It must be called regularly. By default this is called in AkInitializer.cs. static public int PostCallbacks() { if (m_pNotifMem == IntPtr.Zero) { return(0); } try { int numCallbacks = 0; for (IntPtr pNext = AkCallbackSerializer.Lock(); pNext != IntPtr.Zero; pNext = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_pNext_get(pNext), ++numCallbacks) { IntPtr pPackage = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_pPackage_get(pNext); AkCallbackType eType = (AkCallbackType)AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_eType_get(pNext); IntPtr pData = AkSoundEnginePINVOKE.CSharp_AkSerializedCallbackHeader_GetData(pNext); switch (eType) { case AkCallbackType.AK_AudioInterruption: #if UNITY_IOS && !UNITY_EDITOR if (ms_interruptCallbackPkg != null && ms_interruptCallbackPkg.m_Callback != null) { AkAudioInterruptionCallbackInfo.setCPtr(pData); ms_interruptCallbackPkg.m_Callback(AkAudioInterruptionCallbackInfo.bEnterInterruption, ms_interruptCallbackPkg.m_Cookie); } #endif // #if UNITY_IOS && ! UNITY_EDITOR break; case AkCallbackType.AK_AudioSourceChange: if (ms_sourceChangeCallbackPkg != null && ms_sourceChangeCallbackPkg.m_Callback != null) { AkAudioSourceChangeCallbackInfo.setCPtr(pData); ms_sourceChangeCallbackPkg.m_Callback(AkAudioSourceChangeCallbackInfo.bOtherAudioPlaying, ms_sourceChangeCallbackPkg.m_Cookie); } break; case AkCallbackType.AK_Monitoring: if (m_MonitoringCB != null) { AkMonitoringCallbackInfo.setCPtr(pData); m_MonitoringCB(AkMonitoringCallbackInfo.errorCode, AkMonitoringCallbackInfo.errorLevel, AkMonitoringCallbackInfo.playingID, AkMonitoringCallbackInfo.gameObjID, AkMonitoringCallbackInfo.message); } #if UNITY_EDITOR else if (AkSoundEngineController.Instance.engineLogging) { AkMonitoringCallbackInfo.setCPtr(pData); string msg = "Wwise: " + AkMonitoringCallbackInfo.message; if (AkMonitoringCallbackInfo.gameObjID != AkSoundEngine.AK_INVALID_GAME_OBJECT) { var obj = EditorUtility.InstanceIDToObject((int)AkMonitoringCallbackInfo.gameObjID) as GameObject; if (obj != null) { msg += " (GameObject: " + obj.ToString() + ")"; } msg += " (Instance ID: " + AkMonitoringCallbackInfo.gameObjID.ToString() + ")"; } if (AkMonitoringCallbackInfo.errorLevel == AkMonitorErrorLevel.ErrorLevel_Error) { Debug.LogError(msg); } else { Debug.Log(msg); } } #endif break; case AkCallbackType.AK_Bank: BankCallbackPackage bankPkg = null; if (!m_mapBankCallbacks.TryGetValue((int)pPackage, out bankPkg)) { Debug.LogError("WwiseUnity: BankCallbackPackage not found for <" + pPackage + ">."); return(numCallbacks); } else { m_mapBankCallbacks.Remove((int)pPackage); if (bankPkg != null && bankPkg.m_Callback != null) { AkBankCallbackInfo.setCPtr(pData); bankPkg.m_Callback(AkBankCallbackInfo.bankID, AkBankCallbackInfo.inMemoryBankPtr, AkBankCallbackInfo.loadResult, (uint)AkBankCallbackInfo.memPoolId, bankPkg.m_Cookie); } } break; default: EventCallbackPackage eventPkg = null; if (!m_mapEventCallbacks.TryGetValue((int)pPackage, out eventPkg)) { Debug.LogError("WwiseUnity: EventCallbackPackage not found for <" + pPackage + ">."); return(numCallbacks); } else { AkCallbackInfo info = null; switch (eType) { case AkCallbackType.AK_EndOfEvent: m_mapEventCallbacks.Remove(eventPkg.GetHashCode()); if (eventPkg.m_bNotifyEndOfEvent) { AkEventCallbackInfo.setCPtr(pData); info = AkEventCallbackInfo; } break; case AkCallbackType.AK_MusicPlayStarted: AkEventCallbackInfo.setCPtr(pData); info = AkEventCallbackInfo; break; case AkCallbackType.AK_EndOfDynamicSequenceItem: AkDynamicSequenceItemCallbackInfo.setCPtr(pData); info = AkDynamicSequenceItemCallbackInfo; break; case AkCallbackType.AK_MIDIEvent: AkMIDIEventCallbackInfo.setCPtr(pData); info = AkMIDIEventCallbackInfo; break; case AkCallbackType.AK_Marker: AkMarkerCallbackInfo.setCPtr(pData); info = AkMarkerCallbackInfo; break; case AkCallbackType.AK_Duration: AkDurationCallbackInfo.setCPtr(pData); info = AkDurationCallbackInfo; break; case AkCallbackType.AK_MusicSyncUserCue: case AkCallbackType.AK_MusicSyncBar: case AkCallbackType.AK_MusicSyncBeat: case AkCallbackType.AK_MusicSyncEntry: case AkCallbackType.AK_MusicSyncExit: case AkCallbackType.AK_MusicSyncGrid: case AkCallbackType.AK_MusicSyncPoint: AkMusicSyncCallbackInfo.setCPtr(pData); info = AkMusicSyncCallbackInfo; break; case AkCallbackType.AK_MusicPlaylistSelect: AkMusicPlaylistCallbackInfo.setCPtr(pData); info = AkMusicPlaylistCallbackInfo; break; default: Debug.LogError("WwiseUnity: PostCallbacks aborted due to error: Undefined callback type <" + eType + "> found. Callback object possibly corrupted."); return(numCallbacks); } if (info != null) { eventPkg.m_Callback(eventPkg.m_Cookie, eType, info); } } break; } } return(numCallbacks); } finally { AkCallbackSerializer.Unlock(); } }