> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GetXmaFrameLengthInBits

> GetXmaFrameLengthInBits

# GetXmaFrameLengthInBits

指定されたフレームの `LengthInBits` フィールドを読み取ります。

## 構文

```cpp theme={null}
DWORD GetXmaFrameLengthInBits(  
         const BYTE* pPacket,  
         DWORD nBitPosition  
)  
```

### パラメーター

*pPacket*   \_In\_\
型: BYTE\*

フレームを含む XMA パケットへのポインター。

*nBitPosition*   \
型: DWORD

このパケット内のフレームのビット オフセット。

### 戻り値

型: DWORD

長さ (ビット単位)。

## 解説

以下のコード例に示すように、この関数は指定されたフレームの `LengthInBits` フィールドを読み取ります。

```cpp theme={null}

__inline DWORD GetXmaFrameLengthInBits
(
    __in_bcount(nBitPosition / 8 + 3)
    __in const BYTE* pPacket,  // Pointer to XMA packet[s] containing the frame
    DWORD nBitPosition         // Bit offset of the frame within this packet
)
{
    DWORD nRegion;
    DWORD nBytePosition = nBitPosition / 8;
    DWORD nBitOffset = nBitPosition % 8;

    if (nBitOffset < 2) // Only need to read 2 bytes (and might not be safe to read more)
    {
        nRegion = (DWORD)(pPacket[nBytePosition+0]) << 8 |
                  (DWORD)(pPacket[nBytePosition+1]);
        return (nRegion >> (1 - nBitOffset)) & 0x7FFF;  // Last 15 bits
    }
    else // Need to read 3 bytes
    {
        nRegion = (DWORD)(pPacket[nBytePosition+0]) << 16 |
                  (DWORD)(pPacket[nBytePosition+1]) << 8 |
                  (DWORD)(pPacket[nBytePosition+2]);
        return (nRegion >> (9 - nBitOffset)) & 0x7FFF;  // Last 15 bits
    }
}
```

XMA2 の詳細については、[XMA2 の概要](/build/console-features/audio/overviews/xma2-overview)を参照してください。XBOX One のオーディオ アーキテクチャの概要については、**未来のサウンド**: [XBOX One のオーディオ アーキテクチャ](/build/console-features/audio/overviews/xbox-one-audio-architecture)を参照してください。

## 要件

**ヘッダー:** xma2defs.h

**サポートされるプラットフォーム:** XBOX One ファミリ本体および XBOX Series 本体

## 関連項目

[xma2defs](/reference/audio/xma2defs/xma2defs_members)


## Related topics

- [XMA2Defs](/ja-jp/reference/audio/xma2defs/xma2defs_members.md)
- [GetXmaFrameBitPosition](/ja-jp/reference/audio/xma2defs/functions/getxmaframebitposition.md)
- [GetLastXmaFrameBitPosition](/ja-jp/reference/audio/xma2defs/functions/getlastxmaframebitposition.md)
- [GetXmaPacketFirstFrameOffsetInBits](/ja-jp/reference/audio/xma2defs/functions/getxmapacketfirstframeoffsetinbits.md)
- [GetXmaDecodePositionForSample](/ja-jp/reference/audio/xma2defs/functions/getxmadecodepositionforsample.md)
