private void UpdateMouth() { if (_lipSync) { _model.setLipSync(true); if (!AudioManager.Instance.IsPlayingDubbing) { _model.setLipSyncValue(0); } else { AudioManager.Instance.DubbingAudioSource.GetSpectrumData(_samples, 0, FFTWindow.BlackmanHarris); Array.Sort(_samples); float num = 0; for (int i = 0; i < 15; i++) { num += _samples[_samples.Length - 3 - i]; } float max = num * threshold; max = Mathf.Clamp(max, 0, 1); average.Add(max); if (average.Count > avgcount) { average.RemoveAt(0); } float c = 0; for (int i = 0; i < average.Count; i++) { c += average[i]; } max = c / average.Count; // max = Mathf.Lerp(_lastMax, max, 0.5f); _lastMax = max; _model.setLipSyncValue(max); } _model.getLive2DModel().setParamFloat(L2DStandardID.PARAM_MOUTH_OPEN_Y, _model.getLipSyncValue(), 0.8f); } }