커뮤니티 Q&A

Audiokinetic의 커뮤니티 Q&A 포럼에 오신 것을 환영합니다. 이 포럼은 Wwise와 Strata 사용자들이 서로 도움을 주는 곳입니다. Audiokinetic의 직접적인 도움을 얻으려면 지원 티켓 페이지를 사용하세요. 버그를 보고하려면 Audiokinetic 런처에서 Bug Report 옵션을 사용하세요. (Q&A 포럼에 제출된 버그 보고는 거절됩니다. 전용 Bug Report 시스템을 사용하면 보고 내용이 담당자에게 정확히 전달되어 문제 해결 가능성이 크게 높아집니다.)<segment 6493>

빠르고 정확한 답변을 얻으려면 질문을 올릴 때 다음 팁을 참고하세요.

  • 구체적인 내용을 적어주세요: 무엇을 하려는지, 혹은 어떤 특정 문제에 부딪혔는지 설명하세요.
  • 핵심 정보를 포함하세요: 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?
...