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

UNCOMPRESSEDAUDIOFORMAT

構造体
サイズx64: 36 バイト / x86: 36 バイト

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

フィールド

フィールドサイズx64x86説明
guidFormatTypeGUID16+0+0オーディオサンプルの形式を示すGUID(PCMやIEEE float等)。
dwSamplesPerFrameDWORD4+16+161フレームあたりのサンプル数(チャンネル数に相当)。
dwBytesPerSampleContainerDWORD4+20+201サンプルを格納するコンテナのバイト数。
dwValidBitsPerSampleDWORD4+24+241サンプル中の有効ビット数。
fFramesPerSecondFLOAT4+28+28サンプリングレートをフレーム毎秒(Hz)で示す。
dwChannelMaskDWORD4+32+32各サンプルのチャンネル配置を示すマスク(SPEAKER_*)。

各言語での定義

#include <windows.h>

// UNCOMPRESSEDAUDIOFORMAT  (x64 36 / x86 36 バイト)
typedef struct UNCOMPRESSEDAUDIOFORMAT {
    GUID guidFormatType;
    DWORD dwSamplesPerFrame;
    DWORD dwBytesPerSampleContainer;
    DWORD dwValidBitsPerSample;
    FLOAT fFramesPerSecond;
    DWORD dwChannelMask;
} UNCOMPRESSEDAUDIOFORMAT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct UNCOMPRESSEDAUDIOFORMAT
{
    public Guid guidFormatType;
    public uint dwSamplesPerFrame;
    public uint dwBytesPerSampleContainer;
    public uint dwValidBitsPerSample;
    public float fFramesPerSecond;
    public uint dwChannelMask;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure UNCOMPRESSEDAUDIOFORMAT
    Public guidFormatType As Guid
    Public dwSamplesPerFrame As UInteger
    Public dwBytesPerSampleContainer As UInteger
    Public dwValidBitsPerSample As UInteger
    Public fFramesPerSecond As Single
    Public dwChannelMask As UInteger
End Structure
import ctypes
from ctypes import wintypes

class UNCOMPRESSEDAUDIOFORMAT(ctypes.Structure):
    _fields_ = [
        ("guidFormatType", GUID),
        ("dwSamplesPerFrame", wintypes.DWORD),
        ("dwBytesPerSampleContainer", wintypes.DWORD),
        ("dwValidBitsPerSample", wintypes.DWORD),
        ("fFramesPerSecond", ctypes.c_float),
        ("dwChannelMask", wintypes.DWORD),
    ]
#[repr(C)]
pub struct UNCOMPRESSEDAUDIOFORMAT {
    pub guidFormatType: GUID,
    pub dwSamplesPerFrame: u32,
    pub dwBytesPerSampleContainer: u32,
    pub dwValidBitsPerSample: u32,
    pub fFramesPerSecond: f32,
    pub dwChannelMask: u32,
}
import "golang.org/x/sys/windows"

type UNCOMPRESSEDAUDIOFORMAT struct {
	guidFormatType windows.GUID
	dwSamplesPerFrame uint32
	dwBytesPerSampleContainer uint32
	dwValidBitsPerSample uint32
	fFramesPerSecond float32
	dwChannelMask uint32
}
type
  UNCOMPRESSEDAUDIOFORMAT = record
    guidFormatType: TGUID;
    dwSamplesPerFrame: DWORD;
    dwBytesPerSampleContainer: DWORD;
    dwValidBitsPerSample: DWORD;
    fFramesPerSecond: Single;
    dwChannelMask: DWORD;
  end;
const UNCOMPRESSEDAUDIOFORMAT = extern struct {
    guidFormatType: GUID,
    dwSamplesPerFrame: u32,
    dwBytesPerSampleContainer: u32,
    dwValidBitsPerSample: u32,
    fFramesPerSecond: f32,
    dwChannelMask: u32,
};
type
  UNCOMPRESSEDAUDIOFORMAT {.bycopy.} = object
    guidFormatType: GUID
    dwSamplesPerFrame: uint32
    dwBytesPerSampleContainer: uint32
    dwValidBitsPerSample: uint32
    fFramesPerSecond: float32
    dwChannelMask: uint32
struct UNCOMPRESSEDAUDIOFORMAT
{
    GUID guidFormatType;
    uint dwSamplesPerFrame;
    uint dwBytesPerSampleContainer;
    uint dwValidBitsPerSample;
    float fFramesPerSecond;
    uint dwChannelMask;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; UNCOMPRESSEDAUDIOFORMAT サイズ: 36 バイト(x64)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; guidFormatType : GUID (+0, 16byte)  varptr(st)+0 を基点に操作(16byte:入れ子/配列)
; dwSamplesPerFrame : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; dwBytesPerSampleContainer : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; dwValidBitsPerSample : DWORD (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; fFramesPerSecond : FLOAT (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; dwChannelMask : DWORD (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global GUID, pack=1
    #field int Data1
    #field short Data2
    #field short Data3
    #field byte Data4 8
#endstruct

#defstruct global UNCOMPRESSEDAUDIOFORMAT
    #field GUID guidFormatType
    #field int dwSamplesPerFrame
    #field int dwBytesPerSampleContainer
    #field int dwValidBitsPerSample
    #field float fFramesPerSecond
    #field int dwChannelMask
#endstruct

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