CRI ADX  Last Updated: 2024-07-17 10:48 p
多声道播放

示例目录

/cri/pc/samples/criatomex/playback_multi_ch


示例描述

创建Voice池时指定Voice可输出的频道数量。


预设情况下,Voice池创建参数(::CriAtomExHcaVoicePoolConfig )生成与双频道(立体声)输出相对应的Voice。
例如,在播放5.1ch(6ch)的Cue时需要更改此设置。
设置Voice可输出的频道数量的代码如下。
CriAtomExVoicePoolHn hcavoice_pool;
/* 使用预设值初始化Voice池创建参数 */
/* 更改可播放频道数量 */
vp_config.player_config.max_channels = 6;
/* 传递更改后的句柄创建参数并创建Voice池 */
hcavoice_pool = criAtomExVoicePool_AllocateHcaVoicePool(&vp_config, NULL, 0);
/* 创建Player */
player = criAtomExPlayer_Create(NULL, NULL, 0);
/* 指定Cue ID */
criAtomExPlayer_SetCueId(player, acb_hn, CRI_ATOMCUESHEET__6CH);
/* 开始播放 */
CriAtomExAcbObj * CriAtomExAcbHn
ACB handle
Definition: cri_le_atom_ex.h:3033
CriAtomExPlaybackId criAtomExPlayer_Start(CriAtomExPlayerHn player)
Start the playback
CriAtomExPlayerObj * CriAtomExPlayerHn
Player handle
Definition: cri_le_atom_ex.h:3622
CriAtomExPlayerHn criAtomExPlayer_Create(const CriAtomExPlayerConfig *config, void *work, CriSint32 work_size)
Create an AtomEx player
void criAtomExPlayer_SetCueId(CriAtomExPlayerHn player, CriAtomExAcbHn acb_hn, CriAtomExCueId id)
Set the sound data to play (specifying a Cue ID)
#define criAtomExVoicePool_SetDefaultConfigForHcaVoicePool(p_config)
Assign the default values to the configuration structure used to create an HCA Voice Pool
Definition: cri_le_atom_ex.h:600
struct CriAtomExVoicePoolTag * CriAtomExVoicePoolHn
Voice Pool handle
Definition: cri_le_atom_ex.h:3220
CriAtomExVoicePoolHn criAtomExVoicePool_AllocateHcaVoicePool(const CriAtomExHcaVoicePoolConfig *config, void *work, CriSint32 work_size)
Create an HCA Voice Pool
Configuration structure used when creating a HCA Voice Pool
Definition: cri_le_atom_ex.h:3299
CriAtomHcaPlayerConfig player_config
Definition: cri_le_atom_ex.h:3302
CriSint32 max_channels
Maximum number of output channels
Definition: cri_le_atom.h:1728


随着频道数量增多,Voice池使用的工作区大小也会増加。
通过分开创建用于多声道的Voice池和用于播放立体声的Cue的Voice池,使工作区域大小的消费不会太大。


此外,上面的代码是关于HCA Voice池的示例, 如果要支持ADX,只需将“HCA”更改为“ADX”即可。


示例使用的数据中AtomCraft项目的目录

/cri/tools/criatomex/examples/tutorial_data_for_runtime