ホーム › Media.Audio › MIDIEVENT
MIDIEVENT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| dwDeltaTime | DWORD | 4 | +0 | +0 | 前イベントからの相対経過時間(ティック単位)。 |
| dwStreamID | DWORD | 4 | +4 | +4 | ストリームID。現状は予約で0。 |
| dwEvent | DWORD | 4 | +8 | +8 | イベントの種類とデータをパックした値(MEVT_*イベントコードを含む)。 |
| dwParms | DWORD | 4 | +12 | +12 | 可変長パラメータデータの先頭(ロングメッセージ等で使用)。 |
各言語での定義
#include <windows.h>
// MIDIEVENT (x64 16 / x86 16 バイト)
#pragma pack(push, 1)
typedef struct MIDIEVENT {
DWORD dwDeltaTime;
DWORD dwStreamID;
DWORD dwEvent;
DWORD dwParms[1];
} MIDIEVENT;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct MIDIEVENT
{
public uint dwDeltaTime;
public uint dwStreamID;
public uint dwEvent;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public uint[] dwParms;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure MIDIEVENT
Public dwDeltaTime As UInteger
Public dwStreamID As UInteger
Public dwEvent As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public dwParms() As UInteger
End Structureimport ctypes
from ctypes import wintypes
class MIDIEVENT(ctypes.Structure):
_pack_ = 1
_fields_ = [
("dwDeltaTime", wintypes.DWORD),
("dwStreamID", wintypes.DWORD),
("dwEvent", wintypes.DWORD),
("dwParms", wintypes.DWORD * 1),
]#[repr(C, packed(1))]
pub struct MIDIEVENT {
pub dwDeltaTime: u32,
pub dwStreamID: u32,
pub dwEvent: u32,
pub dwParms: [u32; 1],
}import "golang.org/x/sys/windows"
type MIDIEVENT struct {
dwDeltaTime uint32
dwStreamID uint32
dwEvent uint32
dwParms [1]uint32
}type
MIDIEVENT = packed record
dwDeltaTime: DWORD;
dwStreamID: DWORD;
dwEvent: DWORD;
dwParms: array[0..0] of DWORD;
end;const MIDIEVENT = extern struct {
dwDeltaTime: u32,
dwStreamID: u32,
dwEvent: u32,
dwParms: [1]u32,
};type
MIDIEVENT {.packed.} = object
dwDeltaTime: uint32
dwStreamID: uint32
dwEvent: uint32
dwParms: array[1, uint32]align(1)
struct MIDIEVENT
{
uint dwDeltaTime;
uint dwStreamID;
uint dwEvent;
uint[1] dwParms;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MIDIEVENT サイズ: 16 バイト(x64)
dim st, 4 ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; dwDeltaTime : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwStreamID : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; dwEvent : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; dwParms : DWORD (+12, 4byte) varptr(st)+12 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MIDIEVENT, pack=1
#field int dwDeltaTime
#field int dwStreamID
#field int dwEvent
#field int dwParms 1
#endstruct
stdim st, MIDIEVENT ; NSTRUCT 変数を確保
st->dwDeltaTime = 100
mes "dwDeltaTime=" + st->dwDeltaTime