社区问答

欢迎来到 Audiokinetic 社区问答论坛。在此,Wwise 和 Strata 用户可互帮互助。如需我们团队直接提供协助,请前往技术支持申请单页面。若要报告问题,请在 Audiokinetic Launcher 中选择“报告错误”选项(注意,问答论坛并不会接收错误报告)。我们内部设有专门的错误报告系统,会有专人查看报告并设法解决问题。

要想尽快得到满意的解答,请在提问时注意以下几点:

  • 描述尽量具体:比如,想达到什么样的目的,或者具体哪里有问题。
  • 包含关键细节:比如,Wwise 和游戏引擎版本以及所用操作系统等等。
  • 阐明所做努力:阐明自己为了排除故障都采取了哪些措施。
  • 聚焦问题本身:聚焦于问题本身的相关技术细节,以便别人可以快速找到解决方案。

0 投票

Hello,

I am trying to access both the custom cues and AK_MusicSyncBeat from my playing segment. My goal is to be able to react to each grid tick as well as custom cues from within my code. I managed get the custom cue strings into Unity but I cannot figure out how to use the beat information. I tried my best to go through the Music Callback Demo Integration and SDK documentation but I am still relatively new to programming. Maybe someone can point me in the right direction? 

Here is my code:

    // extract the text from User Cues 
    public void PostMusicEvent (string noteOn) 
    {
        AkSoundEngine.PostEvent(noteOn, gameObject, (uint)AkCallbackType.AK_MusicSyncUserCue | (uint)AkCallbackType.AK_MusicSyncBeat, MusicCallBack, this);
    }

    private void MusicCallBack (object in_cookie, AkCallbackType in_type,  object in_callbackInfo)
    {
        AkCallbackManager.AkMusicSyncCallbackInfo musicInfo = in_callbackInfo as AkCallbackManager.AkMusicSyncCallbackInfo;

        callbackText = musicInfo.pszUserCueName;
    
        //gridTick = AkCallbackType.AK_MusicSyncBeat;
    }

分类:General Discussion | 用户: Brad F. (180 分)

1个回答

+1 投票
 
已采纳

EDIT: Figured it out. Turns out you use an if statement for each type of callback you can then implement functionality in them.
 

  // Start is called before the first frame update
    void Start()
    {
        uint CallbackType = (uint)(AkCallbackType.AK_MusicSyncBeat | AkCallbackType.AK_MusicPlaylistSelect);
       
       MusicEvent.Post(gameObject, (uint)CallbackType, CallbackFunciton);

    }


    void CallbackFunciton(object in_cookie, AkCallbackType in_type, object in_info)
    {
        //this if statment is called every time MusicSyncBeat is triggered via wwise and then the items inside are compleated
        if(in_type == AkCallbackType.AK_MusicSyncBeat)
       {
            AkMusicSyncCallbackInfo info = (AkMusicSyncCallbackInfo)in_info;

            playingBPM = 60 / info.segmentInfo_fBeatDuration;

            print("BPM: " + playingBPM);
        }

        //this if statment is called every time MusicPlaylistSelect is triggered via wwise and then the items inside are compleated
        if (in_type == AkCallbackType.AK_MusicPlaylistSelect)
        {
            AkMusicPlaylistCallbackInfo playlistInfo = (AkMusicPlaylistCallbackInfo)in_info;


            activePlaylistItem = playlistInfo.playingID;
            currentSelection = playlistInfo.uPlaylistSelection;
            print("Playlist Item: " + activePlaylistItem + " , Playlist Selection: " + currentSelection);

        }

    }
 



To those that find this, I am still working how to use the different aspects, but the following will allow you use multiple callbacks at once. Found it in the WAG code, special thanks to the programmer I am working with for a game jam! I'll try to remember to update this once I get the latter part working. Note this is in C# in Unity.

    void Start()
    {
        uint CallbackType = (uint)(AkCallbackType.AK_MusicSyncAll | AkCallbackType.AK_MusicPlaylistSelect);
       
        MusicEvent.Post(gameObject, (uint)CallbackType, CallbackFunciton);
       
    }


    void CallbackFunciton(object in_cookie, AkCallbackType in_type, object in_info)
    {
        AkMusicSyncCallbackInfo info = (AkMusicSyncCallbackInfo)in_info;

        playingBPM = 60 / info.segmentInfo_fBeatDuration;
        print(playingBPM);

    }

用户: Curtis (500 分)
采纳于 用户:Mads Maretty S. (Audiokinetic)
Thank you for this answer as I've been looking for a way to do this. This even works in the Wwise Godot implementation.
...