menu
 

La section Questions et réponses de la communauté Audiokinetic est un forum où les utilisateurs de Wwise et de Strata peuvent poser des questions et répondre à celles des autres membres de la communauté. Si vous souhaitez obtenir une réponse de la part de l'équipe de soutien technique d'Audiokinetic, veillez à utiliser le formulaire de Tickets de Soutien.

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

dans General Discussion par Brad F. (180 points)

1 Réponse

+1 vote
 
Meilleure réponse

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

    }

par Curtis (500 points)
sélectionné par 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.
...