# AudioFrame (/zh-CN/api-reference/rtc/csharp-windows/class-audioframe)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

<a id="class_audioframe__prototype"></a>

```csharp
public class AudioFrame
    {
        public AudioFrame()
        {
            type = AUDIO_FRAME_TYPE.FRAME_TYPE_PCM16;
            samplesPerChannel = 0;
            bytesPerSample = BYTES_PER_SAMPLE.TWO_BYTES_PER_SAMPLE;
            channels = 0;
            samplesPerSec = 0;
            RawBuffer = new byte[0];
            renderTimeMs = 0;
            avsync_type = 0;
        }

        public AudioFrame(AUDIO_FRAME_TYPE type, int samplesPerChannel, BYTES_PER_SAMPLE bytesPerSample, int channels, int samplesPerSec,
            byte[] buffer, long renderTimeMs, int avsync_type)
        {
            this.type = type;
            this.samplesPerChannel = samplesPerChannel;
            this.bytesPerSample = bytesPerSample;
            this.channels = channels;
            this.samplesPerSec = samplesPerSec;
            this.RawBuffer = buffer;
            this.renderTimeMs = renderTimeMs;
            this.avsync_type = avsync_type;
        }

        public AUDIO_FRAME_TYPE type { set; get; }
        public int samplesPerChannel { set; get; }
        public BYTES_PER_SAMPLE bytesPerSample { set; get; }
        public int channels { set; get; }
        public int samplesPerSec { set; get; }
        public byte[] RawBuffer { set; get; }
        public long renderTimeMs { set; get; }
        public int avsync_type { set; get; }
    }
```

<a id="class_audioframe__parameters"></a>

## 属性 [#属性]

<ParameterList>
<a id="type"></a>
<Parameter name="type">

音频帧类型，详见 [AUDIO_FRAME_TYPE](/zh-CN/api-reference/rtc/csharp-windows/enum-audioframetype)。

</Parameter>
<a id="samplesperchannel"></a>
<Parameter name="samplesPerChannel">

每个声道的采样点数。

</Parameter>
<a id="bytespersample"></a>
<Parameter name="bytesPerSample">

每个采样点的字节数。对于 PCM 来说，一般使用 16 bit，即两个字节。

</Parameter>
<a id="channels"></a>
<Parameter name="channels">

声道数量(如果是立体声，数据是交叉的)。

<a id="class_audioframe__ul_zxz_2wt_r4b"></a>

- 1: 单声道
- 2: 双声道

</Parameter>
<a id="samplespersec"></a>
<Parameter name="samplesPerSec">

每声道每秒的采样点数。

</Parameter>
<a id="rawbuffer"></a>
<Parameter name="RawBuffer">

声音数据缓存区（如果是立体声，数据是交叉存储的）。

缓存区数据大小 `buffer` = `samples` × `channels` × `bytesPerSample`。

</Parameter>
<a id="rendertimems"></a>
<Parameter name="renderTimeMs">

外部音频帧的渲染时间戳。

你可以使用该时间戳还原音频帧顺序；在有视频的场景中（包含使用外部视频源的场景），该参数可以用于实现音视频同步。

</Parameter>
<a id="avsync_type"></a>
<Parameter name="avsync_type">

保留参数。

</Parameter>
</ParameterList>
