public void DrawControl(IAudioEffectPlugin plugin) { if (loudness == null) { loudness = new AudioSignalSmoothAnalyzer(); } if (_loudnessTree == null) { _loudnessTree = PropertyTree.Create(loudness); } plugin.GetFloatParameter("Instance", out var instance); var i = GAC.ChannelMonitor_GetLoudnessData_dB((int)instance); loudness.Add(GAC.dBToNormalized(i)); var guie = GUI.enabled; GUI.enabled = true; _loudnessTree.Draw(false); _loudnessTree.ApplyChanges(); GUI.enabled = guie; }
public override bool OnGUI(IAudioEffectPlugin plugin) { float useLogScaleFloat; float showSpectrumFloat; plugin.GetFloatParameter("MasterGain", out masterGain); plugin.GetFloatParameter("LowGain", out lowGain); plugin.GetFloatParameter("MidGain", out midGain); plugin.GetFloatParameter("HighGain", out highGain); plugin.GetFloatParameter("LowFreq", out lowFreq); plugin.GetFloatParameter("HighFreq", out highFreq); plugin.GetFloatParameter("LowAttackTime", out lowAttackTime); plugin.GetFloatParameter("MidAttackTime", out midAttackTime); plugin.GetFloatParameter("HighAttackTime", out highAttackTime); plugin.GetFloatParameter("LowReleaseTime", out lowReleaseTime); plugin.GetFloatParameter("MidReleaseTime", out midReleaseTime); plugin.GetFloatParameter("HighReleaseTime", out highReleaseTime); plugin.GetFloatParameter("LowThreshold", out lowThreshold); plugin.GetFloatParameter("MidThreshold", out midThreshold); plugin.GetFloatParameter("HighThreshold", out highThreshold); plugin.GetFloatParameter("LowRatio", out lowRatio); plugin.GetFloatParameter("MidRatio", out midRatio); plugin.GetFloatParameter("HighRatio", out highRatio); plugin.GetFloatParameter("LowKnee", out lowKnee); plugin.GetFloatParameter("MidKnee", out midKnee); plugin.GetFloatParameter("HighKnee", out highKnee); plugin.GetFloatParameter("FilterOrder", out filterOrder); plugin.GetFloatParameter("UseLogScale", out useLogScaleFloat); plugin.GetFloatParameter("ShowSpectrum", out showSpectrumFloat); useLogScale = useLogScaleFloat > 0.5f; showSpectrum = showSpectrumFloat > 0.5f; GUILayout.Space(5f); Rect r = GUILayoutUtility.GetRect(200, 150, GUILayout.ExpandWidth(true)); if (DrawControl(plugin, r, plugin.GetSampleRate())) { plugin.SetFloatParameter("MasterGain", masterGain); plugin.SetFloatParameter("LowGain", lowGain); plugin.SetFloatParameter("MidGain", midGain); plugin.SetFloatParameter("HighGain", highGain); plugin.SetFloatParameter("LowFreq", lowFreq); plugin.SetFloatParameter("HighFreq", highFreq); plugin.SetFloatParameter("LowAttackTime", lowAttackTime); plugin.SetFloatParameter("MidAttackTime", midAttackTime); plugin.SetFloatParameter("HighAttackTime", highAttackTime); plugin.SetFloatParameter("LowReleaseTime", lowReleaseTime); plugin.SetFloatParameter("MidReleaseTime", midReleaseTime); plugin.SetFloatParameter("HighReleaseTime", highReleaseTime); plugin.SetFloatParameter("LowThreshold", lowThreshold); plugin.SetFloatParameter("MidThreshold", midThreshold); plugin.SetFloatParameter("HighThreshold", highThreshold); plugin.SetFloatParameter("LowRatio", lowRatio); plugin.SetFloatParameter("MidRatio", midRatio); plugin.SetFloatParameter("HighRatio", highRatio); plugin.SetFloatParameter("LowKnee", lowKnee); plugin.SetFloatParameter("MidKnee", midKnee); plugin.SetFloatParameter("HighKnee", highKnee); } return(true); }
//============================================================================== public override bool OnGUI(IAudioEffectPlugin plugin) { PluginGUIInstance guiInstance = getGUIInstanceForPlugin(ref plugin); if (!guiInstance.hasEditor) { return(true); } float[] arr; plugin.GetFloatBuffer("Size", out arr, 6); Rect r = GUILayoutUtility.GetRect(arr[0], arr[1], new GUILayoutOption[] { GUILayout.MinWidth(arr[2]), GUILayout.MinHeight(arr[3]), GUILayout.MaxWidth(arr[4]), GUILayout.MaxHeight(arr[5]) }); int controlID = GUIUtility.GetControlID(FocusType.Passive); Event currentEvent = Event.current; EventType currentEventType = currentEvent.GetTypeForControl(controlID); if (currentEventType == EventType.Repaint) { guiInstance.repaint(r); } else if (currentEvent.isMouse) { guiInstance.handleMouseEvent(currentEventType); } else if (currentEvent.isKey) { guiInstance.handleKeyEvent(currentEventType); } return(false); }
public override bool OnGUI(IAudioEffectPlugin plugin) { GUILayout.Space(5f); DrawControl(plugin); GUILayout.Space(5f); return(true); }
public override bool OnGUI(IAudioEffectPlugin plugin) { if (steamAudioManager == null) { steamAudioManager = GameObject.FindObjectOfType <SteamAudioManager>(); } if (steamAudioManager == null) { EditorGUILayout.HelpBox("A Steam Audio Manager does not exist in the scene. Click Window > Steam" + " Audio.", MessageType.Error); return(false); } if (steamAudioManager.audioEngine != AudioEngine.UnityNative) { EditorGUILayout.HelpBox("This Audio Mixer effect requires the audio engine to be set to Unity Native." + " Click Window > Steam Audio to change this.", MessageType.Error); return(false); } var binauralValue = 0.0f; plugin.GetFloatParameter("Binaural", out binauralValue); var binaural = (binauralValue == 1.0f); binaural = EditorGUILayout.Toggle("Binaural", binaural); binauralValue = (binaural) ? 1.0f : 0.0f; plugin.SetFloatParameter("Binaural", binauralValue); return(false); }
public void DrawControl(IAudioEffectPlugin plugin, Rect r, float samplerate) { r = AudioCurveRendering.BeginCurveFrame(r); if (Event.current.type == EventType.Repaint) { float blend = plugin.IsPluginEditableAndEnabled() ? 1.0f : 0.5f; int numsamples = (int)r.width; float[] imp1; plugin.GetFloatBuffer("Impulse0", out imp1, numsamples); float[] imp2; plugin.GetFloatBuffer("Impulse1", out imp2, numsamples); float wet; plugin.GetFloatParameter("Wet", out wet); wet *= 0.01f; float gain; plugin.GetFloatParameter("Gain", out gain); gain = Mathf.Pow(10.0f, gain * 0.05f); float useSample; plugin.GetFloatParameter("Use Sample", out useSample); m_Impulse1Color.a = m_Impulse2Color.a = blend; var r2 = new Rect(r.x, r.y, r.width, r.height * 0.5f); DrawCurve(r2, imp1, 1.0f, m_Impulse1Color, 90, wet, gain); r2.y += r2.height; DrawCurve(r2, imp2, 1.0f, m_Impulse2Color, 150, wet, gain); string name = "Impulse: " + Marshal.PtrToStringAnsi(ConvolutionReverb_GetSampleName((int)useSample)); GUIHelpers.DrawText(r2.x + 5, r2.y - 5, r2.width, name, Color.white); } AudioCurveRendering.EndCurveFrame(); }
public override bool OnGUI(IAudioEffectPlugin plugin) { if (SteamAudioSettings.Singleton.audioEngine != AudioEngineType.Unity) { EditorGUILayout.HelpBox( "This Audio Mixer effect requires the audio engine to be set to Unity. Click" + "Steam Audio > Settings to change this.", MessageType.Warning); return(false); } var binauralValue = 0.0f; plugin.GetFloatParameter("Binaural", out binauralValue); var binaural = (binauralValue == 1.0f); binaural = EditorGUILayout.Toggle("Apply HRTF", binaural); binauralValue = (binaural) ? 1.0f : 0.0f; plugin.SetFloatParameter("Binaural", binauralValue); return(false); }
public override bool OnGUI(IAudioEffectPlugin plugin) { float active, window, scale, mode; plugin.GetFloatParameter("Active", out active); plugin.GetFloatParameter("Window", out window); plugin.GetFloatParameter("Scale", out scale); plugin.GetFloatParameter("Mode", out mode); GUILayout.Space(5.0f); DrawControl( plugin, GUILayoutUtility.GetRect(200, scopeheight, GUILayout.ExpandWidth(true)), plugin.GetSampleRate(), 0 ); GUILayout.Space(5.0f); DrawControl( plugin, GUILayoutUtility.GetRect(200, scopeheight, GUILayout.ExpandWidth(true)), plugin.GetSampleRate(), 1 ); GUILayout.Space(5.0f); return(true); }
public override bool OnGUI(IAudioEffectPlugin plugin) { // ReSharper disable once NotAccessedVariable float active, window, scale; plugin.GetFloatParameter("Active", out active); plugin.GetFloatParameter("Window", out window); plugin.GetFloatParameter("Scale", out scale); GUILayout.Space(5.0f); var r = GUILayoutUtility.GetRect(200, 200, GUILayout.ExpandWidth(true)); if (r.width > r.height) { r.width = r.height; } else { r.height = r.width; } if (DrawControl(plugin, r, plugin.GetSampleRate())) { plugin.SetFloatParameter("Window", window); plugin.SetFloatParameter("Scale", scale); } GUILayout.Space(5.0f); return(true); }
public PluginGUIInstance(ref IAudioEffectPlugin plugin, int id) { instanceID = id; float[] arr; plugin.GetFloatBuffer("Editor", out arr, 1); hasEditor = (arr[0] > 0.0f); }
public override bool OnGUI(IAudioEffectPlugin plugin) { GUILayout.Space(5f); Rect r = GUILayoutUtility.GetRect(200, 100, GUILayout.ExpandWidth(true)); DrawControl(plugin, r, plugin.GetSampleRate()); return(true); }
public void DrawBandSplitMarker(IAudioEffectPlugin plugin, Rect r, float x, float w, bool highlight, Color color) { if (highlight) { w *= 2.0f; } EditorGUI.DrawRect(new Rect(r.x + x - w, r.y, 2 * w, r.height), color); }
public override bool OnGUI(IAudioEffectPlugin plugin) { float fval = 0.0f; bool bval = false; Separator(); Label("Global Scale (Range: 0.00001 - 10000.0f)"); plugin.GetFloatParameter("GScale", out fval); plugin.SetFloatParameter("GScale", EditorGUILayout.FloatField(" ", Mathf.Clamp(fval, 0.00001f, 10000.0f))); Separator(); // Treat these floats as bools in the inspector plugin.GetFloatParameter("E.Rflt On", out fval); bval = (fval == 0.0f) ? false : true; bval = EditorGUILayout.Toggle("Early Refl. On", bval); plugin.SetFloatParameter("E.Rflt On", (bval == false) ? 0.0f : 1.0f); plugin.GetFloatParameter("E.Rflt Rev On", out fval); bval = (fval == 0.0f) ? false : true; bval = EditorGUILayout.Toggle("Reverb On", bval); plugin.SetFloatParameter("E.Rflt Rev On", (bval == false) ? 0.0f : 1.0f); Separator(); Label("ROOM DIMENSIONS (meters)"); Label(""); plugin.GetFloatParameter("Room X", out fval); plugin.SetFloatParameter("Room X", EditorGUILayout.Slider("Room Size X", fval, 1.0f, 200.0f)); plugin.GetFloatParameter("Room Y", out fval); plugin.SetFloatParameter("Room Y", EditorGUILayout.Slider("Room Size Y", fval, 1.0f, 200.0f)); plugin.GetFloatParameter("Room Z", out fval); plugin.SetFloatParameter("Room Z", EditorGUILayout.Slider("Room Size Z", fval, 1.0f, 200.0f)); Separator(); Label("WALL REFLECTION VALUES (0-0.97)"); Label(""); plugin.GetFloatParameter("Left", out fval); plugin.SetFloatParameter("Left", EditorGUILayout.Slider("Left", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Right", out fval); plugin.SetFloatParameter("Right", EditorGUILayout.Slider("Right", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Up", out fval); plugin.SetFloatParameter("Up", EditorGUILayout.Slider("Up", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Down", out fval); plugin.SetFloatParameter("Down", EditorGUILayout.Slider("Down", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Behind", out fval); plugin.SetFloatParameter("Behind", EditorGUILayout.Slider("Behind", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Front", out fval); plugin.SetFloatParameter("Front", EditorGUILayout.Slider("Front", fval, 0.0f, 0.97f)); // We will override the controls with our own, so return false return(false); }
public override bool OnGUI(IAudioEffectPlugin plugin) { if (steamAudioManager == null) { steamAudioManager = GameObject.FindObjectOfType <SteamAudioManager>(); } if (steamAudioManager == null) { EditorGUILayout.HelpBox("A Steam Audio Manager does not exist in the scene. Click Window > Steam" + " Audio.", MessageType.Error); return(false); } if (steamAudioManager.audioEngine != AudioEngine.UnityNative) { EditorGUILayout.HelpBox("This Audio Mixer effect requires the audio engine to be set to Unity Native." + " Click Window > Steam Audio to change this.", MessageType.Error); return(false); } var binauralValue = 0.0f; var typeValue = 0.0f; var bypassDuringInitValue = 0.0f; plugin.GetFloatParameter("Binaural", out binauralValue); plugin.GetFloatParameter("Type", out typeValue); plugin.GetFloatParameter("BypassAtInit", out bypassDuringInitValue); var binaural = (binauralValue == 1.0f); var type = (SimulationType)typeValue; var bypassDuringInit = (bypassDuringInitValue == 1.0f); binaural = EditorGUILayout.Toggle("Binaural", binaural); type = (SimulationType)EditorGUILayout.EnumPopup("Simulation Type", type); EditorGUILayout.Space(); if (showAdvancedOptions = EditorGUILayout.Foldout(showAdvancedOptions, "Advanced Options")) { bypassDuringInit = EditorGUILayout.Toggle("Avoid Silence During Init", bypassDuringInit); } binauralValue = (binaural) ? 1.0f : 0.0f; typeValue = (float)type; bypassDuringInitValue = (bypassDuringInit) ? 1.0f : 0.0f; plugin.SetFloatParameter("Binaural", binauralValue); plugin.SetFloatParameter("Type", typeValue); plugin.SetFloatParameter("BypassAtInit", bypassDuringInitValue); return(false); }
public override bool OnGUI(IAudioEffectPlugin plugin) { // port int field plugin.GetFloatParameter(portName, out float port); plugin.GetFloatParameterInfo(portName, out float minVal, out float maxVal, out float defVal); portInt = (int)port; portInt = Mathf.Clamp(EditorGUILayout.IntField("Port number:", portInt), (int)minVal, (int)maxVal); plugin.SetFloatParameter(portName, portInt); // box // GUILayout.Space(5f); // Rect r = GUILayoutUtility.GetRect(200, 100, GUILayout.ExpandWidth(true)); // DrawControl(plugin, r, plugin.GetSampleRate()); // GUILayout.Space(5f); // show/hide default sliders return(false); }
void LoadPatch(IAudioEffectPlugin plugin, string path) { string patchText = File.ReadAllText(path); HelmPatchFormat patch = JsonUtility.FromJson <HelmPatchFormat>(patchText); FieldInfo[] fields = typeof(HelmPatchSettings).GetFields(); foreach (FieldInfo field in fields) { if (!field.FieldType.IsArray && !field.IsLiteral) { float val = (float)field.GetValue(patch.settings); string name = HelmPatchSettings.ConvertToPlugin(field.Name); plugin.SetFloatParameter(name, val); } } for (int i = 0; i < HelmPatchSettings.kMaxModulations; ++i) { plugin.SetFloatParameter("mod" + i + "value", 0.0f); } int modulationIndex = 0; foreach (HelmModulationSetting modulation in patch.settings.modulations) { if (modulationIndex >= HelmPatchSettings.kMaxModulations) { Debug.LogWarning("Only 16 modulations are currently supported in the Helm Unity plugin."); break; } string prefix = "mod" + modulationIndex; float source = HelmPatchSettings.GetSourceIndex(modulation.source); plugin.SetFloatParameter(prefix + "source", source); float dest = HelmPatchSettings.GetDestinationIndex(modulation.destination); plugin.SetFloatParameter(prefix + "dest", dest); plugin.SetFloatParameter(prefix + "value", modulation.amount); modulationIndex++; } }
private PluginGUIInstance getGUIInstanceForPlugin(ref IAudioEffectPlugin plugin) { float[] idArray; plugin.GetFloatBuffer("ID", out idArray, 1); int id = (int)idArray[0]; for (int i = 0; i < guis.Count; ++i) { if (guis[i].instanceID == id) { return(guis[i]); } } PluginGUIInstance newInstance = new PluginGUIInstance(ref plugin, id); guis.Add(newInstance); return(guis[guis.Count - 1]); }
public bool DoBrowserEvents(IAudioEffectPlugin plugin, Rect rect) { Event evt = Event.current; mousePosition = evt.mousePosition; bool newSelected = false; if (evt.type == EventType.MouseDown && rect.Contains(mousePosition)) { FileSystemInfo[] files = GetAllFiles(); int index = GetPatchIndex(rect, evt.mousePosition); if (files.Length > index && index >= 0) { lastSelectedIndex = index; selected = files[index].FullName; newSelected = true; } } ReloadPatches(); return(newSelected); }
public override bool OnGUI(IAudioEffectPlugin plugin) { float useLogScaleFloat; float showSpectrumFloat; plugin.GetFloatParameter("MasterGain", out _masterGain); plugin.GetFloatParameter("LowGain", out _lowGain); plugin.GetFloatParameter("MidGain", out _midGain); plugin.GetFloatParameter("HighGain", out _highGain); plugin.GetFloatParameter("LowFreq", out _lowFreq); plugin.GetFloatParameter("MidFreq", out _midFreq); plugin.GetFloatParameter("HighFreq", out _highFreq); plugin.GetFloatParameter("LowQ", out _lowQ); plugin.GetFloatParameter("HighQ", out _highQ); plugin.GetFloatParameter("MidQ", out _midQ); plugin.GetFloatParameter("UseLogScale", out useLogScaleFloat); plugin.GetFloatParameter("ShowSpectrum", out showSpectrumFloat); _useLogScale = useLogScaleFloat > 0.5f; _showSpectrum = showSpectrumFloat > 0.5f; GUILayout.Space(5f); var r = GUILayoutUtility.GetRect(200, 100, GUILayout.ExpandWidth(true)); if (DrawControl(plugin, r, plugin.GetSampleRate())) { plugin.SetFloatParameter("MasterGain", _masterGain); plugin.SetFloatParameter("LowGain", _lowGain); plugin.SetFloatParameter("MidGain", _midGain); plugin.SetFloatParameter("HighGain", _highGain); plugin.SetFloatParameter("LowFreq", _lowFreq); plugin.SetFloatParameter("HighFreq", _highFreq); plugin.SetFloatParameter("MidFreq", _midFreq); plugin.SetFloatParameter("LowQ", _lowQ); plugin.SetFloatParameter("MidQ", _midQ); plugin.SetFloatParameter("HighQ", _highQ); } return(true); }
public void DrawControl(IAudioEffectPlugin plugin, Rect r, float samplerate) { Event evt = Event.current; int controlID = GUIUtility.GetControlID(FocusType.Passive); EventType evtType = evt.GetTypeForControl(controlID); r = AudioCurveRendering.BeginCurveFrame(r); if (Event.current.type == EventType.Repaint) { float blend = plugin.IsPluginEditableAndEnabled() ? 1.0f : 0.5f; int numsamples = (int)r.width; float port; plugin.GetFloatParameter(portName, out port); string name = "Port: " + port; GUIHelpers.DrawText(r.x + 5, r.y + 5, r.width, name, Color.white); } AudioCurveRendering.EndCurveFrame(); }
public bool DrawControl(IAudioEffectPlugin plugin, Rect r, float samplerate) { var evt = Event.current; var controlID = GUIUtility.GetControlID(FocusType.Passive); var evtType = evt.GetTypeForControl(controlID); r = AudioCurveRendering.BeginCurveFrame(r); var thr = 4.0f; var changed = false; var x = evt.mousePosition.x - r.x; if ((evtType == EventType.MouseDown) && r.Contains(evt.mousePosition) && (evt.button == 0)) { var lf = (float)GUIHelpers.MapNormalizedFrequency(lowFreq, samplerate, useLogScale, false) * r.width; var hf = (float)GUIHelpers.MapNormalizedFrequency(highFreq, samplerate, useLogScale, false) * r.width; dragOperation = DragOperation.Mid; if (x < (lf + thr)) { dragOperation = DragOperation.Low; } else if (x > (hf - thr)) { dragOperation = DragOperation.High; } GUIUtility.hotControl = controlID; EditorGUIUtility.SetWantsMouseJumping(1); evt.Use(); } else if ((evtType == EventType.MouseDrag) && (GUIUtility.hotControl == controlID)) { if ((dragOperation == DragOperation.Low) || (dragOperation == DragOperation.Mid)) { lowFreq = Mathf.Clamp( (float)GUIHelpers.MapNormalizedFrequency( GUIHelpers.MapNormalizedFrequency(lowFreq, samplerate, useLogScale, false) + (evt.delta.x / r.width), samplerate, useLogScale, true ), 10.0f, highFreq ); } if (dragOperation == DragOperation.Low) { lowGain = Mathf.Clamp(lowGain - (evt.delta.y * 0.5f), -100.0f, 100.0f); } if (dragOperation == DragOperation.Mid) { midGain = Mathf.Clamp(midGain - (evt.delta.y * 0.5f), -100.0f, 100.0f); } if ((dragOperation == DragOperation.Mid) || (dragOperation == DragOperation.High)) { highFreq = Mathf.Clamp( (float)GUIHelpers.MapNormalizedFrequency( GUIHelpers.MapNormalizedFrequency(highFreq, samplerate, useLogScale, false) + (evt.delta.x / r.width), samplerate, useLogScale, true ), lowFreq, samplerate * 0.5f ); } if (dragOperation == DragOperation.High) { highGain = Mathf.Clamp(highGain - (evt.delta.y * 0.5f), -100.0f, 100.0f); } changed = true; evt.Use(); } else if ((evtType == EventType.MouseUp) && (evt.button == 0) && (GUIUtility.hotControl == controlID)) { GUIUtility.hotControl = 0; EditorGUIUtility.SetWantsMouseJumping(0); evt.Use(); } if (Event.current.type == EventType.Repaint) { var blend = plugin.IsPluginEditableAndEnabled() ? 1.0f : 0.5f; // Mark bands (low, medium and high bands) var lowColor = new Color(0.0f, 0.0f, 0.0f, blend); var midColor = new Color(0.5f, 0.5f, 0.5f, blend); var highColor = new Color(1.0f, 1.0f, 1.0f, blend); DrawBandSplitMarker( plugin, r, (float)GUIHelpers.MapNormalizedFrequency(lowFreq, samplerate, useLogScale, false) * r.width, thr, (GUIUtility.hotControl == controlID) && ((dragOperation == DragOperation.Low) || (dragOperation == DragOperation.Mid)), lowColor ); DrawBandSplitMarker( plugin, r, (float)GUIHelpers.MapNormalizedFrequency(highFreq, samplerate, useLogScale, false) * r.width, thr, (GUIUtility.hotControl == controlID) && ((dragOperation == DragOperation.High) || (dragOperation == DragOperation.Mid)), highColor ); const float dbRange = 40.0f; const float magScale = 1.0f / dbRange; float[] liveData; plugin.GetFloatBuffer("LiveData", out liveData, 6); float[] coeffs; plugin.GetFloatBuffer("Coeffs", out coeffs, 20); if (GUIUtility.hotControl == controlID) { DrawFilterCurve( r, coeffs, dragOperation == DragOperation.Low ? Mathf.Pow(10.0f, 0.05f * lowGain) : 0.0f, dragOperation == DragOperation.Mid ? Mathf.Pow(10.0f, 0.05f * midGain) : 0.0f, dragOperation == DragOperation.High ? Mathf.Pow(10.0f, 0.05f * highGain) : 0.0f, new Color(1.0f, 1.0f, 1.0f, 0.2f * blend), true, samplerate, magScale ); } DrawFilterCurve( r, coeffs, Mathf.Pow(10.0f, 0.05f * lowGain) * liveData[0], 0.0f, 0.0f, lowColor, false, samplerate, magScale ); DrawFilterCurve( r, coeffs, 0.0f, Mathf.Pow(10.0f, 0.05f * midGain) * liveData[1], 0.0f, midColor, false, samplerate, magScale ); DrawFilterCurve( r, coeffs, 0.0f, 0.0f, Mathf.Pow(10.0f, 0.05f * highGain) * liveData[2], highColor, false, samplerate, magScale ); DrawFilterCurve( r, coeffs, Mathf.Pow(10.0f, 0.05f * lowGain) * liveData[0], Mathf.Pow(10.0f, 0.05f * midGain) * liveData[1], Mathf.Pow(10.0f, 0.05f * highGain) * liveData[2], ScaleAlpha(AudioCurveRendering.kAudioOrange, 0.5f), false, samplerate, magScale ); DrawFilterCurve( r, coeffs, Mathf.Pow(10.0f, 0.05f * lowGain), Mathf.Pow(10.0f, 0.05f * midGain), Mathf.Pow(10.0f, 0.05f * highGain), AudioCurveRendering.kAudioOrange, false, samplerate, magScale ); if (showSpectrum) { var specLen = (int)r.width; float[] spec; plugin.GetFloatBuffer("InputSpec", out spec, specLen); DrawSpectrum(r, useLogScale, spec, dbRange, samplerate, 0.3f, 1.0f, 0.3f, 0.5f * blend, 0.0f); plugin.GetFloatBuffer("OutputSpec", out spec, specLen); DrawSpectrum(r, useLogScale, spec, dbRange, samplerate, 1.0f, 0.3f, 0.3f, 0.5f * blend, 0.0f); } GUIHelpers.DrawFrequencyTickMarks(r, samplerate, useLogScale, new Color(1.0f, 1.0f, 1.0f, 0.3f * blend)); } AudioCurveRendering.EndCurveFrame(); return(changed); }
public override bool OnGUI([NotNull] IAudioEffectPlugin plugin) { if (!_initialized) { Initialize(); } GUILayout.Label(_logo); EditorGUILayout.HelpBox("This filter captures data to drive acoustic echo cancellation. All audio which passes through this filter will be played through your " + "speakers. When the audio enters your microphone (as echo) it will be removed.", MessageType.Info); if (Application.isPlaying) { var state = WebRtcPreprocessingPipeline.GetAecFilterState(); switch (state) { case AudioPluginDissonanceNative.FilterState.FilterNoInstance: EditorGUILayout.HelpBox("AEC filter is running, but it is not associated with a microphone preprocessor - Microphone not running?", MessageType.Info); break; case AudioPluginDissonanceNative.FilterState.FilterNoSamplesSubmitted: EditorGUILayout.HelpBox("AEC filter is running, but no samples were submitted in the last frame - Could indicate audio thread starvation", MessageType.Warning); break; case AudioPluginDissonanceNative.FilterState.FilterNotRunning: EditorGUILayout.HelpBox("AEC filter is not running - Audio device not initialized?", MessageType.Warning); break; case AudioPluginDissonanceNative.FilterState.FilterOk: break; default: EditorGUILayout.HelpBox("Unknown Filter State!", MessageType.Error); break; } // `GetFloatBuffer` (a built in Unity method) causes a null reference exception when called. This bug seems to be limited to Unity 2019.3 on MacOS. // See tracking issue: https://github.com/Placeholder-Software/Dissonance/issues/177 #if (UNITY_EDITOR_OSX && UNITY_2019_3) EditorGUILayout.HelpBox("Cannot show detailed statistics in Unity 2019.3 due to an editor bug. Please update to Unity 2019.4 or newer!", MessageType.Error); #else float[] data; if (plugin.GetFloatBuffer("AecMetrics", out data, 10)) { EditorGUILayout.LabelField( new GUIContent("Delay Median (samples)"), FormatNumber(data[0]) ); EditorGUILayout.LabelField( new GUIContent("Delay Deviation"), FormatNumber(data[1]) ); EditorGUILayout.LabelField( new GUIContent("Fraction Poor Delays"), FormatPercentage(data[2]) ); EditorGUILayout.LabelField( new GUIContent("Echo Return Loss"), FormatNumber(data[3]) ); EditorGUILayout.LabelField( new GUIContent("Echo Return Loss Enhancement"), FormatNumber(data[6]) ); EditorGUILayout.LabelField( new GUIContent("Residual Echo Likelihood"), FormatPercentage(data[9]) ); ShowHints(data); } #endif } return(false); }
public bool DrawControl(IAudioEffectPlugin plugin, Rect r, float samplerate) { var evt = Event.current; var controlID = GUIUtility.GetControlID(FocusType.Passive); var evtType = evt.GetTypeForControl(controlID); r = AudioCurveRendering.BeginCurveFrame(r); var thr = 4.0f; var changed = false; var x = evt.mousePosition.x - r.x; if ((evtType == EventType.MouseDown) && r.Contains(evt.mousePosition) && (evt.button == 0)) { var lf = (float)GUIHelpers.MapNormalizedFrequency(_lowFreq, samplerate, _useLogScale, false) * r.width; var mf = (float)GUIHelpers.MapNormalizedFrequency(_midFreq, samplerate, _useLogScale, false) * r.width; var hf = (float)GUIHelpers.MapNormalizedFrequency(_highFreq, samplerate, _useLogScale, false) * r.width; var ld = Mathf.Abs(x - lf); var md = Mathf.Abs(x - mf); var hd = Mathf.Abs(x - hf); var d = ld; dragOperation = DragOperation.Low; if (md < d) { d = md; dragOperation = DragOperation.Mid; } if (hd < d) { d = hd; dragOperation = DragOperation.High; } GUIUtility.hotControl = controlID; EditorGUIUtility.SetWantsMouseJumping(1); evt.Use(); } else if ((evtType == EventType.MouseDrag) && (GUIUtility.hotControl == controlID)) { switch (dragOperation) { case DragOperation.Low: _lowFreq = Mathf.Clamp( (float)GUIHelpers.MapNormalizedFrequency( GUIHelpers.MapNormalizedFrequency(_lowFreq, samplerate, _useLogScale, false) + (evt.delta.x / r.width), samplerate, _useLogScale, true ), 10.0f, samplerate * 0.5f ); if (evt.shift) { _lowQ = Mathf.Clamp(_lowQ - (evt.delta.y * 0.05f), 0.01f, 10.0f); } else { _lowGain = Mathf.Clamp(_lowGain - (evt.delta.y * 0.5f), -100.0f, 100.0f); } break; case DragOperation.Mid: _midFreq = Mathf.Clamp( (float)GUIHelpers.MapNormalizedFrequency( GUIHelpers.MapNormalizedFrequency(_midFreq, samplerate, _useLogScale, false) + (evt.delta.x / r.width), samplerate, _useLogScale, true ), 10.0f, samplerate * 0.5f ); if (evt.shift) { _midQ = Mathf.Clamp(_midQ - (evt.delta.y * 0.05f), 0.01f, 10.0f); } else { _midGain = Mathf.Clamp(_midGain - (evt.delta.y * 0.5f), -100.0f, 100.0f); } break; case DragOperation.High: _highFreq = Mathf.Clamp( (float)GUIHelpers.MapNormalizedFrequency( GUIHelpers.MapNormalizedFrequency(_highFreq, samplerate, _useLogScale, false) + (evt.delta.x / r.width), samplerate, _useLogScale, true ), 10.0f, samplerate * 0.5f ); if (evt.shift) { _highQ = Mathf.Clamp(_highQ - (evt.delta.y * 0.05f), 0.01f, 10.0f); } else { _highGain = Mathf.Clamp(_highGain - (evt.delta.y * 0.5f), -100.0f, 100.0f); } break; } changed = true; evt.Use(); } else if ((evtType == EventType.MouseUp) && (evt.button == 0) && (GUIUtility.hotControl == controlID)) { GUIUtility.hotControl = 0; EditorGUIUtility.SetWantsMouseJumping(0); evt.Use(); } if (Event.current.type == EventType.Repaint) { var blend = plugin.IsPluginEditableAndEnabled() ? 1.0f : 0.5f; // Mark bands (low, medium and high bands) DrawBandSplitMarker( plugin, r, (float)GUIHelpers.MapNormalizedFrequency(_lowFreq, samplerate, _useLogScale, false) * r.width, thr, (GUIUtility.hotControl == controlID) && (dragOperation == DragOperation.Low), new Color(0, 0, 0, blend) ); DrawBandSplitMarker( plugin, r, (float)GUIHelpers.MapNormalizedFrequency(_midFreq, samplerate, _useLogScale, false) * r.width, thr, (GUIUtility.hotControl == controlID) && (dragOperation == DragOperation.Mid), new Color(0.5f, 0.5f, 0.5f, blend) ); DrawBandSplitMarker( plugin, r, (float)GUIHelpers.MapNormalizedFrequency(_highFreq, samplerate, _useLogScale, false) * r.width, thr, (GUIUtility.hotControl == controlID) && (dragOperation == DragOperation.High), new Color(1.0f, 1.0f, 1.0f, blend) ); const float dbRange = 40.0f; const float magScale = 1.0f / dbRange; float[] coeffs; plugin.GetFloatBuffer("Coeffs", out coeffs, 15); // Draw filled curve DrawFilterCurve( r, coeffs, true, true, true, ScaleAlpha(AudioCurveRendering.kAudioOrange, blend), _useLogScale, false, _masterGain, samplerate, magScale ); if (GUIUtility.hotControl == controlID) { DrawFilterCurve( r, coeffs, dragOperation == DragOperation.Low, dragOperation == DragOperation.Mid, dragOperation == DragOperation.High, new Color(1.0f, 1.0f, 1.0f, 0.2f * blend), _useLogScale, true, _masterGain, samplerate, magScale ); } if (_showSpectrum) { var specLen = (int)r.width; float[] spec; plugin.GetFloatBuffer("InputSpec", out spec, specLen); DrawSpectrum(r, _useLogScale, spec, dbRange, samplerate, 0.3f, 1.0f, 0.3f, 0.5f * blend, 0.0f); plugin.GetFloatBuffer("OutputSpec", out spec, specLen); DrawSpectrum(r, _useLogScale, spec, dbRange, samplerate, 1.0f, 0.3f, 0.3f, 0.5f * blend, 0.0f); } GUIHelpers.DrawFrequencyTickMarks(r, samplerate, _useLogScale, new Color(1.0f, 1.0f, 1.0f, 0.3f * blend)); } AudioCurveRendering.EndCurveFrame(); return(changed); }
public bool DrawControl(IAudioEffectPlugin plugin, Rect r, float samplerate, int channel) { r = AudioCurveRendering.BeginCurveFrame(r); if (Event.current.type == EventType.Repaint) { float blend = plugin.IsPluginEditableAndEnabled() ? 1.0f : 0.5f; float window, scale, mode; plugin.GetFloatParameter("Window", out window); plugin.GetFloatParameter("Scale", out scale); plugin.GetFloatParameter("Mode", out mode); float[] buffer; int numsamples = (mode >= 1.0f) ? maxspeclen : (int)(window * samplerate); plugin.GetFloatBuffer("Channel" + channel.ToString(), out buffer, numsamples); numsamples = buffer.Length; if (mode < 2.0f) { Color lineColor = new Color(1.0f, 0.5f, 0.2f, blend); if (mode >= 1.0f) { scale *= 0.1f; AudioCurveRendering.DrawFilledCurve(r, delegate(float x) { float f = Mathf.Clamp(x * (numsamples - 2) * window * 0.5f, 0, numsamples - 2); int i = (int)Mathf.Floor(f); float s1 = 20.0f * Mathf.Log10(buffer[i] + 0.0001f); float s2 = 20.0f * Mathf.Log10(buffer[i + 1] + 0.0001f); return((s1 + (s2 - s1) * (f - i)) * scale); }, lineColor); GUIHelpers.DrawFrequencyTickMarks(r, samplerate * window * 0.5f, false, Color.red); GUIHelpers.DrawDbTickMarks(r, 1.0f / scale, scale, Color.red, new Color(1.0f, 0.0f, 0.0f, 0.25f)); } else { AudioCurveRendering.DrawCurve(r, delegate(float x) { return(scale * buffer[(int)Mathf.Floor(x * (numsamples - 2))]); }, lineColor); GUIHelpers.DrawTimeTickMarks(r, window, Color.red, new Color(1.0f, 0.0f, 0.0f, 0.25f)); } } else { scale *= 0.1f; for (int i = 0; i < maxspeclen; i++) { float v = 20.0f * Mathf.Log10(buffer[i] + 0.0001f) * scale; spec[i] = new Color( Mathf.Clamp(v * 4.0f - 1.0f, 0.0f, 1.0f), Mathf.Clamp(v * 4.0f - 2.0f, 0.0f, 1.0f), 1.0f - Mathf.Clamp(Mathf.Abs(v * 4.0f - 1.0f), 0.0f, 1.0f) * Mathf.Clamp(4.0f - 4.0f * v, 0.0f, 1.0f), 1.0f); } if (spectex[channel] == null) { spectex[channel] = new Texture2D(maxspeclen, scopeheight); } specpos[channel] = (specpos[channel] + 1) % scopeheight; spectex[channel].SetPixels(0, specpos[channel], maxspeclen, 1, spec); spectex[channel].Apply(); Color oldColor = GUI.color; GUI.color = new Color(1.0f, 1.0f, 1.0f, blend); Rect r2 = new Rect(r.x, r.y + specpos[channel], r.width / (window * 0.5f), scopeheight); GUI.DrawTexture(r2, spectex[channel], ScaleMode.StretchToFill, false, 1.0f); r2.y -= scopeheight; GUI.DrawTexture(r2, spectex[channel], ScaleMode.StretchToFill, false, 1.0f); GUI.color = oldColor; GUIHelpers.DrawFrequencyTickMarks(r, samplerate * window * 0.5f, false, Color.red); } } AudioCurveRendering.EndCurveFrame(); return(false); }
public override bool OnGUI([NotNull] IAudioEffectPlugin plugin) { if (!_initialized) { Initialize(); } GUILayout.Label(_logo); EditorGUILayout.HelpBox("This filter captures data to drive acoustic echo cancellation. All audio which passes through this filter will be played through your " + "speakers, the filter will watch you microphone for this audio coming back as an echo and remove it", MessageType.Info); if (Application.isPlaying) { var state = WebRtcPreprocessingPipeline.GetAecFilterState(); switch (state) { case WebRtcPreprocessingPipeline.WebRtcPreprocessor.FilterState.FilterNoInstance: EditorGUILayout.HelpBox("AEC filter is running, but it is not associated with a microphone preprocessor - Microphone not running?", MessageType.Info); break; case WebRtcPreprocessingPipeline.WebRtcPreprocessor.FilterState.FilterNoSamplesSubmitted: EditorGUILayout.HelpBox("AEC filter is running, but no samples were submitted in the last frame - Could indicate audio thread starvation", MessageType.Warning); break; case WebRtcPreprocessingPipeline.WebRtcPreprocessor.FilterState.FilterNotRunning: EditorGUILayout.HelpBox("AEC filter is not running - Audio device not initialized?", MessageType.Warning); break; case WebRtcPreprocessingPipeline.WebRtcPreprocessor.FilterState.FilterOk: EditorGUILayout.HelpBox("AEC filter is running.", MessageType.Info); break; default: EditorGUILayout.HelpBox("Unknown Filter State!", MessageType.Error); break; } float[] data; if (plugin.GetFloatBuffer("AecMetrics", out data, 10)) { EditorGUILayout.LabelField( "Delay Median (samples)", data[0].ToString(CultureInfo.InvariantCulture) ); EditorGUILayout.LabelField( "Delay Deviation", data[1].ToString(CultureInfo.InvariantCulture) ); EditorGUILayout.LabelField( "Fraction Poor Delays", (data[2] * 100).ToString(CultureInfo.InvariantCulture) + "%" ); EditorGUILayout.LabelField( "Echo Return Loss", data[3].ToString(CultureInfo.InvariantCulture) ); EditorGUILayout.LabelField( "Echo Return Loss Enhancement", data[6].ToString(CultureInfo.InvariantCulture) ); EditorGUILayout.LabelField( "Residual Echo Likelihood", (data[9] * 100).ToString("0.0", CultureInfo.InvariantCulture) + "%" ); } } return(false); }
public override bool OnGUI(IAudioEffectPlugin plugin) { float fval = 0.0f; bool bval = false; Separator(); Label("GLOBAL SCALE (0.00001 - 10000.0)"); plugin.GetFloatParameter("GScale", out fval); plugin.SetFloatParameter("GScale", EditorGUILayout.FloatField(" ", Mathf.Clamp(fval, 0.00001f, 10000.0f))); Separator(); // Treat these floats as bools in the inspector plugin.GetFloatParameter("E.Rflt On", out fval); bval = (fval == 0.0f) ? false : true; bval = EditorGUILayout.Toggle("Reflections Engine On", bval); plugin.SetFloatParameter("E.Rflt On", (bval == false) ? 0.0f : 1.0f); plugin.GetFloatParameter("E.Rflt Rev On", out fval); bval = (fval == 0.0f) ? false : true; bval = EditorGUILayout.Toggle("Late Reverberation", bval); plugin.SetFloatParameter("E.Rflt Rev On", (bval == false) ? 0.0f : 1.0f); Separator(); Label("ROOM DIMENSIONS (meters)"); Label(""); plugin.GetFloatParameter("Room X", out fval); plugin.SetFloatParameter("Room X", EditorGUILayout.Slider("Width", fval, 1.0f, 200.0f)); plugin.GetFloatParameter("Room Y", out fval); plugin.SetFloatParameter("Room Y", EditorGUILayout.Slider("Height", fval, 1.0f, 200.0f)); plugin.GetFloatParameter("Room Z", out fval); plugin.SetFloatParameter("Room Z", EditorGUILayout.Slider("Length", fval, 1.0f, 200.0f)); Separator(); Label("WALL REFLECTION COEFFICIENTS (0.0 - 0.97)"); Label(""); plugin.GetFloatParameter("Left", out fval); plugin.SetFloatParameter("Left", EditorGUILayout.Slider("Left", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Right", out fval); plugin.SetFloatParameter("Right", EditorGUILayout.Slider("Right", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Up", out fval); plugin.SetFloatParameter("Up", EditorGUILayout.Slider("Up", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Down", out fval); plugin.SetFloatParameter("Down", EditorGUILayout.Slider("Down", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Behind", out fval); plugin.SetFloatParameter("Behind", EditorGUILayout.Slider("Back", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Front", out fval); plugin.SetFloatParameter("Front", EditorGUILayout.Slider("Front", fval, 0.0f, 0.97f)); Separator(); Label("SHARED REVERB ATTENUATION RANGE (1.0 - 10000.0 meters)"); Label(""); plugin.GetFloatParameter("Shared Rev Min", out fval); plugin.SetFloatParameter("Shared Rev Min", EditorGUILayout.Slider("Minimum", fval, 1.0f, 10000.0f)); plugin.GetFloatParameter("Shared Rev Max", out fval); plugin.SetFloatParameter("Shared Rev Max", EditorGUILayout.Slider("Maximum", fval, 1.0f, 10000.0f)); // We will override the controls with our own, so return false return(false); }
public bool DrawControl(IAudioEffectPlugin plugin, Rect r, float samplerate) { Event evt = Event.current; int dragControlID = GUIUtility.GetControlID(FocusType.Passive); r = AudioCurveRendering.BeginCurveFrame(r); float windowMin, windowMax, windowDef; plugin.GetFloatParameterInfo("Window", out windowMin, out windowMax, out windowDef); float yscaleMin, yscaleMax, yscaleDef; plugin.GetFloatParameterInfo("YScale", out yscaleMin, out yscaleMax, out yscaleDef); float yoffsetMin, yoffsetMax, yoffsetDef; plugin.GetFloatParameterInfo("YOffset", out yoffsetMin, out yoffsetMax, out yoffsetDef); float window; plugin.GetFloatParameter("Window", out window); float yscale; plugin.GetFloatParameter("YScale", out yscale); float yoffset; plugin.GetFloatParameter("YOffset", out yoffset); float blend = plugin.IsPluginEditableAndEnabled() ? 1.0f : 0.5f; switch (evt.GetTypeForControl(dragControlID)) { case EventType.MouseDown: if (evt.button == 0 && r.Contains(evt.mousePosition) && GUIUtility.hotControl == 0) { GUIUtility.hotControl = dragControlID; evt.Use(); } break; case EventType.MouseUp: if (evt.button == 0 && GUIUtility.hotControl == dragControlID) { GUIUtility.hotControl = 0; evt.Use(); } break; case EventType.MouseDrag: if (GUIUtility.hotControl == dragControlID) { window = Mathf.Clamp(window + evt.delta.x * 0.1f, windowMin, windowMax); if (evt.shift) { yoffset = Mathf.Clamp(yoffset - (0.5f * evt.delta.y / yscale), yoffsetMin, yoffsetMax); } else { yscale = Mathf.Clamp(yscale - evt.delta.y * 0.01f, yscaleMin, yscaleMax); } plugin.SetFloatParameter("Window", window); plugin.SetFloatParameter("YScale", yscale); plugin.SetFloatParameter("YOffset", yoffset); evt.Use(); } break; case EventType.ScrollWheel: if (r.Contains(evt.mousePosition)) { window = Mathf.Clamp(window + evt.delta.x * 0.1f, windowMin, windowMax); yoffset = Mathf.Clamp(yoffset - (0.5f * evt.delta.y / yscale), yoffsetMin, yoffsetMax); plugin.SetFloatParameter("Window", window); plugin.SetFloatParameter("YScale", yscale); plugin.SetFloatParameter("YOffset", yoffset); evt.Use(); } break; case EventType.Repaint: { float yscaleDraw = yscale * 0.05f; // Background grid and values Color lineColor = new Color(0, 0, 0, 0.2f); Color textColor = new Color(1.0f, 1.0f, 1.0f, 0.3f * blend); GUIHelpers.DrawDbTickMarks(r, yoffset, yscaleDraw, textColor, lineColor); GUIHelpers.DrawTimeTickMarks(r, window, textColor, lineColor); // Curves int numsamples = (int)r.width; float[] mcurve; plugin.GetFloatBuffer("MomentaryRMS", out mcurve, numsamples); float[] scurve; plugin.GetFloatBuffer("ShortTermRMS", out scurve, numsamples); float[] icurve; plugin.GetFloatBuffer("IntegratedRMS", out icurve, numsamples); DrawCurve(r, mcurve, yoffset, yscaleDraw, new Color(1.0f, 0.0f, 0.0f, blend * 0.5f), 90); DrawCurve(r, scurve, yoffset, yscaleDraw, new Color(0.0f, 1.0f, 0.0f, blend * 0.3f), 150); DrawCurve(r, icurve, yoffset, yscaleDraw, new Color(0.0f, 0.0f, 1.0f, blend * 0.3f), 210); } break; } AudioCurveRendering.EndCurveFrame(); return(false); }
public abstract bool OnGUI(IAudioEffectPlugin plugin);
public bool DrawControl(IAudioEffectPlugin plugin, Rect r, float samplerate) { Event evt = Event.current; int controlID = GUIUtility.GetControlID(FocusType.Passive); EventType evtType = evt.GetTypeForControl(controlID); r = AudioCurveRendering.BeginCurveFrame(r); if (Event.current.type == EventType.Repaint) { float blend = plugin.IsPluginEditableAndEnabled() ? 1.0f : 0.5f; const float dbRange = 40.0f; const float magScale = 1.0f / dbRange; float showSpectrum; plugin.GetFloatParameter("ShowSpectrum", out showSpectrum); if (showSpectrum >= 0.5f) { blend *= 0.5f; } bool useLogScale = false; float numModes = 0; if (plugin.GetFloatParameter("Num modes", out numModes) && numModes > 0 && numModes < 1000) { float[] coeffs; if (plugin.GetFloatBuffer("Coeffs", out coeffs, (int)numModes * 3) && coeffs != null) { // Draw filled curve DrawFilterCurve( r, coeffs, ScaleAlpha(AudioCurveRendering.kAudioOrange, blend), (int)numModes, useLogScale, false, samplerate, magScale); GUIHelpers.DrawFrequencyTickMarks(r, samplerate, useLogScale, new Color(1.0f, 1.0f, 1.0f, 0.3f * blend)); } } if (showSpectrum >= 0.5f) { float spectrumOffset; plugin.GetFloatParameter("SpectrumOffset", out spectrumOffset); int specLen = (int)r.width; float[] spec; plugin.GetFloatBuffer("InputSpec", out spec, specLen); DrawSpectrum(r, useLogScale, spec, dbRange, samplerate, 0.3f, 1.0f, 0.3f, 0.5f * blend, spectrumOffset); plugin.GetFloatBuffer("OutputSpec", out spec, specLen); DrawSpectrum(r, useLogScale, spec, dbRange, samplerate, 1.0f, 0.3f, 0.3f, 0.5f * blend, spectrumOffset); } } AudioCurveRendering.EndCurveFrame(); return(false); }
public override bool OnGUI(IAudioEffectPlugin plugin) { float fval = 0.0f; bool bval = false; Separator(); Label("Voice limit (1 - 1024)"); ONSPSettings.Instance.voiceLimit = EditorGUILayout.IntField(" ", ONSPSettings.Instance.voiceLimit); if (GUI.changed) { GUI.changed = false; EditorUtility.SetDirty(ONSPSettings.Instance); } Separator(); Label ("GLOBAL SCALE (0.00001 - 10000.0)"); plugin.GetFloatParameter("GScale", out fval); plugin.SetFloatParameter("GScale", EditorGUILayout.FloatField(" ", Mathf.Clamp (fval, 0.00001f, 10000.0f))); Separator(); Label ("REFLECTION ENGINE"); Label(""); // Treat these floats as bools in the inspector plugin.GetFloatParameter("E.Rflt On", out fval); bval = (fval == 0.0f) ? false : true; bval = EditorGUILayout.Toggle("Enable Early Reflections", bval); plugin.SetFloatParameter("E.Rflt On", (bval == false) ? 0.0f : 1.0f); plugin.GetFloatParameter("E.Rflt Rev On", out fval); bval = (fval == 0.0f) ? false : true; bval = EditorGUILayout.Toggle("Enable Reverberation", bval); plugin.SetFloatParameter("E.Rflt Rev On", (bval == false) ? 0.0f : 1.0f); Separator(); Label("ROOM DIMENSIONS (meters)"); Label(""); plugin.GetFloatParameter("Room X", out fval); plugin.SetFloatParameter("Room X", EditorGUILayout.Slider("Width", fval, 1.0f, 200.0f)); plugin.GetFloatParameter("Room Y", out fval); plugin.SetFloatParameter("Room Y", EditorGUILayout.Slider("Height", fval, 1.0f, 200.0f)); plugin.GetFloatParameter("Room Z", out fval); plugin.SetFloatParameter("Room Z", EditorGUILayout.Slider("Length", fval, 1.0f, 200.0f)); Separator(); Label("WALL REFLECTION COEFFICIENTS (0.0 - 0.97)"); Label(""); plugin.GetFloatParameter("Left", out fval); plugin.SetFloatParameter("Left", EditorGUILayout.Slider("Left", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Right", out fval); plugin.SetFloatParameter("Right", EditorGUILayout.Slider("Right", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Up", out fval); plugin.SetFloatParameter("Up", EditorGUILayout.Slider("Up", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Down", out fval); plugin.SetFloatParameter("Down", EditorGUILayout.Slider("Down", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Behind", out fval); plugin.SetFloatParameter("Behind", EditorGUILayout.Slider("Back", fval, 0.0f, 0.97f)); plugin.GetFloatParameter("Front", out fval); plugin.SetFloatParameter("Front", EditorGUILayout.Slider("Front", fval, 0.0f, 0.97f)); Separator(); Label("SHARED REVERB ATTENUATION RANGE (1.0 - 10000.0 meters)"); Label(""); plugin.GetFloatParameter("Shared Rev Min", out fval); plugin.SetFloatParameter("Shared Rev Min", EditorGUILayout.Slider("Minimum", fval, 1.0f, 10000.0f)); plugin.GetFloatParameter("Shared Rev Max", out fval); plugin.SetFloatParameter("Shared Rev Max", EditorGUILayout.Slider("Maximum", fval, 1.0f, 10000.0f)); Separator(); Label("SHARED REVERB WET MIX (-60.0 - 20.0 dB)"); Label(""); plugin.GetFloatParameter("Shared Rev Wet", out fval); plugin.SetFloatParameter("Shared Rev Wet", EditorGUILayout.Slider(" ", fval, -60.0f, 20.0f)); Separator(); Label("PROPAGATION QUALITY LEVEL (0.0 - 200.0%)"); Label(""); plugin.GetFloatParameter("Prop Quality", out fval); plugin.SetFloatParameter("Prop Quality", EditorGUILayout.Slider(" ", fval, 0.0f, 200.0f)); Separator(); // We will override the controls with our own, so return false return false; }
public bool DrawControl(IAudioEffectPlugin plugin, Rect r, float samplerate) { r = AudioCurveRendering.BeginCurveFrame(r); if (Event.current.type == EventType.Repaint) { var blend = plugin.IsPluginEditableAndEnabled() ? 1.0f : 0.5f; float window; plugin.GetFloatParameter("Window", out window); window *= samplerate; if (window > samplerate) { window = samplerate; } float[] corr; var numsamples = (int)window; plugin.GetFloatBuffer("Correlation", out corr, 2 * numsamples); numsamples = corr.Length; var cx = r.x + (r.width * 0.5f); var cy = r.y + (r.height * 0.5f); coord1[0].Set(r.x, r.y + (r.height * 0.5f), 0); coord1[1].Set(r.x + r.width, r.y + (r.height * 0.5f), 0); coord2[0].Set(r.x + (r.width * 0.5f), r.y, 0); coord2[1].Set(r.x + (r.width * 0.5f), r.y + r.height, 0); var w = (2.0f * 3.1415926f) / (circle.Length - 1); var cr = r.height * 0.4f; for (var n = 0; n < circle.Length; n++) { circle[n].Set(cx + (cr * Mathf.Cos(n * w)), cy + (cr * Mathf.Sin(n * w)), 0); } float scale; plugin.GetFloatParameter("Scale", out scale); scale *= cr; var lineTint = 0.5f; UnityEditor.Handles.color = new Color(lineTint, lineTint, lineTint, 0.75f); UnityEditor.Handles.DrawAAPolyLine(2.0f, coord1.Length, coord1); UnityEditor.Handles.DrawAAPolyLine(2.0f, coord2.Length, coord2); UnityEditor.Handles.DrawAAPolyLine(2.0f, circle.Length, circle); HandleUtilityWrapper.handleWireMaterial.SetPass(0); GL.Begin(GL.LINES); var col1 = AudioCurveRendering.kAudioOrange; var col2 = Color.yellow; col1.a = blend; col2.a = 0.0f; var cs = 1.0f / ((numsamples / 2) - 1); for (var n = 0; n < (numsamples / 2); n++) { var px = cx + (scale * corr[n * 2]); var py = cy - (scale * corr[(n * 2) + 1]); if ((px >= r.x) && (py >= r.y) && (px < (r.x + r.width)) && (py < (r.y + r.height))) { GL.Color(Color.Lerp(col1, col2, n * cs)); GL.Vertex3(px, py - 1.0f, 0.0f); GL.Vertex3(px, py, 0.0f); } } GL.End(); } AudioCurveRendering.EndCurveFrame(); return(false); }