CRI ADX  Last Updated: 2024-07-17 10:47 p
Playing Back Large Amount of Voices

Samples Directory

/CRIWARE/SDK/pc/samples/criatomex/playback_many_voices


Sample Description

In CRI Atom, a player can play back large amount of Voices.

Maximum number of Voices is passed to the library initialization function criAtomEx_Initialize as max_virtual_voices member of CriAtomExConfig structure.
You set larger values (100 when you want to play back 100 Voices) to this member.

#define SMP_NUM_VOICE (100)
CriAtomExConfig atomex_config;
/* Initialize the library setting with default value */
criAtomEx_SetDefaultConfig(&atomex_config);
/* Set the number of virtual voices */
atomex_config.max_virtual_voices = SMP_NUM_VOICE;
/* Initialize the library */
criAtomEx_Initialize(&atomex_config, NULL, 0);
/* Read and register ACF file */
criAtomEx_RegisterAcfFile(NULL, PATH ACF_FILE, NULL, 0);
/* Load an ACB file and create an ACB handle */
acb_hn = criAtomExAcb_LoadAcbFile(NULL, PATH ACB_FILE, NULL, PATH AWB_FILE, NULL, 0);
/* Create an ADX Voice Pool */
/* Set the number of Voices */
adxvp_config.num_voices = SMP_NUM_VOICE;
/* Create Voice Pool */
voice_pool = criAtomExVoicePool_AllocateAdxVoicePool(&adxvp_config, NULL, 0);
/* Create a player */
player = criAtomExPlayer_Create(NULL, NULL, 0);
/* Set Cue ID */
criAtomExPlayer_SetCueId(player, acb_hn, CRI_ATOMCUESHEET_THUNDER1);
/* Start playback */
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


When the criAtomExPlayer_Start function is called, sound is played back using Voices one after the other.
When Voices are exhausted, oldest Voice is stopped and is reused.

Since the maximum number of Voices is fixed, it is possible to limit the CPU load within certain range regardless of the content of the data.