CRI ADX  Last Updated: 2024-07-17 10:47 p
Voice Pool ID

Samples Directory

/CRIWARE/SDK/pc/samples/criatomex/voice_pool_identifier


Sample Description

When a players plays back sound if there are multiple Voice Pools, the Voice Pool from which the player acquired a Voice depends on the situation at the time of playback.
Therefore, if multiple sounds are played back without setting a priority, it may cause unintended undesirable situations, for example, the BGM Voice stops and is replaced by a playback of an SE.
When there is a sound which you want to play back such as BGM or dialogue regardless of the situation of other sounds, you must allocate dedicated Voice Pool for these sounds.
To achieve this, Atom library provides "Voice Pool ID."
Voice Pool ID is a unique number which identifies a Voice Pool.
When you specify a Voice Pool ID when creating a Voice Pool, the Voice Pool is referenced only from players who know the ID.
Following code shows the procedure to associate a Voice Pool and a player using the Voice Pool ID.

/* Create Voice Pool 1 */
/* Set unique ID "0x1234" to the Voice Pool */
pool_config.identifier = 0x1234;
pool_config.num_voices = 4;
app_obj->voice_pool1 = criAtomExVoicePool_AllocateAdxVoicePool(&pool_config, NULL, 0);
/* Create Voice Pool 2 */
/* Set unique ID "0x5678" to the Voice Pool */
pool_config.identifier = 0x5678;
pool_config.num_voices = 4;
app_obj->voice_pool2 = criAtomExVoicePool_AllocateAdxVoicePool(&pool_config, NULL, 0);
/* Create player 1 */
app_obj->player1 = criAtomExPlayer_Create(NULL, NULL, 0);
/* Limit the Voice Pool referenced by player 1 to the Voice Pool with ID "0x1234" */
criAtomExPlayer_SetVoicePoolIdentifier(app_obj->player1, 0x1234);
/* Create player 2 */
app_obj->player2 = criAtomExPlayer_Create(NULL, NULL, 0);
/* Limit the Voice Pool referenced by player 2 to the Voice Pool with ID "0x5678" */
criAtomExPlayer_SetVoicePoolIdentifier(app_obj->player2, 0x5678);
void criAtomExPlayer_SetVoicePoolIdentifier(CriAtomExPlayerHn player, CriAtomExVoicePoolIdentifier identifier)
Specify the Voice Pool identifier.
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.


In the above sample, ID "0x1234" is set to Voice Pool 1 and ID "0x5678" is set to Voice Pool 2.
The sample uses the criAtomExPlayer_SetVoicePoolIdentifier function to instruct the player 1 to acquire Voices from the Voice Pool with ID "0x1234", so all playbacks using player 1 is performed using Voices in Voice Pool 1.
(Even if player 1 performs many playbacks, Voice is not taken off from Voice Pool 2.)
Similarly, the sample instructs the player 2 to acquire Voices from the Voice Pool with ID "0x5678", so all playbacks using player 2 is performed using Voices in Voice Pool 2.<br