void Update() { float freq = minWaveFrequency + Mathf.Abs(Mathf.Sin(Time.time / 5.3f)) * (maxWaveFrequency - minWaveFrequency); float gain = minWaveGain + Mathf.Abs(Mathf.Cos(Time.time / 3.4f)) * (maxWaveGain - minWaveGain); pd.SetFloatParameter(Hv_waves_AudioLib.Parameter.Frequency, freq); pd.SetFloatParameter(Hv_waves_AudioLib.Parameter.Gain, gain); }
private IEnumerator LerpWaveSpeed(float old, float current) { while (timer2 <= lerpTime) { float curBoatSpeed = Mathf.Lerp(old, current, timer2 / lerpTime); waves.SetFloatParameter(Hv_waves_AudioLib.Parameter.Wavespeed, curBoatSpeed * 5); waves.SetFloatParameter(Hv_waves_AudioLib.Parameter.Volume, curBoatSpeed); yield return(null); timer2 += Time.deltaTime; } timer2 = 0; }
public override void OnInspectorGUI() { bool isEnabled = _dsp.IsInstantiated(); if (!isEnabled) { EditorGUILayout.LabelField("Press Play!", EditorStyles.centeredGreyMiniLabel); } // events GUI.enabled = isEnabled; EditorGUILayout.Space(); // turnon if (GUILayout.Button("turnon")) { _dsp.SendEvent(Hv_waves_AudioLib.Event.Turnon); } GUILayout.EndVertical(); // parameters GUI.enabled = true; GUILayout.BeginVertical(); EditorGUILayout.Space(); EditorGUI.indentLevel++; // volume GUILayout.BeginHorizontal(); float volume = _dsp.GetFloatParameter(Hv_waves_AudioLib.Parameter.Volume); float newVolume = EditorGUILayout.Slider("volume", volume, 10.0f, 100.0f); if (volume != newVolume) { _dsp.SetFloatParameter(Hv_waves_AudioLib.Parameter.Volume, newVolume); } GUILayout.EndHorizontal(); // wavespeed GUILayout.BeginHorizontal(); float wavespeed = _dsp.GetFloatParameter(Hv_waves_AudioLib.Parameter.Wavespeed); float newWavespeed = EditorGUILayout.Slider("wavespeed", wavespeed, 10.0f, 100.0f); if (wavespeed != newWavespeed) { _dsp.SetFloatParameter(Hv_waves_AudioLib.Parameter.Wavespeed, newWavespeed); } GUILayout.EndHorizontal(); EditorGUI.indentLevel--; }
public override void OnInspectorGUI() { bool isEnabled = _dsp.IsInstantiated(); if (!isEnabled) { EditorGUILayout.LabelField("Press Play!", EditorStyles.centeredGreyMiniLabel); } GUILayout.BeginVertical(); // PARAMETERS GUI.enabled = true; EditorGUILayout.Space(); EditorGUI.indentLevel++; // frequency GUILayout.BeginHorizontal(); float frequency = _dsp.GetFloatParameter(Hv_waves_AudioLib.Parameter.Frequency); float newFrequency = EditorGUILayout.Slider("frequency", frequency, 50.0f, 4000.0f); if (frequency != newFrequency) { _dsp.SetFloatParameter(Hv_waves_AudioLib.Parameter.Frequency, newFrequency); } GUILayout.EndHorizontal(); // gain GUILayout.BeginHorizontal(); float gain = _dsp.GetFloatParameter(Hv_waves_AudioLib.Parameter.Gain); float newGain = EditorGUILayout.Slider("gain", gain, 0.0f, 1.0f); if (gain != newGain) { _dsp.SetFloatParameter(Hv_waves_AudioLib.Parameter.Gain, newGain); } GUILayout.EndHorizontal(); EditorGUI.indentLevel--; GUILayout.EndVertical(); }