CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
CriAtomExOutputAnalyzer Class Reference

Sound output data analysis module (for each player/source/bus) More...

Inheritance diagram for CriAtomExOutputAnalyzer:
CriAtomExPlayerOutputAnalyzer

Classes

struct  Config
 Sound output data analysis module config structure More...
 

Public Member Functions

delegate void PcmCaptureCallback (float[] dataL, float[] dataR, int numChannels, int numData)
 Waveform acquisition callback More...
 
 CriAtomExOutputAnalyzer (Config config)
 Creates a sound output data analysis module More...
 
override void Dispose ()
 Discards the output data analysis module More...
 
bool AttachExPlayer (CriAtomExPlayer player)
 Attaching the AtomExPlayer More...
 
void DetachExPlayer ()
 Detaches the AtomExPlayer More...
 
bool AttachDspBus (string busName)
 Attaching the DSP bus More...
 
void DetachDspBus ()
 Detaches the DSP bus More...
 
float GetRms (int channel)
 Gets the RMS level of sound output being attached More...
 
void GetSpectrumLevels (ref float[] levels)
 Gets the spectrum analysis result More...
 
void GetPcmData (ref float[] data, int ch)
 Gets the waveform data of the sound output being attached More...
 
void SetPcmCaptureCallback (PcmCaptureCallback callback)
 Registers the waveform data acquisition callback More...
 
void ExecutePcmCaptureCallback ()
 Calls the waveform data acquisition callback More...
 
void ExecutePcmCaptureCallback (PcmCaptureCallback callback)
 

Public Attributes

const int MaximumSpectrumBands = 512
 Maximum number of spectrum analyzer bands More...
 

Detailed Description

Sound output data analysis module (for each player/source/bus)

Description:
Performs sound output analysis for each CriAtomSource/CriAtomExPlayer or for each bus.
Provides features such as Level Meter.
Note:
When attached to CriAtomSource/CriAtomExPlayer, analysis is not possible when HCA-MX or platform-specific sound compression codec is used.
Use HCA or ADX codecs.

Constructor & Destructor Documentation

CriAtomExOutputAnalyzer ( Config  config)
inline

Creates a sound output data analysis module

Returns
Sound output data analysis module
Description:
Create an output Voice data analysis module.
Use the analysis module you created by attaching it to a CriAtomSource, CriAtomExPlayer, or bus.
Perform analysis of the level meter etc. on the attached audio output.
// 解析モジュールの作成例
// コンフィグでSpectrumAnalyzerを有効にし、バンド数を指定
CriAtomExOutputAnalyzer.Config config = new CriAtomExOutputAnalyzer.Config();
config.enableSpectrumAnalyzer = true;
config.numSpectrumAnalyzerBands = 16;
// 出力データ解析モジュールを作成
this.analyzer = new CriAtomExOutputAnalyzer(config);
Note:
Only one CriAtomSource/CriAtomExPlayer/ bus can be attached to the analysis module.
If you want to reuse the analysis module, detach it.
Note:
Unmanaged resources are reserved when creating a sound output data analysis module.
When you no longer need the analysis module, be sure to call the CriAtomExOutputAnalyzer.Dispose method.

Member Function Documentation

delegate void PcmCaptureCallback ( float[]  dataL,
float[]  dataR,
int  numChannels,
int  numData 
)

Waveform acquisition callback

Description:
A callback for acquiring the output waveform data.
override void Dispose ( )
inline

Discards the output data analysis module

Description:
Discards the output data analysis module.
At the time of calling this function, all the resources allocated in the plug-in when creating the output data analysis module are released.
To prevent memory leak, call this method when the output data analysis module is no longer required.
Note:
This function is a return-on-complete function.
If there are any attached AtomExPlayers, they are detached in this function.
Note that the sounds being played by the target AtomExPlayers are forcibly stopped.
See also
CriAtomExOutputAnalyzer::CriAtomExOutputAnalyzer
bool AttachExPlayer ( CriAtomExPlayer  player)
inline

Attaching the AtomExPlayer

Returns
Whether the attach was successful (success: True, failure: False)
Description:
Attaches the AtomExPlayer that analyzes the output data.
It is not possible to attach multiple AtomExPlayers. If you attach another AtomExPlayer while one is attached, the attached AtomExPlayer is detached.

To attach CriAtomSource, use CriAtomSource::AttachToOutputAnalyzer.
Note:
Attachment must be done before starting playback. Attachment fails after starting playback.

If you discard the AtomExPlayer attached using this function before detaching it, an access violation occurs at the time of detachment.
Be sure to first detach the AtomExPlayer before discarding it.
See also
CriAtomExOutputAnalyzer::DetachExPlayer, CriAtomSource::AttachToOutputAnalyzer
void DetachExPlayer ( )
inline

Detaches the AtomExPlayer

Description:
Detaches the AtomExPlayer that analyzes the output data.
After detaching, the subsequent analysis will not be done.
Note:
If this function is called while the player already attached is playing a sound, the playback is forcibly stopped before detaching.

An access violation occurs if the attached AtomExPlayer has already been discarded.
Be sure to call this function or CriAtomExOutputAnalyzer::Dispose before discarding the AtomExPlayer.
See also
CriAtomExOutputAnalyzer::AttachExPlayer, CriAtomExOutputAnalyzer::Dispose
bool AttachDspBus ( string  busName)
inline

Attaching the DSP bus

Returns
Whether the attach was successful (success: True, failure: False)
Description:
Attach a DSP bus for output data analysis.
It is not possible to attach multiple DSP buses. If you attach another DSP bus while one is attached, the attached DSP bus is detached.
See also
CriAtomExOutputAnalyzer::DetachDspBus
void DetachDspBus ( )
inline

Detaches the DSP bus

Description:
Detach a DSP bus for output data analysis.
After detaching, the subsequent analysis will not be done.
See also
CriAtomExOutputAnalyzer::AttachDspBus, CriAtomExOutputAnalyzer::Dispose
float GetRms ( int  channel)
inline

Gets the RMS level of sound output being attached

Parameters
channelChannel number
Returns
RMS level
Description:
Gets the RMS level of sound output being attached.
When using this function, create a module setting enableLevelmeter to True in Config.
See also
CriAtomExOutputAnalyzer::AttachExPlayer, CriAtomExOutputAnalyzer::AttachDspBus
void GetSpectrumLevels ( ref float[]  levels)
inline

Gets the spectrum analysis result

Parameters
levelsAnalysis result (amplitude of each band)
Description:
Gets the amplitude for each band analyzed by the spectrum analyzer.
The number of elements in the array is the number of bands specified when the module was created.
When using this function, create a module setting enableSpectrumAnalyzer to True and a numSpectrumAnalyzerBands to a positive number equal to or smaller than MaximumSpectrumBands in Config. If you want to display the analysis result like a commercial spectrum analyzer, you need to convert the value returned by this function into a decibel value.
Example:
// 例:スペクトル解析結果を取得するコンポーネント
public class SpectrumLevelMeter : MonoBehaviour {
private CriAtomExOutputAnalyzer analyzer;
void Start() {
// 引数 config については省略。モジュールの作成時に指定したバンド数は 8 とする
this.analyzer = new CriAtomExOutputAnalyzer(config);
// CriAtomExPlayer のアタッチについては省略
}
void Update() {
// 音声再生中の実行
float[] levels = new float[8];
analyzer.GetSpectrumLevels (ref levels);
// levelsの0帯域目の振幅値をデシベル値に変換
float db = 20.0f * Mathf.Log10(levels[0]);
Debug.Log (db);
}
}
See also
CriAtomExOutputAnalyzer::AttachExPlayer, CriAtomExOutputAnalyzer::AttachDspBus
void GetPcmData ( ref float[]  data,
int  ch 
)
inline

Gets the waveform data of the sound output being attached

Parameters
dataOutput data
chChannel
Description:
Gets the waveform data of the sound output being attached.
When using this function, create a module by setting enablePcmCapture to True and a numCapturedPcmSamples to a positive number in Config.
Note:
If the argument array is not long enough, it is allocated in the function.
To avoid unnecessary GC, pass an array with a length longer than the number of data samples specified in the initialization config as an argument. Currently, the only channels that can be acquired are L/R. For ch, specify 0 or 1.
See also
CriAtomExOutputAnalyzer::AttachExPlayer, CriAtomExOutputAnalyzer::AttachDspBus
void SetPcmCaptureCallback ( PcmCaptureCallback  callback)
inline

Registers the waveform data acquisition callback

Description:
Register the callback for acquiring output data.
When using callback for acquiring the waveform data, register the callback using this function before calling ExecutePcmCaptureCallback.
void ExecutePcmCaptureCallback ( )
inline

Calls the waveform data acquisition callback

Description:
Call the callback for acquiring the output data.
When this function is called, the callback is called multiple times with the output difference data from the last execution as an argument.
Note:
When using a callback for getting the waveform data, call this function regularly.
If this function is not called for a long time, there may be a loss of acquired waveform data.
void ExecutePcmCaptureCallback ( PcmCaptureCallback  callback)
inline
Deprecated:
This is a deprecated API that will be removed. Please consider using SetPcmCaptureCallback(PcmCaptureCallback) and ExecutePcmCaptureCallback() instead.

Member Data Documentation

const int MaximumSpectrumBands = 512

Maximum number of spectrum analyzer bands

Description:
Maximum number of bands that the spectrum analyzer can output.

The documentation for this class was generated from the following file: