Samples Directory
/CRIWARE/SDK/pc/samples/criatomex/seamless_playback
Sample Description
- Atom library provides a feature called "seamless concatenated playback" to concatenate and play multiple wave data.
(Generally, it is also called as "gapless playback feature.")
Using seamless concatenated playback feature, you can play back wave data without loop information in loop (playing back the same wave data repeatedly) or play back wave data divided in each part in any combination.
- Procedure to use seamless concatenated playback feature is as follows:
- Create an AtomEx player using the criAtomExPlayer_Create function.
- Register a data request callback function to the AtomEx player using the criAtomExPlayer_SetDataRequestCallback function.
- Set data to be played back first using functions such as criAtomExPlayer_SetData.
- Start playback using the criAtomExPlayer_Start function.
- Data request callback function is called when the sound data that has been set has been finished loading. Set the next data to be played back in the callback function.
- Following is a code before starting playback.
:
app_obj->player, app_data_request_callback, app_obj);
:
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_SetDataRequestCallback(CriAtomExPlayerHn player, CriAtomExPlayerDataRequestCbFunc func, void *obj)
Register the data request callback function.
void criAtomExPlayer_SetCueId(CriAtomExPlayerHn player, CriAtomExAcbHn acb_hn, CriAtomExCueId id)
Set the sound data to play (specifying a Cue ID)
- Although registering callback and setting first data is done on AtomEx player, adding data in the callback must be done by calling "Atom player" API in the lower layer (Atom layer).
- For example, if you want to perform concatenated playback on multiple on-memory data, first data is set to an AtomEx player using the criAtomExPlayer_SetData function, but when you set remaining data in the callback function, set data to the Atom player handle passed as an argument to the callback function using the criAtomPlayer_SetData function.
- [Note]
Wave data-level concatenation is done in a Voice instead of AtomEx player.
Therefore, callback for concatenated playback is called from the Atom player internally held by a Voice instead of AtomEx player.
- Note that since Atom layer does not support playing back Cue, when you want to concatenate and play back wave data in Cues, you must get AWB handles and wave data IDs from the Cues.
- Procedure to play back wave data in Cues is as follows:
- Get information about wave data contained in the Cue using the criAtomExAcb_GetWaveformInfoById function.
- Use the criAtomExAcb_GetOnMemoryAwbHandle function when the wave data is an on-memory data, or use the criAtomExAcb_GetStreamingAwbHandle function when it an streaming playback data to get AWB handle.
- Call the criAtomPlayer_SetWaveId function using the AWB handle and waveform ID.
- Specific code is as follows.
:
} else {
}
:
CriAtomAwbHn criAtomExAcb_GetOnMemoryAwbHandle(CriAtomExAcbHn acb_hn)
Get an AWB handle from an ACB handle (for in-memory playback)
CriBool criAtomExAcb_GetWaveformInfoById(CriAtomExAcbHn acb_hn, CriAtomExCueId id, CriAtomExWaveformInfo *waveform_info)
Get information about the waveform played by the Cue whose ID is given.
CriAtomAwbHn criAtomExAcb_GetStreamingAwbHandle(CriAtomExAcbHn acb_hn)
Get an AWB handle from an ACB handle (for streaming playback)
struct CriAtomAwbTag * CriAtomAwbHn
AWB handle.
Definition: cri_le_atom.h:1349
void criAtomPlayer_SetWaveId(CriAtomPlayerHn player, CriAtomAwbHn awb, CriSint32 id)
Set sound data (specify sound data ID)
- Attention
- Seamless concatenated playback concatenates one wave data contained in a Cue.
For Cues which include multiple wave data, intended result may not be achieved since any wave data in the Cue is selected and played.
When performing seamless concatenated playback using Cues, use only Cues which do not contain multiple wave data.
Note that since wave data to be concatenated is specified by waveform ID, parameters specified for Cues such as volume of panning are not applied at all.
(Parameters for first played Cue are continued to be applied.)
Wave data used for concatenated playback must have same parameters.
Specifically, following parameters must be the same.
- Codec
- Number of channels
- Sampling rate
If you attempt to concatenate waveforms with different parameters, sound data may be played back with unintended speed or error callback may occur.