CRI ADX  Last Updated: 2024-07-17 10:47 p
Playback by Specifying a File Name

Samples Directory

/CRIWARE/SDK/pc/samples/criatomex/playback_fname


Sample Description

CRI Atom supports playback by directly specifying file name.
Procedure to play sound data by specifying file name is as follows:
  1. Create D-BAS for streaming playback.
  2. Create a Voice Pool which supports streaming playback.
  3. Create an AtomEx player containing an area to store path.
  4. Specify the name of the file to be played back.
  5. Specify format information of the sound to be played back.
  6. Start playback
Specific code is as follows:

CriAtomExPlayerConfig player_config;
/* Create D-BAS */
dbas_id = criAtomDbas_Create(NULL, NULL, 0);
/* Initialize parameters for creating Voice Pool with default value */
/* Enable streaming playback because playback specifying a file name is a streaming playback */
voice_pool_config.player_config.streaming_flag = CRI_TRUE;
/* Create a Voice Pool which allows streaming playback */
voice_pool = criAtomExVoicePool_AllocateStandardVoicePool(&voice_pool_config, NULL, 0);
/* Initialize parameters for creating player with default value */
/* Specify the size of the path storage area to remember the file name to be played back */
player_config.max_path_strings = 1;
player_config.max_path = SMP_PATH_LENGTH;
/* Create a player */
player = criAtomExPlayer_Create(&player_config, NULL, 0);
/* Specify the file to be played back */
criAtomExPlayer_SetFile(player, NULL, PATH FILE);
/* Start playback */
CriAtomDbasId CriAtomExDbasId
AtomEx D-BAS ID.
Definition: cri_le_atom_ex.h:4450
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.
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.
#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
#define criAtomExVoicePool_SetDefaultConfigForStandardVoicePool(p_config)
Assign the default values to the configuration structure used to create a standard Voice Pool.
Definition: cri_le_atom_ex.h:564
CriAtomExVoicePoolHn criAtomExVoicePool_AllocateStandardVoicePool(const CriAtomExStandardVoicePoolConfig *config, void *work, CriSint32 work_size)
Create a standard Voice Pool.
struct CriAtomExVoicePoolTag * CriAtomExVoicePoolHn
Voice Pool handle.
Definition: cri_le_atom_ex.h:3220
CriAtomDbasId criAtomDbas_Create(const CriAtomDbasConfig *config, void *work, CriSint32 work_size)
Create D-BAS.
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 max_path_strings
Maximum number of path strings.
Definition: cri_le_atom_ex.h:3544
Configuration structure used when creating a standard Voice Pool.
Definition: cri_le_atom_ex.h:3255
CriAtomStandardPlayerConfig player_config
Definition: cri_le_atom_ex.h:3258
CriBool streaming_flag
Whether to perform streaming playback.
Definition: cri_le_atom.h:1484


Following are the descriptions of each operation.
Creating D-BAS
When performing streaming playback, an area to buffer data loaded from a file must allocated.
In Atom library, a mechanism called D-BAS is used to manage the amount of buffering data.
When performing streaming playback, you must create a D-BAS using the criAtomDbas_Create function.
When creating a D-BAS, you must specify the number of files loaded (played back in streaming) at a time and total bit rate of them.
(Size of the work are required for creating D-BAS depends on the maximum number of simultaneous playback and bit rate.)
[Note]
Bit rate of the sound file can be calculated using the criAtomEx_CalculateAdxBitrate function.
Creating a Voice Pool
Create a Voice required for decoding and playing sound data using functions such as the criAtomExVoicePool_AllocateStandardVoicePool function.
[Note]
A Voice Pool created using the criAtomExVoicePool_AllocateStandardVoicePool function can play back both ADX and HCA sound files.
If sound file format to be played back is limited to ADX, by using the criAtomExVoicePool_AllocateAdxVoicePool function, you can reduce the size of required work area.
Similarly, if you only want to play HCA, by using the criAtomExVoicePool_AllocateHcaVoicePool function, you can reduce the size of work area.
If the purpose is to play back sound files, you must create a Voice Pool which supports streaming playback.
You can create a Voice Pool which supports streaming playback by setting streaming_flag to CRI_TRUE in player_config in configuration structure (such as CriAtomExStandardVoicePoolConfig ) for creating Voice Pool.
Creating a Player
When performing playback by specifying a file name, AtomEx player needs an area to hold a pathname when it is created.
Size of the path storage area is determined by the following parameters in the configuration structure ( CriAtomExPlayerConfig ) for creating AtomEx player.
  • max_path_strings
  • max_path
max_path_strings indicates the number of file names an AtomEx player can hold.
To play back two or more files in one player, specify two (2) or larger value for max_path_strings.
max_path specifies maximum length of the path string used.
Specifying Path Information
Specify the path of the file to be played back using the criAtomExPlayer_SetFile function.
In addition, specify format information of the sound data to be played back using the following functions.
List of Functions to Specify Format Information
Parameter to Be Specified Function to Be Used
Format criAtomExPlayer_SetFormat
Number of channels criAtomExPlayer_SetNumChannels
Sampling rate criAtomExPlayer_SetSamplingRate
Atom library acquires a Voice which matches with the parameters specified in these APIs and decodes and plays back the sound data.
Starting Playback
Use the criAtomExPlayer_Start function to start playback.