CRI ADX  Last Updated: 2024-07-17 10:47 p
User PCM output

Samples Directory

/CRIWARE/SDK/pc/samples/criatomex/user_pcm_output


Sample Description

When executing the criAtomEx_Initialize_PC function, the Atom library internally initializes XAudio2 and uses it as sound output.
By contrast, when using the criAtomEx_InitializeForUserPcmOutput_PC function for the library initialization, the Atom library does not perform the XAudio2 initialization.
(That means the sound output processing is not done within the Atom library.)
When initializing the library with the criAtomEx_InitializeForUserPcmOutput_PC function, the sound output processing should be done on the application side.
Specifically, PCM data is retrieved from the library by the criAtomExAsr_GetPcmDataFloat32 function and the sound output processing is done on the application side.

Specific code is shown below:

/* Main processing */
main
{
:
/* Initialize the library for user PCM output */
:
}
/* Sound output thread processing */
static CriUint32 user_sound_output_func(
void *obj, CriUint32 nch, CriFloat32 *sample[], CriUint32 nsmpl)
{
:
/* Get PCM data */
num_written = criAtomExAsr_GetPcmDataFloat32(nch, nsmpl, sample);
/* Output the PCM data */
:
}
CriSint32 criAtomExAsr_GetPcmDataFloat32(CriSint32 output_channels, CriSint32 output_samples, CriFloat32 *output_buffer[])
Get the PCM data.
#define criAtomEx_InitializeForUserPcmOutput_PC(config, work, work_size)
Initialize the user PCM output library.
Definition: cri_le_atom_pc.h:543


[Remarks]
The library must be finalized by the criAtomEx_FinalizeForUserPcmOutput_PC function when initializing with the criAtomEx_InitializeForUserPcmOutput_PC function.

Attention
The calling to the criAtomExAsr_GetPcmDataFloat32 function should be performed periodically on a separate thread.
Currently, there are some functions in the Atom libray that do not relinquish the process until PCM data is output. (e.g. voice pool destruction process)
If calling this type of function and the criAtomExAsr_GetPcmDataFloat32 function in order on the same thread, the function may wait for completion of PCM data output eternally.