Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

0 votes

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;
    }

in General Discussion by Brad F. (180 points)

1 Answer

+1 vote
 
Best answer

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);

    }

by Curtis (500 points)
selected by 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.
...