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

示例目录

/cri/pc/samples/criatomex/playback_awb


示例描述

在CRI Atom中,可以从AWB文件直接播放音频数据。
从AWB文件流播放音频数据的代码如下。
CriAtomExAdxVoicePoolConfig voice_pool_config;
CriAtomAwbHn awb_hn;
/* 创建AWB句柄 */
awb_hn = criAtomAwb_LoadToc(NULL, PATH AWB_FILE, NULL, 0);
/* 使用预设值初始化创建Voice池的参数 */
/* 由于要从AWB文件执行流播放,启用流播放 */
voice_pool_config.player_config.streaming_flag = CRI_TRUE;
/* 创建可执行流播放的Voice池 */
voice_pool = criAtomExVoicePool_AllocateAdxVoicePool(&voice_pool_config, NULL, 0);
/* 创建Player */
player = criAtomExPlayer_Create(NULL, NULL, 0);
/* 指定WaveID */
criAtomExPlayer_SetWaveId(player, awb_hn, 0);
/* 开始播放 */
CriAtomExPlaybackId criAtomExPlayer_Start(CriAtomExPlayerHn player)
Start the playback
CriAtomExPlayerObj * CriAtomExPlayerHn
Player handle
Definition: cri_le_atom_ex.h:3622
void criAtomExPlayer_SetWaveId(CriAtomExPlayerHn player, CriAtomAwbHn awb, CriAtomExWaveId id)
Set the wave data to play (specifying a wave data ID)
CriAtomExPlayerHn criAtomExPlayer_Create(const CriAtomExPlayerConfig *config, void *work, CriSint32 work_size)
Create an AtomEx player
#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
CriAtomExVoicePoolHn criAtomExVoicePool_AllocateAdxVoicePool(const CriAtomExAdxVoicePoolConfig *config, void *work, CriSint32 work_size)
Create an ADX Voice Pool
struct CriAtomAwbTag * CriAtomAwbHn
AWB handle
Definition: cri_le_atom.h:1349
CriAtomAwbHn criAtomAwb_LoadToc(CriFsBinderHn binder, const CriChar8 *path, void *work, CriSint32 work_size)
Load AWB file's TOC information (synchronous version)
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
CriAtomAdxPlayerConfig player_config
Definition: cri_le_atom_ex.h:3280


::criAtomExPlayer_SetWaveId函数的第三个参数是AWB文件中的音频数据索引。


上述代码示例表示的是流播放的情况,也可以将AWB文件读取到内存中, 使用::criAtomAwb_LoadFromMemory函数从AWB文件映像中创建AWB句柄, 执行内存播放。