CRI ADX  Last Updated: 2024-07-17 10:48 p
简单播放

示例目录

/cri/pc/samples/criatomex/simple_playback


示例描述
下面介绍将编码工作控制在最小限度,只播放One Shot的音频数据的方法。
CriAtomExPlayerStatus player_status;
/* 注册自定义的内存分配函数 */
criAtomEx_SetUserAllocator(user_alloc, user_free, NULL);
/* 初始化程序库 */
criAtomEx_Initialize(NULL, 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);
/* 创建Voice池 */
voice_pool = criAtomExVoicePool_AllocateAdxVoicePool(NULL, NULL, 0);
/* 创建Player */
player = criAtomExPlayer_Create(NULL, NULL, 0);
/* 指定Cue ID */
criAtomExPlayer_SetCueId(player, acb_hn, CRI_ATOMCUESHEET_BOMB2);
/* 开始播放 */
/* 主循环 */
for(;;) {
/* V同步等待 */
criFwSys_WaitVsync();
/* 执行Server处理 */
/* 获取Player的状态 */
player_status = criAtomExPlayer_GetStatus(player);
if (player_status == CRIATOMEXPLAYER_STATUS_PLAYEND) {
break;
}
}
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
void criAtomEx_ExecuteMain(void)
Execute the server processing
CriBool criAtomEx_RegisterAcfFile(CriFsBinderHn binder, const CriChar8 *path, void *work, CriSint32 work_size)
Register an ACF file
#define criAtomEx_SetUserAllocator(p_malloc_func, p_free_func, p_obj)
Register a custom memory allocator
Definition: cri_le_atom_ex.h:309
CriAtomExPlayerStatus criAtomExPlayer_GetStatus(CriAtomExPlayerHn player)
Get the player status
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)
enum CriAtomExPlayerStatusTag CriAtomExPlayerStatus
Player status
@ CRIATOMEXPLAYER_STATUS_PLAYEND
Definition: cri_le_atom_ex.h:3670
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


通过使用::criAtomEx_SetUserAllocator函数注册内存分配函数, 可以在需要工作区的模块初始化和创建句柄处理中省略指定工作区。


关于详细信息,请参照教程“Cue Playback (Memory) ”。


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

/cri/tools/criatomex/examples/tutorial_data_for_runtime