ホーム › Media.Audio › WAVEHDR
WAVEHDR
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| lpData | LPSTR | 8/4 | +0 | +0 | 波形データバッファへのポインタ。 |
| dwBufferLength | DWORD | 4 | +8 | +4 | バッファのバイトサイズ。 |
| dwBytesRecorded | DWORD | 4 | +12 | +8 | 録音時に実際に記録されたバイト数(入力用)。 |
| dwUser | UINT_PTR | 8/4 | +16 | +12 | アプリ定義のユーザーデータ。 |
| dwFlags | DWORD | 4 | +24 | +16 | バッファの状態を示すビットフラグ(WHDR_DONE/PREPARED等)。 |
| dwLoops | DWORD | 4 | +28 | +20 | ループ再生回数(WHDR_BEGINLOOP/ENDLOOP使用時)。 |
| lpNext | WAVEHDR* | 8/4 | +32 | +24 | 予約済み。次のWAVEHDRへのポインタ(ドライバ用)。 |
| reserved | UINT_PTR | 8/4 | +40 | +28 | 予約済み。アプリは使用しない。 |
各言語での定義
#include <windows.h>
// WAVEHDR (x64 48 / x86 32 バイト)
#pragma pack(push, 1)
typedef struct WAVEHDR {
LPSTR lpData;
DWORD dwBufferLength;
DWORD dwBytesRecorded;
UINT_PTR dwUser;
DWORD dwFlags;
DWORD dwLoops;
WAVEHDR* lpNext;
UINT_PTR reserved;
} WAVEHDR;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct WAVEHDR
{
public IntPtr lpData;
public uint dwBufferLength;
public uint dwBytesRecorded;
public UIntPtr dwUser;
public uint dwFlags;
public uint dwLoops;
public IntPtr lpNext;
public UIntPtr reserved;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure WAVEHDR
Public lpData As IntPtr
Public dwBufferLength As UInteger
Public dwBytesRecorded As UInteger
Public dwUser As UIntPtr
Public dwFlags As UInteger
Public dwLoops As UInteger
Public lpNext As IntPtr
Public reserved As UIntPtr
End Structureimport ctypes
from ctypes import wintypes
class WAVEHDR(ctypes.Structure):
_pack_ = 1
_fields_ = [
("lpData", ctypes.c_void_p),
("dwBufferLength", wintypes.DWORD),
("dwBytesRecorded", wintypes.DWORD),
("dwUser", ctypes.c_size_t),
("dwFlags", wintypes.DWORD),
("dwLoops", wintypes.DWORD),
("lpNext", ctypes.c_void_p),
("reserved", ctypes.c_size_t),
]#[repr(C, packed(1))]
pub struct WAVEHDR {
pub lpData: *mut core::ffi::c_void,
pub dwBufferLength: u32,
pub dwBytesRecorded: u32,
pub dwUser: usize,
pub dwFlags: u32,
pub dwLoops: u32,
pub lpNext: *mut core::ffi::c_void,
pub reserved: usize,
}import "golang.org/x/sys/windows"
type WAVEHDR struct {
lpData uintptr
dwBufferLength uint32
dwBytesRecorded uint32
dwUser uintptr
dwFlags uint32
dwLoops uint32
lpNext uintptr
reserved uintptr
}type
WAVEHDR = packed record
lpData: Pointer;
dwBufferLength: DWORD;
dwBytesRecorded: DWORD;
dwUser: NativeUInt;
dwFlags: DWORD;
dwLoops: DWORD;
lpNext: Pointer;
reserved: NativeUInt;
end;const WAVEHDR = extern struct {
lpData: ?*anyopaque,
dwBufferLength: u32,
dwBytesRecorded: u32,
dwUser: usize,
dwFlags: u32,
dwLoops: u32,
lpNext: ?*anyopaque,
reserved: usize,
};type
WAVEHDR {.packed.} = object
lpData: pointer
dwBufferLength: uint32
dwBytesRecorded: uint32
dwUser: uint
dwFlags: uint32
dwLoops: uint32
lpNext: pointer
reserved: uintalign(1)
struct WAVEHDR
{
void* lpData;
uint dwBufferLength;
uint dwBytesRecorded;
size_t dwUser;
uint dwFlags;
uint dwLoops;
void* lpNext;
size_t reserved;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WAVEHDR サイズ: 32 バイト(x86)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 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 も可)
; dwLoops : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; lpNext : WAVEHDR* (+24, 4byte) varptr(st)+24 を基点に操作(4byte:入れ子/配列)
; reserved : UINT_PTR (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WAVEHDR サイズ: 48 バイト(x64)
dim st, 12 ; 4byte整数×12(構造体サイズ 48 / 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 も可)
; dwLoops : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; lpNext : WAVEHDR* (+32, 8byte) varptr(st)+32 を基点に操作(8byte:入れ子/配列)
; reserved : UINT_PTR (+40, 8byte) qpoke st,40,値 / qpeek(st,40) ※IronHSPのみ。3.7/3.8は lpoke st,40,下位 : lpoke st,44,上位
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WAVEHDR, pack=1
#field intptr lpData
#field int dwBufferLength
#field int dwBytesRecorded
#field intptr dwUser
#field int dwFlags
#field int dwLoops
#field intptr lpNext
#field intptr reserved
#endstruct
stdim st, WAVEHDR ; NSTRUCT 変数を確保
st->dwBufferLength = 100
mes "dwBufferLength=" + st->dwBufferLength