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

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

Inheritance diagram for CriAtomExPlayerOutputAnalyzer:
CriAtomExOutputAnalyzer

Classes

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

Public Types

enum  Type { LevelMeter = 0, SpectrumAnalyzer = 1, PcmCapture = 2 }
 Analysis processing type More...
 

Public Member Functions

 CriAtomExPlayerOutputAnalyzer (Type[] types, Config[] configs=null)
 Creates a sound output data analysis module More...
 
delegate void PcmCaptureCallback (float[] dataL, float[] dataR, int numChannels, int numData)
 Waveform acquisition callback 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)

Deprecated:
削除予定の非推奨APIです。 CriWare.CriAtomExOutputAnalyzer クラスの使用を検討してください。
Description:
Performs sound output analysis for each CriAtomSource/CriAtomExPlayer.
Provides features such as Level Meter.
Note:
This class is discontinued in the future. Use CriWare.CriAtomExOutputAnalyzer .
Analysis is not possible when using HCA-MX or a platform-specific sound compression codec.
Use HCA or ADX codecs.

Member Enumeration Documentation

enum Type
strong

Analysis processing type

Description:
A value indicating the type of analysis specified when creating the analysis module.
See also
CriAtomExOutputAnalyzer
Enumerator
LevelMeter 

Level Meter (RMS level measurement)

SpectrumAnalyzer 

Spectrum analyzer

PcmCapture 

Gets the waveform data

Constructor & Destructor Documentation

CriAtomExPlayerOutputAnalyzer ( Type[]  types,
Config[]  configs = null 
)
inline

Creates a sound output data analysis module

Returns
Sound output data analysis module
Description:
Creates an output sound data analysis module for CriAtomSource/CriAtomExPlayer.
You use the analysis module you created by attaching it to CriAtomSource or CriAtomExPlayer.
You perform analysis on the attached sound output such as a Level Meter.
Note:
Only one CriAtomSource/CriAtomExPlayer can be attached to the analysis module.
If you want to reuse the analysis module, detach it.
Note:
This class is discontinued in the future. Use CriAtomExOutputAnalyzer .
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 CriAtomExPlayerOutputAnalyzer.Dispose method.

Member Function Documentation

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

Waveform acquisition callback

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

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)
inlineinherited

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 ( )
inlineinherited

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)
inlineinherited

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 ( )
inlineinherited

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)
inlineinherited

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)
inlineinherited

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 
)
inlineinherited

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)
inlineinherited

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 ( )
inlineinherited

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)
inlineinherited
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
inherited

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: