Wwise SDK
クイックスタートサンプル統合 - MIDI
バージョン
menu
link
|
Wwise SDK 2022.1.19
|
クイックスタートサンプル統合 - MIDI
MIDI 統合例
MIDIイベントは、AK::SoundEngine::PostMIDIOnEvent() 関数を呼び出してポストされます。次のコードが 例を示しています:
- 初期MIDI パラメータを設定し、
- イベント名(Wwiseユーザーがつけた名前)または "Wwise_IDs.h"(Wwiseによって生成されるヘッダーファイル)で定義されるイベント ID を使用したイベントポスト。 by Wwise).
#include "Wwise_IDs.h" // IDs generated by Wwise
// After Sound Engine initialization, register a global callback function.
// Be sure to register for callback just before the message queue is processed;
// this will ensure that any newly posted MIDI events are processed during
// the current frame (i.e. immediately after we exit our callback function).
AK::SoundEngine::RegisterGlobalCallback( &MIDICallback, AkGlobalCallbackLocation_PreProcessMessageQueueForRender )
// Obtain Sound Engine audio settings. These are required to determine the time
// equivalent of one audio frame.
AkAudioSettings audioSettings;
AK::SoundEngine::GetAudioSettings( audioSettings );
(...)
// Callback function used to post MIDI events.
void MIDICallback( bool in_bLastCall )
{
// Post MIDI event(s) if required.
// Take extra care to ensure this code is thread-safe.
// For this example, assume we need to post the note-on and note-off
// events for the same note.
AkMIDIPost aPosts[2];
const AkUInt8 byNote = 60;
// Note will end mid-frame.
// Note-on
AkMIDIPost& noteOn = aPosts[0];
noteOn.byType = AK_MIDI_EVENT_TYPE_NOTE_ON;
noteOn.byChan = byChan;
noteOn.uOffset = uOnSamples;
// Note-off
AkMIDIPost& noteOff = aPosts[1];
noteOff.byType = AK_MIDI_EVENT_TYPE_NOTE_OFF;
noteOff.byChan = byChan;
noteOff.uOffset = uOffSamples;
AK::SoundEngine::PostMIDIOnEvent( eventID, REGISTERED_MIDI_GAME_OBJECT, aPosts, 2 );
}
イベントに関する詳細は、 統合の詳細 - Event(イベント) を参照してください。 MIDIに関する詳細は、 統合の詳細 - MIDI を参照してください。
AKSOUNDENGINE_API AKRESULT RegisterGlobalCallback(AkGlobalCallbackFunc in_pCallback, AkUInt32 in_eLocation=AkGlobalCallbackLocation_BeginRender, void *in_pCookie=NULL, AkPluginType in_eType=AkPluginTypeNone, AkUInt32 in_ulCompanyID=0, AkUInt32 in_ulPluginID=0)
AKSOUNDENGINE_API AkPlayingID PostMIDIOnEvent(AkUniqueID in_eventID, AkGameObjectID in_gameObjectID, AkMIDIPost *in_pPosts, AkUInt16 in_uNumPosts, bool in_bAbsoluteOffsets=false, AkUInt32 in_uFlags=0, AkCallbackFunc in_pfnCallback=NULL, void *in_pCookie=NULL, AkPlayingID in_playingID=AK_INVALID_PLAYING_ID)
AKSOUNDENGINE_API AKRESULT GetAudioSettings(AkAudioSettings &out_audioSettings)
@ AkGlobalCallbackLocation_PreProcessMessageQueueForRender
Start of frame rendering, before having processed game messages.
Definition: AkCallback.h:340
AkUInt32 uNumSamplesPerFrame
Number of samples per audio frame (256, 512, 1024 or 2048).
Definition: AkTypes.h:286
AKSOUNDENGINE_API AkUInt32 GetIDFromString(const char *in_pszString)
Definition: AkMidiTypes.h:237
このページはお役に立ちましたか?
このページの内容
menu