12-13-2018 08:10 AM
private void Update() {
if (this._voipAudioSource.clip == null) {
return;
}
this._currentUpdateTime += Time.deltaTime;
if (this._currentUpdateTime >= this._updateStep) {
this._currentUpdateTime = 0f;
this._voipAudioSource.clip.GetData(this._clipSampleData,
this._voipAudioSource.timeSamples); //I read 1024 samples, which is about 80 ms on a 44khz stereo clip, beginning at the current sample position of the clip.
this._clipLoudness = 0f;
foreach (var sample in this._clipSampleData) {
this._clipLoudness += Mathf.Abs(sample);
}
this._clipLoudness /= this._sampleDataLength; //clipLoudness is what you are looking for
DebugHelper.Log("Loudness: " + this._clipLoudness * VOIP_SCALE);
if (this._ovrAvatar != null) {
this._ovrAvatar.VoiceAmplitude = Mathf.Clamp(this._clipLoudness * VOIP_SCALE, 0f, 1f);
}
}
}private void OnAudioFilterRead(float[] data, int channels) {
this._ovrAvatar.UpdateVoiceVisualization(data);
}
12-17-2018 07:48 AM
12-20-2018 08:49 AM
digibix said:
The avatar mouth movement currently works only on Android....