CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
Seamless concatenated playback

Sample description

Overview

This is a sample script that uses seamless concatenated playback.

cri4u_samples_criatom_script08_main.png

How to use

When you press the [Play Cue] button, the specified Cue will be concatenated and played back.
When you press the [Play Data] button, the sine waveform created by the script will be concatenated playback.

After pressing the Play button for each of the above, click the [Stop] button to stop the audio output.

Scene Information


Middleware CRI ADX (CRI Atom)
Sample Script Sample: Seamless concatenated playback
Location /CRIWARE/SDK/unity/samples/UnityProject/Assets/Scenes/criatom/script/ScriptSample08_SeamlessSequencePlayback/Scenes
Scene File ScriptSample08_SeamlessSequencePlayback.unity
Original ADX data Data: Pinball


Program description

This is a sample script that performs continuous audio playback using seamless concatenated playback.
You can continuously play PCM data seamlessly in the Cue or memory.
In this sample, CriAtomExPlayer corresponding to each playback format is used for playback.

Seamless concatenated playback script

Playback using the seamless concatenated playback function of CriAtomExPlayer.

The steps to perform seamless concatenated playback are as follows:

  1. Create a concatenated playback Entry Pool for the Player.
    • Created by CriAtomExPlayer.PrepareEntryPool.
    • We recommend that you set a relatively large number for data input.
    • (For PCM data) You need to create a dedicated Voice Pool with CriAtomExRawPcmVoicePool and associate it with the Player using CriAtomExPlayer.SetVoicePoolIdentifier.
      -(For PCM data) Also, be sure to specify the audio format to be played by CriAtomExPlayer.SetFormat.
  2. Input sufficient audio data to CriAtomExPlayer before playing audio.
    -The next data is requested immediately after calling CriAtomExPlayer.Start, so it must be input before calling Start.
    • (For Cue) At this time, the first Cue is input by CriAtomExPlayer.SetCue, and the coming data will be input by CriAtomExPlayer.EntryCue.
    • (For PCM data) At this time, the first Cue is input by CriAtomExPlayer.SetData, and the coming data will be input by CriAtomExPlayer.EntryData.

  3. During seamless concatenated playback, additional data will be supplied at an appropriate timing.
    -(For Cue) Depending on the length of the input Cue, if there is sufficient data length in Cue playback, it will be added with CriAtomExPlayer.EntryCue when the entry is empty.
    -(For PCM data) Two buffers may be consumed at one time depending on the application frame rate and the Atom server processing, thus input it with a margin before it becomes empty.

Attention
All the waveform data formats used for seamless concatenated playback have to be the same.
Specifically, the following parameters must be the same:
  • Codecs
  • Number of channels
  • Sampling rate
If you try to connect waveforms with different parameters, problems such as audio data being played back at an unintended speed and error callbacks will occur.