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

示例目录

/cri/pc/samples/criatomex/playback_many_streaming_voices


示例描述

准备大量的流Voice,大量播放流数据。
#define SMP_NUM_VOICE (100)
CriFsConfig fs_config;
CriAtomExConfig atomex_config;
/* 使用预设值初始化CRI File System的设置参数 */
criFs_SetDefaultConfig(&fs_config);
/* 增加加载器数量(预设值+播放Voice数) */
fs_config.num_loaders = fs_config.num_loaders + SMP_NUM_VOICE;
/* 增加文件句柄数(预设值+播放Voice数) */
fs_config.max_files = fs_config.max_files + SMP_NUM_VOICE;
/* 使用预设值初始化程序库设置 */
criAtomEx_SetDefaultConfig(&atomex_config);
/* 设置虚拟Voice数 */
atomex_config.max_virtual_voices = SMP_NUM_VOICE;
/* 传递CRI File System的初始化参数 */
atomex_config.fs_config = &fs_config;
/* 初始化程序库 */
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池 */
adxvp_config.num_voices = SMP_NUM_VOICE;
adxvp_config.player_config.streaming_flag = CRI_TRUE;
voice_pool = criAtomExVoicePool_AllocateAdxVoicePool(&adxvp_config, NULL, 0);
/* 创建Player */
player = criAtomExPlayer_Create(NULL, NULL, 0);
/* 指定Cue ID */
criAtomExPlayer_SetCueId(player, acb_hn, CRI_ATOMCUESHEET_MUSIC_LOOP);
/* 开始播放 */
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
CriBool streaming_flag
Whether to perform streaming playback
Definition: cri_le_atom.h:1641
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
CriAtomAdxPlayerConfig player_config
Definition: cri_le_atom_ex.h:3280
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
const CriFsConfig * fs_config
Pointer to the CRI File System initialization parameters
Definition: cri_le_atom_ex.h:1812

CRI Atom通过CRI File System库执行文件访问, 每个流处理消耗一个加载器句柄。
也就是说,如果要用CRI Atom大量播放流数据, 则必须增加CRI File System端的加载器句柄数和文件句柄数。


在应用程序端更改CRI File System的参数设置时,请在更改::CriFsConfig构件的值后, 注册到::CriAtomExConfig构件的fs_config成员,初始化CRI Atom。


此外,由于要执行流播放,因此请在创建Voice池时将streaming_flag成员设置为CRI_TRUE。


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

/cri/tools/criatomex/examples/tutorial_data_for_runtime