| ミドルウェア | CRI ADX2 (CRI Atom) |
| サンプル | Scriptサンプル:レベルメーター |
| 格納場所 | /cri/unity/samples/UnityProject/Assets/Scenes/criatom/script/ScriptSample05_LevelMeter/Scenes |
| シーンファイル | ScriptSample05_scene_LevelMeter.unity |
| ADX2データのオリジナル | データ:音楽の簡易クロスフェード |
using UnityEngine; using System.Collections; public class LevelMeter : MonoBehaviour { public int monitoredChannelId = 0; private int analyzedDspBusId = 0; private float objScaleBaseVal = 2.0f; /* This "Start()" method is called before "Update()".*/ void Start () { CriAtom.AttachDspBusSetting("DspBusSetting_0"); /* Set Bus Analayzer to use "BusAnalyzeInfo" */ CriAtom.SetBusAnalyzer(true); } /* Update the local scale value of GameObject */ void Update(){ /* Get BusAnalyzerInfo from a DSP Buss verifyed by mDspBusId*/ CriAtomExAsr.BusAnalyzerInfo lBusInfo = CriAtom.GetBusAnalyzerInfo(analyzedDspBusId); /* calculate new value of GameObject scale */ float lObjScaleNewVal = 0.1f + objScaleBaseVal * lBusInfo.peakLevels[monitoredChannelId]; Debug.Log("Channel_" + monitoredChannelId + " : " + lBusInfo.peakLevels[monitoredChannelId]); /* update local scale of 'this' game object */ this.transform.localScale = new Vector3(lObjScaleNewVal, lObjScaleNewVal, lObjScaleNewVal); } }
dB = 10.0f * log10f(level);
CriAtom.AttachDspBusSetting("DspBusSetting_0"); CriAtom.SetBusAnalyzer(true);