CRI ADX  Last Updated: 2025-05-07 13:34 p
Voice priority

Sample directory

/cri/pc/samples/criatomex/control_priority

Data used in the sample

/cri/common/smpdata/criatomex/
  • music_tr.adx
  • music_loop.adx

Sample description

In CRI Atom, the voice that actually processes the sound and the player that controls the playback are separate, so if multiple players are performing playback processing when there are few voices, the players will compete for the voices.


  • Setting priority
    To set which player should be given priority when there are not enough voices, use the criAtomExPlayer_SetVoicePriority function.

  • Setting the voice control method (first come first served/last come first served)
    When the priorities are the same, use the criAtomExPlayer_SetVoiceControlMethod function to set whether to give priority to the player who started playing first or the player who started playing last.
#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.
Configuration structure used when creating an ADX Voice Pool.
Definition: cri_le_atom_ex.h:3277
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
CriSint32 num_voices
Definition: cri_le_atom_ex.h:3257
CriAtomStandardPlayerConfig player_config
Definition: cri_le_atom_ex.h:3258
CriBool streaming_flag
Whether to perform streaming playback.
Definition: cri_le_atom.h:1484


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.)