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

Sample Directory

/cri/pc/samples/criatomex/tween

Data used in the sample

/cri/common/smpdata/criatomex/
  • SampleProject.acf
  • AtomCueSheet.acb
  • AtomCueSheet.awb

Sample Description

This is a sample that uses Tween to change the player volume and AISAC control value at a specified time.
About Tween
Tween is a module that changes a specific parameter to a desired value at a specified time.
By attaching a Tween to the AtomEx player, you can gradually change parameters such as the volume and AISAC control value over a specified time.
Setting up Tween
The parameters to be controlled by Tween are specified when creating the Tween handle.
There are two main ways to specify parameters:
  • CRIATOMEX_PARAMETER_TYPE_BASIC
  • CRIATOMEX_PARAMETER_TYPE_AISAC
To control general parameters such as volume, pan, and pitch, set parameter_type in the CriAtomExTweenConfig structure to CRIATOMEX_PARAMETER_TYPE_BASIC and specify the ID of the parameter you want to control in id.parameter_id .
To control the AISAC control value using Tween, set parameter_type in the CriAtomExTweenConfig structure to CRIATOMEX_PARAMETER_TYPE_AISAC and specify the AISAC control ID you want to control in id.aisac_control_id .
/* Create a Tween for volume operations */
tween_config.parameter_type = CRIATOMEX_PARAMETER_TYPE_BASIC;
tween_config.id.parameter_id = CRIATOMEX_PARAMETER_ID_VOLUME;
app_obj->volume_tween = criAtomExTween_Create(&tween_config, NULL, 0);
/* Create a Tween for AISAC operations */
tween_config.parameter_type = CRIATOMEX_PARAMETER_TYPE_AISAC;
tween_config.id.aisac_control_id = CRI_ATOMCUESHEET_AISACCONTROL_ANY;
app_obj->aisac_tween = criAtomExTween_Create(&tween_config, NULL, 0);
/* Attach Tween */
criAtomExPlayer_AttachTween(app_obj->player, app_obj->volume_tween);
criAtomExPlayer_AttachTween(app_obj->player, app_obj->aisac_tween);
void criAtomExPlayer_AttachTween(CriAtomExPlayerHn player, CriAtomExTweenHn tween)
Attach a Tween to a player.
@ CRIATOMEX_PARAMETER_ID_VOLUME
Definition: cri_le_atom_ex.h:4007
#define criAtomExTween_SetDefaultConfig(p_config)
Assign the default values to the configuration structure used to create a Tween.
Definition: cri_le_atom_ex.h:1162
CriAtomExTweenHn criAtomExTween_Create(const CriAtomExTweenConfig *config, void *work, CriSint32 work_size)
Create Tween.
@ CRIATOMEX_PARAMETER_TYPE_BASIC
Basic parameters.
Definition: cri_le_atom_ex.h:5024
@ CRIATOMEX_PARAMETER_TYPE_AISAC
AISAC control value.
Definition: cri_le_atom_ex.h:5031
Note:
For a list of parameters that can be operated when CRIATOMEX_PARAMETER_TYPE_BASIC is specified, see CriAtomExParameterId in the reference.
Change parameters
By setting the change time and target value in the criAtomExTween_MoveTo function, the parameters specified when creating the Tween will be changed to the target value over the specified time.
/* Instructs to change the volume value to 0 over 1000 milliseconds */
criAtomExTween_MoveTo(app_obj->volume_tween, 1000, 0.0f);
/* Instructs to change the AISAC control value to 1 over 3000 milliseconds */
criAtomExTween_MoveTo(app_obj->aisac_tween, 3000, 1.0f);
void criAtomExTween_MoveTo(CriAtomExTweenHn tween, CriUint16 time_ms, CriFloat32 value)
Smoothly change the current value of the parameter to the specified value.
Note:
After executing the criAtomExTween_MoveTo function to start changing the parameters, if you execute the criAtomExTween_MoveTo function again before the parameters reach their target values, the change from the current value to the new target value will begin smoothly.
For example, if you execute criAtomExTween_MoveTo(tween, 1000, 1.0f); and then execute criAtomExTween_MoveTo(tween, 1000, 0.0f); when the parameter value changes to 0.5, the parameter value will gradually change from 0.5 to 0.0 over 1000 milliseconds.