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

Samples Directory

/CRIWARE/SDK/pc/samples/criatomex/control_priority

Sample Description

In CRI Atom, since Voice, which performs actual playback, and player, which controls playback, are independent, players compete for Voices when multiple players are used for playback with smaller number of Voices.

  • Setting priority
    When there are not enough voices, use the criAtomExPlayer_SetVoicePriority function to set the priority of players.

  • Setting Voice control method (first-arrival priority or last-arrival priority)
    Whether first played player or last played player is given precedence when the priorities are the same is Set by the criAtomExPlayer_SetVoiceControlMethod function.
The following is a code to set priorities to players when there are not enough Voices.

#define SMP_PATH_LENGTH (256)
CriAtomExPlayerConfig player_config;
/* Set smaller number so that competition happens */
pool_config.num_voices = 1;
/* Set streaming playback */
pool_config.player_config.streaming_flag = CRI_TRUE;
/* Create Voice Pool */
voice_pool = criAtomExVoicePool_AllocateAdxVoicePool(&pool_config, NULL, 0);
/* Set the size required for storing path */
player_config.max_path = SMP_PATH_LENGTH;
/* Create a player */
player[0] = criAtomExPlayer_Create(&player_config, NULL, 0);
player[1] = criAtomExPlayer_Create(&player_config, NULL, 0);
/* Set the file to be played back to the player*/
criAtomExPlayer_SetFile(player[0], NULL, PATH FILE1);
criAtomExPlayer_SetFile(player[1], NULL, PATH FILE2);
/* Set priorities */
criAtomExPlayer_SetVoicePriority(player[0], 1); /* Relatively high priority */
criAtomExPlayer_SetVoicePriority(player[1], 0); /* Relatively low priority */
/* First-arrival priority (the player arrived later with the same priority cannot get a Voice) */
/* Update information */
/* Start playback */
void criAtomExPlayer_SetFile(CriAtomExPlayerHn player, CriFsBinderHn binder, const CriChar8 *path)
Set the sound data to play (specifying a file name)
CriAtomExPlaybackId criAtomExPlayer_Start(CriAtomExPlayerHn player)
Start the playback.
void criAtomExPlayer_SetVoiceControlMethod(CriAtomExPlayerHn player, CriAtomExVoiceControlMethod method)
Specifying a voice control method.
CriAtomExPlayerObj * CriAtomExPlayerHn
Player handle.
Definition: cri_le_atom_ex.h:3622
void criAtomExPlayer_UpdateAll(CriAtomExPlayerHn player)
Update the playback parameters (for all sounds currently playing)
CriAtomExPlayerHn criAtomExPlayer_Create(const CriAtomExPlayerConfig *config, void *work, CriSint32 work_size)
Create an AtomEx player.
void criAtomExPlayer_SetVoicePriority(CriAtomExPlayerHn player, CriSint32 priority)
Set the priority.
#define criAtomExPlayer_SetDefaultConfig(p_config)
Assign the default values to the configuration structure used to create an AtomeEx Player.
Definition: cri_le_atom_ex.h:710
@ CRIATOMEX_PREFER_FIRST
Definition: cri_le_atom_ex.h:3685
#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.
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 when creating a player.
Definition: cri_le_atom_ex.h:3484
CriSint32 max_path
Maximum path length.
Definition: cri_le_atom_ex.h:3565


In above sample code, when player[1] is played back first and then player[0] is played back, since there is only one Voice and player[0] has high priority, player[1] stops playback and player[0] starts playback.

If their priorities are the same, because first-arrival priority is set, player[1] continues playback and player[0] does not start playback and becomes playback finished states.

For priorities when playing back Cue, application does not have to do any operations since priorities set by the tool are applied. (Currently, operation is not allowed.)