社区问答

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

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

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

+2 投票
Hello,

I've been looking at the example of what seems like calling custom MIDI events to Wwise in the SDK (https://www.audiokinetic.com/library/edge/?source=SDK&id=quickstart__sample__integration__midi.html)

And have been trying to translate it into C# that can be called by Unity.

It seems like I can define the "byChan" and "byType" of my AkMIDIPost instance, but when I try to define "NoteOnOff.byNote" and "NoteOnOff.byVelocity", the namespace doesn't recognize these things. Is this not possible in C# Unity Integration?
分类:General Discussion | 用户: Aaron I. (220 分)

1个回答

0 投票

Hi Aaron,

I just ran into this same issue. I think it's a Wwise bug - Wwise is using SWIG to wrap its C++ API for C# in Unity. It seems like this SWIG code was generated in an automated fashion, and didn't take inheritance into account - the AkMidiPost type inherits from their MIDI event type, which has all of the stuff you need. However getters and setters are not implemented, which you can see by looking at either the SoundEngine_wrap.cxx file located in the AkSoundEngine source, or in the generated AkSoundEnginePINVOKE_Windows.cs file generated with your Unity integration (Windows because I'm on Windows, presumably.) 

The fix is to add getters and setters for the MIDI data you need, but I would stay away unless you're familiar with C/C++ (or at least know what unions and structs are.) I think this is something that AK will have to implement in a future update. 

Her'e's how I did byNote and byVelocity - however, because those two are part of a struct that's part of a union, you have to be careful about context (and I'm sure AK wouldn't publish code like this)


SoundEngine_wrap.cxx

[code]

SWIGEXPORT void SWIGSTDCALL CSharp_AkMIDIPost_tNoteOnOff_byNote_set( void * jarg1, byte jarg2 )
{
    AkMIDIPost *arg1 = (AkMIDIPost *) 0;
    AkUInt8 arg2, arg3;
    arg1 = (AkMIDIPost *) jarg1;
    arg2 = (AkUInt8) jarg2;
    if ( arg1 )
    {
        arg1->NoteOnOff.byNote = arg2;
    }
}


SWIGEXPORT unsigned char SWIGSTDCALL CSharp_AkMIDIPost_tNoteOnOff_byNote_get( void * jarg1 )
{
    unsigned char jresult;
    AkMIDIPost *arg1 = (AkMIDIPost *) 0;
    AkUInt8 result;

    arg1 = (AkMIDIPost *) jarg1;
    result = arg1->NoteOnOff.byNote;
    jresult = (unsigned char) result;
    return jresult;
}

SWIGEXPORT void SWIGSTDCALL CSharp_AkMIDIPost_tNoteOnOff_byVelocity_set( void * jarg1, byte jarg2 )
{
    AkMIDIPost *arg1 = (AkMIDIPost *) 0;
    AkUInt8 arg2, arg3;
    arg1 = (AkMIDIPost *) jarg1;
    arg2 = (AkUInt8) jarg2;
    if ( arg1 )
    {
        arg1->NoteOnOff.byVelocity = arg2;
    }
}

SWIGEXPORT unsigned char SWIGSTDCALL CSharp_AkMIDIPost_tNoteOnOff_byVelocity_get( void * jarg1 )
{
    unsigned char jresult;
    AkMIDIPost *arg1 = (AkMIDIPost *) 0;
    AkUInt8 result;

    arg1 = (AkMIDIPost *) jarg1;
    result = arg1->NoteOnOff.byVelocity;
    jresult = (unsigned char) result;
    return jresult;
}

[/code]


AkSoundEnginePINVOKE_Windows.cs

[code]

    [DllImport("AkSoundEngine", EntryPoint = "CSharp_AkMIDIPost_tNoteOnOff_byNote_set")]
    public static extern void CSharp_AkMIDIPost_tNoteOnOff_byNote_set(IntPtr jarg1, byte jarg2);
    [DllImport("AkSoundEngine", EntryPoint = "CSharp_AkMIDIPost_tNoteOnOff_byNote_get")]
    public static extern byte CSharp_AkMIDIPost_tNoteOnOff_byNote_get(IntPtr jarg1);

    [DllImport("AkSoundEngine", EntryPoint = "CSharp_AkMIDIPost_tNoteOnOff_byVelocity_set")]
    public static extern void CSharp_AkMIDIPost_tNoteOnOff_byVelocity_set(IntPtr jarg1, byte jarg2);
    [DllImport("AkSoundEngine", EntryPoint = "CSharp_AkMIDIPost_tNoteOnOff_byVelocity_get")]
    public static extern byte CSharp_AkMIDIPost_tNoteOnOff_byVelocity_get(IntPtr jarg1);

[/code]


AkMIDIPost.cs

[code]

    public byte byNote
    {
        set
        {
            AkSoundEnginePINVOKE.CSharp_AkMIDIPost_tNoteOnOff_byNote_set(swigCPtr, value);

        }
        get
        {
            byte ret = AkSoundEnginePINVOKE.CSharp_AkMIDIPost_tNoteOnOff_byNote_get(swigCPtr);

            return ret;
        }
    }
    public byte byVelocity
    {
        set
        {
            AkSoundEnginePINVOKE.CSharp_AkMIDIPost_tNoteOnOff_byVelocity_set(swigCPtr, value);

        }
        get
        {
            byte ret = AkSoundEnginePINVOKE.CSharp_AkMIDIPost_tNoteOnOff_byVelocity_get(swigCPtr);

            return ret;
        }
    }

[/code]

 

Sorry for any formatting issues...

用户: John J. (340 分)
Even more broken now?
...