CRI ADX  Last Updated: 2025-05-07 13:34 p
Cross-faded Playback

Samples Directory

/cri/pc/samples/criatomex/crossfade_playback

Data used in the sample

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

Sample Description

By attaching a "fader" to the AtomEx player, it is possible to automate time-series volume control such as fading-in, fading-out, or cross-fading.
Procedure for Fading-in
Procedure for fading-in sound (starting playback in muted state and gradually increasing the volume) is as follows:
  1. Create an AtomEx player using the criAtomExPlayer_Create function.
  2. Attach a fader to the AtomEx player using the criAtomExPlayer_AttachFader function.
  3. Specify the time to be taken by fading-in using the criAtomExPlayer_SetFadeInTime function.
  4. Set the sound data to be played back by fading-in using the criAtomExPlayer_SetCueId function.
  5. Start playback using the criAtomExPlayer_Start function.


By following the above steps, the volume of the sound played back using the criAtomExPlayer_Start function is controlled so that it increases in the time specified by the criAtomExPlayer_SetFadeInTime function.
Procedure for Fading-out
Procedure for fading-out (gradually decreasing volume and stopping playback when the sound is muted) current sound is as follows:
  1. Specify the time to be taken by fading-out using the criAtomExPlayer_SetFadeOutTime function.
  2. Stop playback using the criAtomExPlayer_Stop function.


By following the above steps, volume of the current sound is controlled so that it is muted in the time specified by the criAtomExPlayer_SetFadeOutTime function.
Procedure for Cross-fading
By calling criAtomExPlayer_Start function repeatedly while criAtomExPlayer_SetFadeInTime and criAtomExPlayer_SetFadeOutTime functions are running, the current sound fades out and the new sound fades in every time the function is called.
:
/* Create a player */
app_obj->player = criAtomExPlayer_Create(NULL, NULL, 0);
/* Attach a fader */
criAtomExPlayer_AttachFader(app_obj->player, NULL, NULL, 0);
/* Initialize fading time */
/* Note: Set cross-fading time to 3 seconds. */
app_obj->fade_time_ms = 3000;
criAtomExPlayer_SetFadeInTime(app_obj->player, app_obj->fade_time_ms);
criAtomExPlayer_SetFadeOutTime(app_obj->player, app_obj->fade_time_ms);
:
:
/* Start playback */
/* Note: Previously-played sound fades-out and new sound fades-in each time you play back. */
criAtomExPlayer_Start(app_obj->player);
:
void criAtomExPlayer_AttachFader(CriAtomExPlayerHn player, const CriAtomExFaderConfig *config, void *work, CriSint32 work_size)
Attach a fader to a player.
void criAtomExPlayer_SetFadeInTime(CriAtomExPlayerHn player, CriSint32 ms)
Set the fade-in time.
void criAtomExPlayer_SetFadeOutTime(CriAtomExPlayerHn player, CriSint32 ms)
Set the fade-out time.
CriAtomExPlaybackId criAtomExPlayer_Start(CriAtomExPlayerHn player)
Start the playback.
CriAtomExPlayerHn criAtomExPlayer_Create(const CriAtomExPlayerConfig *config, void *work, CriSint32 work_size)
Create an AtomEx player.
 
[Note]
Although the fade-in and fade-out start at the same time in the default settings, By using the criAtomExPlayer_SetFadeInStartOffset function, The timing of the fade-in and fade-out can be shifted by using the criAtomExPlayer_SetFadeInStartOffset function.
If you want the next sound to fade in after the currently playing sound has faded out, or if you want the next sound to fade in after the sound has faded out, you can use the Fade out the previous sound after the sound has faded in, etc, If you want to shift the timing of the fade-in and fade-out, Use the criAtomExPlayer_SetFadeInStartOffset function in conjunction.