CRI ADX  Last Updated: 2024-07-17 10:48 p
播放大量Voice

示例目录

/cri/pc/samples/criatomex/playback_many_voices


示例描述

CRI Atom可以用一个Player播放大量Voice。


可以通过传递给初始化程序库函数::criAtomEx_Initialize的 CriAtomExConfig 构件的 max_virtual_voices 成员,设置可使用的最大Voice数量。
为此成员设置较大的值(如果要发声100个Voice,则设置为100)。
#define SMP_NUM_VOICE (100)
CriAtomExConfig atomex_config;
/* 使用预设值初始化程序库设置 */
criAtomEx_SetDefaultConfig(&atomex_config);
/* 设置虚拟Voice数 */
atomex_config.max_virtual_voices = SMP_NUM_VOICE;
/* 初始化程序库 */
criAtomEx_Initialize(&atomex_config, NULL, 0);
/* 读取和注册ACF文件 */
criAtomEx_RegisterAcfFile(NULL, PATH ACF_FILE, NULL, 0);
/* 读取ACB文件,创建ACB句柄 */
acb_hn = criAtomExAcb_LoadAcbFile(NULL, PATH ACB_FILE, NULL, PATH AWB_FILE, NULL, 0);
/* 创建ADX Voice池 */
/* 设置Voice数 */
adxvp_config.num_voices = SMP_NUM_VOICE;
/* 创建Voice池 */
voice_pool = criAtomExVoicePool_AllocateAdxVoicePool(&adxvp_config, NULL, 0);
/* 创建Player */
player = criAtomExPlayer_Create(NULL, NULL, 0);
/* 指定Cue ID */
criAtomExPlayer_SetCueId(player, acb_hn, CRI_ATOMCUESHEET_THUNDER1);
/* 开始播放 */
CriAtomExAcbObj * CriAtomExAcbHn
ACB handle
Definition: cri_le_atom_ex.h:3033
CriAtomExAcbHn criAtomExAcb_LoadAcbFile(CriFsBinderHn acb_binder, const CriChar8 *acb_path, CriFsBinderHn awb_binder, const CriChar8 *awb_path, void *work, CriSint32 work_size)
Load an ACB file
CriBool criAtomEx_Initialize(const CriAtomExConfig *config, void *work, CriSint32 work_size)
Initialize the library
#define criAtomEx_SetDefaultConfig(p_config)
Assign the default values to the configuration structure used for the library's initialization.
Definition: cri_le_atom_ex.h:322
CriBool criAtomEx_RegisterAcfFile(CriFsBinderHn binder, const CriChar8 *path, void *work, CriSint32 work_size)
Register an ACF file
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_SetDefaultConfigForAdxVoicePool(p_config)
Assign the default values to the configuration structure used to create an ADX Voice Pool
Definition: cri_le_atom_ex.h:582
struct CriAtomExVoicePoolTag * CriAtomExVoicePoolHn
Voice Pool handle
Definition: cri_le_atom_ex.h:3220
CriAtomExVoicePoolHn criAtomExVoicePool_AllocateAdxVoicePool(const CriAtomExAdxVoicePoolConfig *config, void *work, CriSint32 work_size)
Create an ADX Voice Pool
Configuration structure used when creating an ADX Voice Pool
Definition: cri_le_atom_ex.h:3277
CriSint32 num_voices
Definition: cri_le_atom_ex.h:3279
Configuration structure used to initialize the Atom libraryThis structure is used to specify the beha...
Definition: cri_le_atom_ex.h:1461
CriSint32 max_virtual_voices
Maximum number of virtual voices
Definition: cri_le_atom_ex.h:1585

执行::criAtomExPlayer_Start函数时,将逐个使用Voice发声。 如果Voice不足,则按照从旧到新的顺序停止Voice,再次使用。


由于Voice上限已经确定,因此与数据创建无关, 可以将CPU负荷控制在一定范围内。


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

/cri/tools/criatomex/examples/tutorial_data_for_runtime