Win32 API 日本語リファレンス
ホームMedia.Audio › MIDIHDR

MIDIHDR

構造体
サイズx64: 112 バイト / x86: 64 バイトパッキング1

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
lpDataLPSTR8/4+0+0MIDIデータバッファへのポインタ(SysExやストリーム用)。
dwBufferLengthDWORD4+8+4バッファのバイトサイズ。
dwBytesRecordedDWORD4+12+8入力時に実際に記録されたバイト数。
dwUserUINT_PTR8/4+16+12アプリ定義のユーザーデータ。
dwFlagsDWORD4+24+16バッファの状態を示すビットフラグ(MHDR_DONE/PREPARED等)。
lpNextMIDIHDR*8/4+28+20予約済み。次のMIDIHDRへのポインタ(ドライバ用)。
reservedUINT_PTR8/4+36+24予約済み。アプリは使用しない。
dwOffsetDWORD4+44+28コールバック時のバッファ内オフセット(ストリーム用)。
dwReservedUINT_PTR64/32+48+32予約済み。アプリは使用しない(固定長配列)。

各言語での定義

#include <windows.h>

// MIDIHDR  (x64 112 / x86 64 バイト)
#pragma pack(push, 1)
typedef struct MIDIHDR {
    LPSTR lpData;
    DWORD dwBufferLength;
    DWORD dwBytesRecorded;
    UINT_PTR dwUser;
    DWORD dwFlags;
    MIDIHDR* lpNext;
    UINT_PTR reserved;
    DWORD dwOffset;
    UINT_PTR dwReserved[8];
} MIDIHDR;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct MIDIHDR
{
    public IntPtr lpData;
    public uint dwBufferLength;
    public uint dwBytesRecorded;
    public UIntPtr dwUser;
    public uint dwFlags;
    public IntPtr lpNext;
    public UIntPtr reserved;
    public uint dwOffset;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public UIntPtr[] dwReserved;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure MIDIHDR
    Public lpData As IntPtr
    Public dwBufferLength As UInteger
    Public dwBytesRecorded As UInteger
    Public dwUser As UIntPtr
    Public dwFlags As UInteger
    Public lpNext As IntPtr
    Public reserved As UIntPtr
    Public dwOffset As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public dwReserved() As UIntPtr
End Structure
import ctypes
from ctypes import wintypes

class MIDIHDR(ctypes.Structure):
    _pack_ = 1
    _fields_ = [
        ("lpData", ctypes.c_void_p),
        ("dwBufferLength", wintypes.DWORD),
        ("dwBytesRecorded", wintypes.DWORD),
        ("dwUser", ctypes.c_size_t),
        ("dwFlags", wintypes.DWORD),
        ("lpNext", ctypes.c_void_p),
        ("reserved", ctypes.c_size_t),
        ("dwOffset", wintypes.DWORD),
        ("dwReserved", ctypes.c_size_t * 8),
    ]
#[repr(C, packed(1))]
pub struct MIDIHDR {
    pub lpData: *mut core::ffi::c_void,
    pub dwBufferLength: u32,
    pub dwBytesRecorded: u32,
    pub dwUser: usize,
    pub dwFlags: u32,
    pub lpNext: *mut core::ffi::c_void,
    pub reserved: usize,
    pub dwOffset: u32,
    pub dwReserved: [usize; 8],
}
import "golang.org/x/sys/windows"

type MIDIHDR struct {
	lpData uintptr
	dwBufferLength uint32
	dwBytesRecorded uint32
	dwUser uintptr
	dwFlags uint32
	lpNext uintptr
	reserved uintptr
	dwOffset uint32
	dwReserved [8]uintptr
}
type
  MIDIHDR = packed record
    lpData: Pointer;
    dwBufferLength: DWORD;
    dwBytesRecorded: DWORD;
    dwUser: NativeUInt;
    dwFlags: DWORD;
    lpNext: Pointer;
    reserved: NativeUInt;
    dwOffset: DWORD;
    dwReserved: array[0..7] of NativeUInt;
  end;
const MIDIHDR = extern struct {
    lpData: ?*anyopaque,
    dwBufferLength: u32,
    dwBytesRecorded: u32,
    dwUser: usize,
    dwFlags: u32,
    lpNext: ?*anyopaque,
    reserved: usize,
    dwOffset: u32,
    dwReserved: [8]usize,
};
type
  MIDIHDR {.packed.} = object
    lpData: pointer
    dwBufferLength: uint32
    dwBytesRecorded: uint32
    dwUser: uint
    dwFlags: uint32
    lpNext: pointer
    reserved: uint
    dwOffset: uint32
    dwReserved: array[8, uint]
align(1)
struct MIDIHDR
{
    void* lpData;
    uint dwBufferLength;
    uint dwBytesRecorded;
    size_t dwUser;
    uint dwFlags;
    void* lpNext;
    size_t reserved;
    uint dwOffset;
    size_t[8] dwReserved;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; MIDIHDR サイズ: 64 バイト(x86)
dim st, 16    ; 4byte整数×16(構造体サイズ 64 / 4 切り上げ)
; lpData : LPSTR (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwBufferLength : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwBytesRecorded : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dwUser : UINT_PTR (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwFlags : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; lpNext : MIDIHDR* (+20, 4byte)  varptr(st)+20 を基点に操作(4byte:入れ子/配列)
; reserved : UINT_PTR (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; dwOffset : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; dwReserved : UINT_PTR (+32, 32byte)  varptr(st)+32 を基点に操作(32byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MIDIHDR サイズ: 112 バイト(x64)
dim st, 28    ; 4byte整数×28(構造体サイズ 112 / 4 切り上げ)
; lpData : LPSTR (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; dwBufferLength : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; dwBytesRecorded : DWORD (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; dwUser : UINT_PTR (+16, 8byte)  qpoke st,16,値 / qpeek(st,16)  ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; dwFlags : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; lpNext : MIDIHDR* (+28, 8byte)  varptr(st)+28 を基点に操作(8byte:入れ子/配列)
; reserved : UINT_PTR (+36, 8byte)  qpoke st,36,値 / qpeek(st,36)  ※IronHSPのみ。3.7/3.8は lpoke st,36,下位 : lpoke st,40,上位
; dwOffset : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; dwReserved : UINT_PTR (+48, 64byte)  varptr(st)+48 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MIDIHDR, pack=1
    #field intptr lpData
    #field int dwBufferLength
    #field int dwBytesRecorded
    #field intptr dwUser
    #field int dwFlags
    #field intptr lpNext
    #field intptr reserved
    #field int dwOffset
    #field intptr dwReserved 8
#endstruct

stdim st, MIDIHDR        ; NSTRUCT 変数を確保
st->dwBufferLength = 100
mes "dwBufferLength=" + st->dwBufferLength