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

HrtfDistanceDecay

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

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

フィールド

フィールドサイズx64x86説明
typeHrtfDistanceDecayType4+0+0距離減衰モデルの種別を示すHrtfDistanceDecayType値。
maxGainFLOAT4+4+4適用される最大ゲインをデシベルで示す。
minGainFLOAT4+8+8適用される最小ゲインをデシベルで示す。
unityGainDistanceFLOAT4+12+12ゲインが等倍となる基準距離をメートルで示す。
cutoffDistanceFLOAT4+16+16減衰計算を打ち切る最大距離をメートルで示す。

各言語での定義

#include <windows.h>

// HrtfDistanceDecay  (x64 20 / x86 20 バイト)
typedef struct HrtfDistanceDecay {
    HrtfDistanceDecayType type;
    FLOAT maxGain;
    FLOAT minGain;
    FLOAT unityGainDistance;
    FLOAT cutoffDistance;
} HrtfDistanceDecay;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct HrtfDistanceDecay
{
    public int type;
    public float maxGain;
    public float minGain;
    public float unityGainDistance;
    public float cutoffDistance;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure HrtfDistanceDecay
    Public type As Integer
    Public maxGain As Single
    Public minGain As Single
    Public unityGainDistance As Single
    Public cutoffDistance As Single
End Structure
import ctypes
from ctypes import wintypes

class HrtfDistanceDecay(ctypes.Structure):
    _fields_ = [
        ("type", ctypes.c_int),
        ("maxGain", ctypes.c_float),
        ("minGain", ctypes.c_float),
        ("unityGainDistance", ctypes.c_float),
        ("cutoffDistance", ctypes.c_float),
    ]
#[repr(C)]
pub struct HrtfDistanceDecay {
    pub type: i32,
    pub maxGain: f32,
    pub minGain: f32,
    pub unityGainDistance: f32,
    pub cutoffDistance: f32,
}
import "golang.org/x/sys/windows"

type HrtfDistanceDecay struct {
	type int32
	maxGain float32
	minGain float32
	unityGainDistance float32
	cutoffDistance float32
}
type
  HrtfDistanceDecay = record
    type: Integer;
    maxGain: Single;
    minGain: Single;
    unityGainDistance: Single;
    cutoffDistance: Single;
  end;
const HrtfDistanceDecay = extern struct {
    type: i32,
    maxGain: f32,
    minGain: f32,
    unityGainDistance: f32,
    cutoffDistance: f32,
};
type
  HrtfDistanceDecay {.bycopy.} = object
    type: int32
    maxGain: float32
    minGain: float32
    unityGainDistance: float32
    cutoffDistance: float32
struct HrtfDistanceDecay
{
    int type;
    float maxGain;
    float minGain;
    float unityGainDistance;
    float cutoffDistance;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; HrtfDistanceDecay サイズ: 20 バイト(x64)
dim st, 5    ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; type : HrtfDistanceDecayType (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; maxGain : FLOAT (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; minGain : FLOAT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; unityGainDistance : FLOAT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; cutoffDistance : FLOAT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global HrtfDistanceDecay
    #field int type
    #field float maxGain
    #field float minGain
    #field float unityGainDistance
    #field float cutoffDistance
#endstruct

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