ホーム › Media.Audio.DirectMusic › DMUS_REGION
DMUS_REGION
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| RangeKey | RGNRANGE | 4 | +0 | +0 | リージョンが対応するキー範囲を示すRGNRANGE。 |
| RangeVelocity | RGNRANGE | 4 | +4 | +4 | リージョンが対応するベロシティ範囲を示すRGNRANGE。 |
| fusOptions | WORD | 2 | +8 | +8 | リージョンのオプションフラグ。 |
| usKeyGroup | WORD | 2 | +10 | +10 | リージョンが属するキーグループ番号。 |
| ulRegionArtIdx | DWORD | 4 | +12 | +12 | リージョン固有アーティキュレーションへのインデックス。 |
| ulNextRegionIdx | DWORD | 4 | +16 | +16 | 次のリージョンへのインデックス。 |
| ulFirstExtCkIdx | DWORD | 4 | +20 | +20 | 最初の拡張チャンクへのインデックス。 |
| WaveLink | WAVELINK | 12 | +24 | +24 | ウェーブとの関連付けを示すWAVELINK。 |
| WSMP | WSMPL | 20 | +36 | +36 | サンプル情報を示すWSMPL。 |
| WLOOP | WLOOP | 16 | +56 | +56 | ループ情報を示すWLOOP。 |
各言語での定義
#include <windows.h>
// RGNRANGE (x64 4 / x86 4 バイト)
typedef struct RGNRANGE {
WORD usLow;
WORD usHigh;
} RGNRANGE;
// WAVELINK (x64 12 / x86 12 バイト)
typedef struct WAVELINK {
WORD fusOptions;
WORD usPhaseGroup;
DWORD ulChannel;
DWORD ulTableIndex;
} WAVELINK;
// WSMPL (x64 20 / x86 20 バイト)
typedef struct WSMPL {
DWORD cbSize;
WORD usUnityNote;
SHORT sFineTune;
INT lAttenuation;
DWORD fulOptions;
DWORD cSampleLoops;
} WSMPL;
// WLOOP (x64 16 / x86 16 バイト)
typedef struct WLOOP {
DWORD cbSize;
DWORD ulType;
DWORD ulStart;
DWORD ulLength;
} WLOOP;
// DMUS_REGION (x64 72 / x86 72 バイト)
typedef struct DMUS_REGION {
RGNRANGE RangeKey;
RGNRANGE RangeVelocity;
WORD fusOptions;
WORD usKeyGroup;
DWORD ulRegionArtIdx;
DWORD ulNextRegionIdx;
DWORD ulFirstExtCkIdx;
WAVELINK WaveLink;
WSMPL WSMP;
WLOOP WLOOP[1];
} DMUS_REGION;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RGNRANGE
{
public ushort usLow;
public ushort usHigh;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WAVELINK
{
public ushort fusOptions;
public ushort usPhaseGroup;
public uint ulChannel;
public uint ulTableIndex;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSMPL
{
public uint cbSize;
public ushort usUnityNote;
public short sFineTune;
public int lAttenuation;
public uint fulOptions;
public uint cSampleLoops;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WLOOP
{
public uint cbSize;
public uint ulType;
public uint ulStart;
public uint ulLength;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DMUS_REGION
{
public RGNRANGE RangeKey;
public RGNRANGE RangeVelocity;
public ushort fusOptions;
public ushort usKeyGroup;
public uint ulRegionArtIdx;
public uint ulNextRegionIdx;
public uint ulFirstExtCkIdx;
public WAVELINK WaveLink;
public WSMPL WSMP;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public WLOOP[] WLOOP;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RGNRANGE
Public usLow As UShort
Public usHigh As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WAVELINK
Public fusOptions As UShort
Public usPhaseGroup As UShort
Public ulChannel As UInteger
Public ulTableIndex As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WSMPL
Public cbSize As UInteger
Public usUnityNote As UShort
Public sFineTune As Short
Public lAttenuation As Integer
Public fulOptions As UInteger
Public cSampleLoops As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WLOOP
Public cbSize As UInteger
Public ulType As UInteger
Public ulStart As UInteger
Public ulLength As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DMUS_REGION
Public RangeKey As RGNRANGE
Public RangeVelocity As RGNRANGE
Public fusOptions As UShort
Public usKeyGroup As UShort
Public ulRegionArtIdx As UInteger
Public ulNextRegionIdx As UInteger
Public ulFirstExtCkIdx As UInteger
Public WaveLink As WAVELINK
Public WSMP As WSMPL
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public WLOOP() As WLOOP
End Structureimport ctypes
from ctypes import wintypes
class RGNRANGE(ctypes.Structure):
_fields_ = [
("usLow", ctypes.c_ushort),
("usHigh", ctypes.c_ushort),
]
class WAVELINK(ctypes.Structure):
_fields_ = [
("fusOptions", ctypes.c_ushort),
("usPhaseGroup", ctypes.c_ushort),
("ulChannel", wintypes.DWORD),
("ulTableIndex", wintypes.DWORD),
]
class WSMPL(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("usUnityNote", ctypes.c_ushort),
("sFineTune", ctypes.c_short),
("lAttenuation", ctypes.c_int),
("fulOptions", wintypes.DWORD),
("cSampleLoops", wintypes.DWORD),
]
class WLOOP(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("ulType", wintypes.DWORD),
("ulStart", wintypes.DWORD),
("ulLength", wintypes.DWORD),
]
class DMUS_REGION(ctypes.Structure):
_fields_ = [
("RangeKey", RGNRANGE),
("RangeVelocity", RGNRANGE),
("fusOptions", ctypes.c_ushort),
("usKeyGroup", ctypes.c_ushort),
("ulRegionArtIdx", wintypes.DWORD),
("ulNextRegionIdx", wintypes.DWORD),
("ulFirstExtCkIdx", wintypes.DWORD),
("WaveLink", WAVELINK),
("WSMP", WSMPL),
("WLOOP", WLOOP * 1),
]#[repr(C)]
pub struct RGNRANGE {
pub usLow: u16,
pub usHigh: u16,
}
#[repr(C)]
pub struct WAVELINK {
pub fusOptions: u16,
pub usPhaseGroup: u16,
pub ulChannel: u32,
pub ulTableIndex: u32,
}
#[repr(C)]
pub struct WSMPL {
pub cbSize: u32,
pub usUnityNote: u16,
pub sFineTune: i16,
pub lAttenuation: i32,
pub fulOptions: u32,
pub cSampleLoops: u32,
}
#[repr(C)]
pub struct WLOOP {
pub cbSize: u32,
pub ulType: u32,
pub ulStart: u32,
pub ulLength: u32,
}
#[repr(C)]
pub struct DMUS_REGION {
pub RangeKey: RGNRANGE,
pub RangeVelocity: RGNRANGE,
pub fusOptions: u16,
pub usKeyGroup: u16,
pub ulRegionArtIdx: u32,
pub ulNextRegionIdx: u32,
pub ulFirstExtCkIdx: u32,
pub WaveLink: WAVELINK,
pub WSMP: WSMPL,
pub WLOOP: [WLOOP; 1],
}import "golang.org/x/sys/windows"
type RGNRANGE struct {
usLow uint16
usHigh uint16
}
type WAVELINK struct {
fusOptions uint16
usPhaseGroup uint16
ulChannel uint32
ulTableIndex uint32
}
type WSMPL struct {
cbSize uint32
usUnityNote uint16
sFineTune int16
lAttenuation int32
fulOptions uint32
cSampleLoops uint32
}
type WLOOP struct {
cbSize uint32
ulType uint32
ulStart uint32
ulLength uint32
}
type DMUS_REGION struct {
RangeKey RGNRANGE
RangeVelocity RGNRANGE
fusOptions uint16
usKeyGroup uint16
ulRegionArtIdx uint32
ulNextRegionIdx uint32
ulFirstExtCkIdx uint32
WaveLink WAVELINK
WSMP WSMPL
WLOOP [1]WLOOP
}type
RGNRANGE = record
usLow: Word;
usHigh: Word;
end;
WAVELINK = record
fusOptions: Word;
usPhaseGroup: Word;
ulChannel: DWORD;
ulTableIndex: DWORD;
end;
WSMPL = record
cbSize: DWORD;
usUnityNote: Word;
sFineTune: Smallint;
lAttenuation: Integer;
fulOptions: DWORD;
cSampleLoops: DWORD;
end;
WLOOP = record
cbSize: DWORD;
ulType: DWORD;
ulStart: DWORD;
ulLength: DWORD;
end;
DMUS_REGION = record
RangeKey: RGNRANGE;
RangeVelocity: RGNRANGE;
fusOptions: Word;
usKeyGroup: Word;
ulRegionArtIdx: DWORD;
ulNextRegionIdx: DWORD;
ulFirstExtCkIdx: DWORD;
WaveLink: WAVELINK;
WSMP: WSMPL;
WLOOP: array[0..0] of WLOOP;
end;const RGNRANGE = extern struct {
usLow: u16,
usHigh: u16,
};
const WAVELINK = extern struct {
fusOptions: u16,
usPhaseGroup: u16,
ulChannel: u32,
ulTableIndex: u32,
};
const WSMPL = extern struct {
cbSize: u32,
usUnityNote: u16,
sFineTune: i16,
lAttenuation: i32,
fulOptions: u32,
cSampleLoops: u32,
};
const WLOOP = extern struct {
cbSize: u32,
ulType: u32,
ulStart: u32,
ulLength: u32,
};
const DMUS_REGION = extern struct {
RangeKey: RGNRANGE,
RangeVelocity: RGNRANGE,
fusOptions: u16,
usKeyGroup: u16,
ulRegionArtIdx: u32,
ulNextRegionIdx: u32,
ulFirstExtCkIdx: u32,
WaveLink: WAVELINK,
WSMP: WSMPL,
WLOOP: [1]WLOOP,
};type
RGNRANGE {.bycopy.} = object
usLow: uint16
usHigh: uint16
WAVELINK {.bycopy.} = object
fusOptions: uint16
usPhaseGroup: uint16
ulChannel: uint32
ulTableIndex: uint32
WSMPL {.bycopy.} = object
cbSize: uint32
usUnityNote: uint16
sFineTune: int16
lAttenuation: int32
fulOptions: uint32
cSampleLoops: uint32
WLOOP {.bycopy.} = object
cbSize: uint32
ulType: uint32
ulStart: uint32
ulLength: uint32
DMUS_REGION {.bycopy.} = object
RangeKey: RGNRANGE
RangeVelocity: RGNRANGE
fusOptions: uint16
usKeyGroup: uint16
ulRegionArtIdx: uint32
ulNextRegionIdx: uint32
ulFirstExtCkIdx: uint32
WaveLink: WAVELINK
WSMP: WSMPL
WLOOP: array[1, WLOOP]struct RGNRANGE
{
ushort usLow;
ushort usHigh;
}
struct WAVELINK
{
ushort fusOptions;
ushort usPhaseGroup;
uint ulChannel;
uint ulTableIndex;
}
struct WSMPL
{
uint cbSize;
ushort usUnityNote;
short sFineTune;
int lAttenuation;
uint fulOptions;
uint cSampleLoops;
}
struct WLOOP
{
uint cbSize;
uint ulType;
uint ulStart;
uint ulLength;
}
struct DMUS_REGION
{
RGNRANGE RangeKey;
RGNRANGE RangeVelocity;
ushort fusOptions;
ushort usKeyGroup;
uint ulRegionArtIdx;
uint ulNextRegionIdx;
uint ulFirstExtCkIdx;
WAVELINK WaveLink;
WSMPL WSMP;
WLOOP[1] WLOOP;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DMUS_REGION サイズ: 72 バイト(x64)
dim st, 18 ; 4byte整数×18(構造体サイズ 72 / 4 切り上げ)
; RangeKey : RGNRANGE (+0, 4byte) varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; RangeVelocity : RGNRANGE (+4, 4byte) varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; fusOptions : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; usKeyGroup : WORD (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; ulRegionArtIdx : DWORD (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; ulNextRegionIdx : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ulFirstExtCkIdx : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; WaveLink : WAVELINK (+24, 12byte) varptr(st)+24 を基点に操作(12byte:入れ子/配列)
; WSMP : WSMPL (+36, 20byte) varptr(st)+36 を基点に操作(20byte:入れ子/配列)
; WLOOP : WLOOP (+56, 16byte) varptr(st)+56 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global RGNRANGE
#field short usLow
#field short usHigh
#endstruct
#defstruct global WAVELINK
#field short fusOptions
#field short usPhaseGroup
#field int ulChannel
#field int ulTableIndex
#endstruct
#defstruct global WSMPL
#field int cbSize
#field short usUnityNote
#field short sFineTune
#field int lAttenuation
#field int fulOptions
#field int cSampleLoops
#endstruct
#defstruct global WLOOP
#field int cbSize
#field int ulType
#field int ulStart
#field int ulLength
#endstruct
#defstruct global DMUS_REGION
#field RGNRANGE RangeKey
#field RGNRANGE RangeVelocity
#field short fusOptions
#field short usKeyGroup
#field int ulRegionArtIdx
#field int ulNextRegionIdx
#field int ulFirstExtCkIdx
#field WAVELINK WaveLink
#field WSMPL WSMP
#field WLOOP WLOOP 1
#endstruct
stdim st, DMUS_REGION ; NSTRUCT 変数を確保
st->fusOptions = 100
mes "fusOptions=" + st->fusOptions