ホーム › Media.Multimedia › WMAUDIO3WAVEFORMAT
WMAUDIO3WAVEFORMAT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| wfx | WAVEFORMATEX | 18 | +0 | +0 | 波形フォーマットの基底となるWAVEFORMATEX構造体。Windows Media Audio v3(WMA Pro)形式を示す。 |
| wValidBitsPerSample | WORD | 2 | +18 | +18 | サンプルあたりの有効ビット数。コンテナビット幅以下の実効精度を示す。 |
| dwChannelMask | DWORD | 4 | +20 | +20 | チャンネル配置を示すスピーカー位置のビットマスク。マルチチャンネル配置を指定する。 |
| dwReserved1 | DWORD | 4 | +24 | +24 | 予約済みフィールド。将来の拡張用で通常はゼロ。 |
| dwReserved2 | DWORD | 4 | +28 | +28 | 予約済みフィールド。将来の拡張用で通常はゼロ。 |
| wEncodeOptions | WORD | 2 | +32 | +32 | エンコードオプションを示すフラグ。エンコーダ固有の設定を保持する。 |
| wReserved3 | WORD | 2 | +34 | +34 | 予約済みフィールド。将来の拡張用で通常はゼロ。 |
各言語での定義
#include <windows.h>
// WAVEFORMATEX (x64 18 / x86 18 バイト)
#pragma pack(push, 1)
typedef struct WAVEFORMATEX {
WORD wFormatTag;
WORD nChannels;
DWORD nSamplesPerSec;
DWORD nAvgBytesPerSec;
WORD nBlockAlign;
WORD wBitsPerSample;
WORD cbSize;
} WAVEFORMATEX;
#pragma pack(pop)
// WMAUDIO3WAVEFORMAT (x64 36 / x86 36 バイト)
#pragma pack(push, 1)
typedef struct WMAUDIO3WAVEFORMAT {
WAVEFORMATEX wfx;
WORD wValidBitsPerSample;
DWORD dwChannelMask;
DWORD dwReserved1;
DWORD dwReserved2;
WORD wEncodeOptions;
WORD wReserved3;
} WMAUDIO3WAVEFORMAT;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct WAVEFORMATEX
{
public ushort wFormatTag;
public ushort nChannels;
public uint nSamplesPerSec;
public uint nAvgBytesPerSec;
public ushort nBlockAlign;
public ushort wBitsPerSample;
public ushort cbSize;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct WMAUDIO3WAVEFORMAT
{
public WAVEFORMATEX wfx;
public ushort wValidBitsPerSample;
public uint dwChannelMask;
public uint dwReserved1;
public uint dwReserved2;
public ushort wEncodeOptions;
public ushort wReserved3;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure WAVEFORMATEX
Public wFormatTag As UShort
Public nChannels As UShort
Public nSamplesPerSec As UInteger
Public nAvgBytesPerSec As UInteger
Public nBlockAlign As UShort
Public wBitsPerSample As UShort
Public cbSize As UShort
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure WMAUDIO3WAVEFORMAT
Public wfx As WAVEFORMATEX
Public wValidBitsPerSample As UShort
Public dwChannelMask As UInteger
Public dwReserved1 As UInteger
Public dwReserved2 As UInteger
Public wEncodeOptions As UShort
Public wReserved3 As UShort
End Structureimport ctypes
from ctypes import wintypes
class WAVEFORMATEX(ctypes.Structure):
_pack_ = 1
_fields_ = [
("wFormatTag", ctypes.c_ushort),
("nChannels", ctypes.c_ushort),
("nSamplesPerSec", wintypes.DWORD),
("nAvgBytesPerSec", wintypes.DWORD),
("nBlockAlign", ctypes.c_ushort),
("wBitsPerSample", ctypes.c_ushort),
("cbSize", ctypes.c_ushort),
]
class WMAUDIO3WAVEFORMAT(ctypes.Structure):
_pack_ = 1
_fields_ = [
("wfx", WAVEFORMATEX),
("wValidBitsPerSample", ctypes.c_ushort),
("dwChannelMask", wintypes.DWORD),
("dwReserved1", wintypes.DWORD),
("dwReserved2", wintypes.DWORD),
("wEncodeOptions", ctypes.c_ushort),
("wReserved3", ctypes.c_ushort),
]#[repr(C, packed(1))]
pub struct WAVEFORMATEX {
pub wFormatTag: u16,
pub nChannels: u16,
pub nSamplesPerSec: u32,
pub nAvgBytesPerSec: u32,
pub nBlockAlign: u16,
pub wBitsPerSample: u16,
pub cbSize: u16,
}
#[repr(C, packed(1))]
pub struct WMAUDIO3WAVEFORMAT {
pub wfx: WAVEFORMATEX,
pub wValidBitsPerSample: u16,
pub dwChannelMask: u32,
pub dwReserved1: u32,
pub dwReserved2: u32,
pub wEncodeOptions: u16,
pub wReserved3: u16,
}import "golang.org/x/sys/windows"
type WAVEFORMATEX struct {
wFormatTag uint16
nChannels uint16
nSamplesPerSec uint32
nAvgBytesPerSec uint32
nBlockAlign uint16
wBitsPerSample uint16
cbSize uint16
}
type WMAUDIO3WAVEFORMAT struct {
wfx WAVEFORMATEX
wValidBitsPerSample uint16
dwChannelMask uint32
dwReserved1 uint32
dwReserved2 uint32
wEncodeOptions uint16
wReserved3 uint16
}type
WAVEFORMATEX = packed record
wFormatTag: Word;
nChannels: Word;
nSamplesPerSec: DWORD;
nAvgBytesPerSec: DWORD;
nBlockAlign: Word;
wBitsPerSample: Word;
cbSize: Word;
end;
WMAUDIO3WAVEFORMAT = packed record
wfx: WAVEFORMATEX;
wValidBitsPerSample: Word;
dwChannelMask: DWORD;
dwReserved1: DWORD;
dwReserved2: DWORD;
wEncodeOptions: Word;
wReserved3: Word;
end;const WAVEFORMATEX = extern struct {
wFormatTag: u16,
nChannels: u16,
nSamplesPerSec: u32,
nAvgBytesPerSec: u32,
nBlockAlign: u16,
wBitsPerSample: u16,
cbSize: u16,
};
const WMAUDIO3WAVEFORMAT = extern struct {
wfx: WAVEFORMATEX,
wValidBitsPerSample: u16,
dwChannelMask: u32,
dwReserved1: u32,
dwReserved2: u32,
wEncodeOptions: u16,
wReserved3: u16,
};type
WAVEFORMATEX {.packed.} = object
wFormatTag: uint16
nChannels: uint16
nSamplesPerSec: uint32
nAvgBytesPerSec: uint32
nBlockAlign: uint16
wBitsPerSample: uint16
cbSize: uint16
WMAUDIO3WAVEFORMAT {.packed.} = object
wfx: WAVEFORMATEX
wValidBitsPerSample: uint16
dwChannelMask: uint32
dwReserved1: uint32
dwReserved2: uint32
wEncodeOptions: uint16
wReserved3: uint16align(1)
struct WAVEFORMATEX
{
ushort wFormatTag;
ushort nChannels;
uint nSamplesPerSec;
uint nAvgBytesPerSec;
ushort nBlockAlign;
ushort wBitsPerSample;
ushort cbSize;
}
align(1)
struct WMAUDIO3WAVEFORMAT
{
WAVEFORMATEX wfx;
ushort wValidBitsPerSample;
uint dwChannelMask;
uint dwReserved1;
uint dwReserved2;
ushort wEncodeOptions;
ushort wReserved3;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WMAUDIO3WAVEFORMAT サイズ: 36 バイト(x64)
dim st, 9 ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; wfx : WAVEFORMATEX (+0, 18byte) varptr(st)+0 を基点に操作(18byte:入れ子/配列)
; wValidBitsPerSample : WORD (+18, 2byte) wpoke st,18,値 / 値 = wpeek(st,18)
; dwChannelMask : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; dwReserved1 : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; dwReserved2 : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; wEncodeOptions : WORD (+32, 2byte) wpoke st,32,値 / 値 = wpeek(st,32)
; wReserved3 : WORD (+34, 2byte) wpoke st,34,値 / 値 = wpeek(st,34)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global WAVEFORMATEX, pack=1
#field short wFormatTag
#field short nChannels
#field int nSamplesPerSec
#field int nAvgBytesPerSec
#field short nBlockAlign
#field short wBitsPerSample
#field short cbSize
#endstruct
#defstruct global WMAUDIO3WAVEFORMAT, pack=1
#field WAVEFORMATEX wfx
#field short wValidBitsPerSample
#field int dwChannelMask
#field int dwReserved1
#field int dwReserved2
#field short wEncodeOptions
#field short wReserved3
#endstruct
stdim st, WMAUDIO3WAVEFORMAT ; NSTRUCT 変数を確保
st->wValidBitsPerSample = 100
mes "wValidBitsPerSample=" + st->wValidBitsPerSample