CRI ADX  Last Updated: 2025-05-07 13:34 p
Controlling Volume by Tracks

Samples Directory

/cri/pc/samples/criatomex/control_track_volume

Data used in the sample

/cri/common/smpdata/criatomex/
  • InterleavedMultiTrack.hca

Sample Description

Atom library has a mechanism to handle multichannel sound data as multi-track sound data.
For example, when you play 6ch sound data, it is treated as 5.1ch sound data (data in which each channel corresponds to L, R, C, LFE, Ls, and Rs) by default.
However, by using the criAtomExPlayer_SetTrackInfo function , you can control 6ch sound data as monophonic 6 track sound data or stereo 3 track sound data.
:
/* Define the number of channels for each track */
/* Note: In this sample, 8ch sound data is treated as 2-channel 4-track data. */
const CriSint32 channels_per_track[4] = { 2, 2, 2, 2 };
:
/* Create a Voice Pool which can play back 8ch HCA data */
voice_pool_config.player_config.max_channels = 8;
app_obj->voice_pool
= criAtomExVoicePool_AllocateHcaVoicePool(&voice_pool_config, NULL, 0);
/* Create a player */
app_obj->player = criAtomExPlayer_Create(NULL, NULL, 0);
/* Set format information of the sound data to play */
/* Note: Since the data to be played back is 2-channel 4-track = 8, */
/* specify 8 to the criAtomExPlayer_SetNumChannels function. */
criAtomExPlayer_SetNumChannels(app_obj->player, 8);
criAtomExPlayer_SetSamplingRate(app_obj->player, 48000);
/* Set track information of the sound data */
/* Note: In the following code, 2-channel 4-track is specified. */
criAtomExPlayer_SetTrackInfo(app_obj->player, NUM_TRACKS, channels_per_track);
/* Set sound data */
criAtomExPlayer_SetFile(app_obj->player, NULL, PATH FILE);
/* Start playback */
criAtomExPlayer_Start(app_obj->player);
:
#define CRIATOMEX_FORMAT_HCA
Definition: cri_le_atom_ex.h:1928
void criAtomExPlayer_SetFile(CriAtomExPlayerHn player, CriFsBinderHn binder, const CriChar8 *path)
Set the sound data to play (specifying a file name)
void criAtomExPlayer_SetFormat(CriAtomExPlayerHn player, CriAtomExFormat format)
Specify the format of a sound.
CriAtomExPlaybackId criAtomExPlayer_Start(CriAtomExPlayerHn player)
Start the playback.
CriAtomExPlayerHn criAtomExPlayer_Create(const CriAtomExPlayerConfig *config, void *work, CriSint32 work_size)
Create an AtomEx player.
void criAtomExPlayer_SetNumChannels(CriAtomExPlayerHn player, CriSint32 num_channels)
Specify the number of channels of a sound.
void criAtomExPlayer_SetSamplingRate(CriAtomExPlayerHn player, CriSint32 sampling_rate)
Specify the sampling rate of a sound.
void criAtomExPlayer_SetTrackInfo(CriAtomExPlayerHn player, CriSint32 num_tracks, const CriSint32 *channels_per_track)
Set the track information.
#define criAtomExVoicePool_SetDefaultConfigForHcaVoicePool(p_config)
Assign the default values to the configuration structure used to create an HCA Voice Pool.
Definition: cri_le_atom_ex.h:600
CriAtomExVoicePoolHn criAtomExVoicePool_AllocateHcaVoicePool(const CriAtomExHcaVoicePoolConfig *config, void *work, CriSint32 work_size)
Create an HCA Voice Pool.
By using above settings, AtomEx players plays back 8ch sound data as stereo 4-track sound data.
You can control volume for each track independently using the criAtomExPlayer_SetTrackVolume function.
:
/* Mute sound other than track 2 */
criAtomExPlayer_SetTrackVolume(app_obj->player, 0, 0.0f);
criAtomExPlayer_SetTrackVolume(app_obj->player, 1, 0.0f);
criAtomExPlayer_SetTrackVolume(app_obj->player, 2, 1.0f);
criAtomExPlayer_SetTrackVolume(app_obj->player, 3, 0.0f);
criAtomExPlayer_UpdateAll(app_obj->player);
:
void criAtomExPlayer_UpdateAll(CriAtomExPlayerHn player)
Update the playback parameters (for all sounds currently playing)
void criAtomExPlayer_SetTrackVolume(CriAtomExPlayerHn player, CriSint32 track_no, CriFloat32 volume)
Set the track volume.