[TOC]
# **VR应用3D音效**
## EnableVRAudio 3D音效启用
**开启3D音效**
1.接口说明
开启某个流的3D音效,前提是该流已被创建,并存在id
2.函数原型
~~~
EnableVRAudio(int id, RenderingMode mode);
~~~
* 参数说明
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| id | int | 音频流的唯一标识 |
| mode | RenderingMode | 3D音效模式 |
* RenderingMode
| 类型 | 值 |
| --- | --- |
| kStereoPanning | 0,简易3D立体声 |
| kBinauralLowQuality | 1,一阶声场3D |
| kBinauralMediumQuality | 2,二阶声场3D |
| kBinauralHighQuality | 3,三阶声场3D |
| kRoomEffectsOnly | 4,仅房间效果 |
3.示例代码
~~~
client.EnableVRAudio(id, RenderingMode.kBinauralHighQuality);
~~~
4.返回值
错误返回错误码,成功返回0。
## EnableNormalStereoAudio 3D切换为普通流
**将3D音效流变为普通流**
1.接口说明
将3D音频流切换为普通流,前提是该音频流已经存在
2.函数原型
~~~
int EnableNormalStereoAudio(int id);
~~~
3.示例代码
~~~
client.EnableNormalStereoAudio(id)
~~~
4.返回值
错误返回错误码,成功返回0。
## Set3DGlobal 对3D音效的房间全局设置
**3D音效的房间效果与主增益设置**
1.接口说明
针对某房间,设置3D音效是否启用房间效应,以及该房间内所有声源的增益
2.函数原型
~~~
int Set3DGlobal(bool bypass_roomeffect, float master_gain);
~~~
* 参数说明:
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| bypass_roomeffect | bool | true,旁路房间效果;false,开启房间效果 |
| master_gain | float | 房间主增益 |
3.示例代码
~~~
client.Set3DGlobal(true,2.0f);
~~~
4.返回值
错误返回错误码,成功返回0。
## SetSourceObject 对某声源3D音效的声源整体特性设置
**某声源3D音效设置**
1.接口说明
针对某声源,设置3D音效除位置信息外所有参数
2.函数原型
~~~
int SetRoomPropertiesType(RoomPropertiesType type,RoomProperties roomProperties);
~~~
* 参数说明:
| 参数 | 类型 | 说明 |
| --- | --- | --- |
| type | RoomPropertiesType | 房间类型,可选择 RoomPropertiesType.Generate生成自己设置参数的房间,其他Type可以不设置房间参数 |
| roomProperties | RoomProperties | 选择 RoomPropertiesType.Generate建议设置RoomProperties,其他房间类型不需要 |
3.示例代码
~~~
client.SetRoomPropertiesType(RoomPropertiesType.Small, roomProperties);
~~~
4.返回值
错误返回错误码,成功返回0。