CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
[CriAtom] Sound file playback

Description of the sample

Overview

cri4u_samples_criatom_prim01_game_mini.png

This example is a simple scene demonstrating how to play an uncompressed sound file with ADX.
It does not use any component. A script plays the sound file.

Operations

  • Playback File (MUSIC), Playback File (VOICE), and Playback File (SE) buttons
    Play the specified sound file.

  • Stop button
    Stops sound playback.

Scene information


Middleware CRI ADX (CRI Atom)
Sample Primitive sample
Location /CRIWARE/SDK/unity/samples/UnityProject/Assets/Scenes/criatom/primitive/
Scene file Scene_01_PlaybackFile.unity


Description of the program

Steps in the program

The script calls the following functions to play a sound file.
  • (1) Create a player
    this.player = new CriAtomExPlayer();

  • (2) Set the file to play
    this.player.SetFile(null, Path.Combine(CriWare.streamingAssetsPath, "sample_music.hca"));

  • (3) Set the sound format
    An HCA-encoded file is played.
    this.player.SetFormat(CriAtomEx.Format.HCA);

  • (4) Start playback
    this.player.Start();

Creating the sound files

The sound files can be created (encoded) with the command line tool provided with the SDK.
Overview of the tool


Tool name CRI Atom Encoder Console Version
Location /CRIWARE/tools/criatomex/
File name criatomencd.exe


Command format
criatomencd <input file name> <output file name> -codec=<compression codec name>

Sample usage
Encode the sample_music.wav file with the HCA codec.

criatomencd sample_music.wav sample_music.hca -codec=HCA

[Note 1]
This sample is in beta version (as of December 4, 2014).
Note that part of the API specifications may be changed in the future.
The documentation about the CriAtomExPlayer function will be published in a future release.
The Android and iOS versions will be released in the future.

[Note 2]
In this sample, the number of simultaneous playbacks of sound data is not limited. If requesting playbacks in a row, an error message may be output on the CRI library side.
In this case, the application must adjust the initialization parameters of the CRI library.
Or, the settings such as the Cue limit or the Category limit features must be applied to the CRI ADX data. By doing this, the number of simultaneous playbacks of sound data can be limited without changing application's source code.