Effect Documentation

Documentation

Effect Helper

namespace Audectra.Graphics.Effects
{
    /// <summary>
    /// Helper class to simplify effect generation and
    /// build a bridge between your effect and Audectra.
    /// </summary>
    public interface IEffectHelper
    {
        /// <summary>
        /// Create an empty render for your effect.
        /// </summary>
        /// <returns>Empty render</returns>
        IRgbRender CreateRender();

        /// <summary>
        /// Create a new random color with full saturation
        /// and full brightness.
        /// </summary>
        /// <returns>new random color</returns>
        RgbColor CreateRandomColor();

        /// <summary>
        /// Create an empty particle system for your effect.
        /// </summary>
        /// <returns>Empty particle system</returns>
        IParticleSystem CreateParticleSystem();

        /// <summary>
        /// Create a new one dimensional wave simulation.
        /// </summary>
        /// <returns>wave simulation</returns>
        IWaveSimulation1D CreateWaveSimulation1D();

        /// <summary>
        /// Converts passed value to single precision float.
        /// Only usable in ValueChanged callback methods.
        /// </summary>
        /// <param name="value">value to convert</param>
        /// <returns>converted value</returns>
        float ValueToSingle(object value);

        /// <summary>
        /// Converts passed value to integer.
        /// Only usable in ValueChanged callback methods.
        /// </summary>
        /// <param name="value">value to convert</param>
        /// <returns>converted value</returns>
        int ValueToInt(object value);

        /// <summary>
        /// Converts passed value to rgb color.
        /// Only usable in ValueChanged callback methods.
        /// </summary>
        /// <param name="value">value to convert</param>
        /// <returns>converted value</returns>
        RgbColor ValueToColor(object value);

        /// <summary>
        /// Has a beat been detected? Gets reset after calling.
        /// </summary>
        /// <returns>true, if a beat has been detected, false otherwise.</returns>
        bool IsBeat();

        /// <summary>
        /// Get the estimated beat.
        /// </summary>
        /// <returns>estimated beat period in seconds</returns>
        float GetBeatPeriod();

        /// <summary>
        /// Get the latest calculated power spectrum.
        /// </summary>
        /// <returns>Latest power spectrum</returns>
        double[] GetPowerSpectrum();

        /// <summary>
        /// Get the latest calculated chroma values.
        /// </summary>
        /// <returns>Latest chromas</returns>
        double[] GetChromas();

        /// <summary>
        /// Adds a colored blob on the given render.
        /// </summary>
        /// <param name="render">render, where blob will be added on</param>
        /// <param name="x">x coordinate of center position</param>
        /// <param name="y">y coordinate of center position</param>
        /// <param name="dx">x size of blob</param>
        /// <param name="dy">y size of blob</param>
        /// <param name="color">color for the blob</param>
        void AddBlob(IRgbRender render, float x, float y, float dx, float dy, RgbColor color);

        /// <summary>
        /// Fill a bar in your render. It always fills the smaller dimension.
        /// </summary>
        /// <param name="render">render, where bar will be filled</param>
        /// <param name="x0">starting position</param>
        /// <param name="length">bar length in the greater dimension</param>
        /// <param name="color">color of the bar</param>
        void FillBar(IRgbRender render, int x0, int length, RgbColor color);

        /// <summary>
        /// Adds a colored rectangle on the given render.
        /// </summary>
        /// <param name="render">render, where rectangle will be added on</param>
        /// <param name="x0">x position of top left corner</param>
        /// <param name="y0">y position of top left corner</param>
        /// <param name="x1">x position of bottom right corner</param>
        /// <param name="y1">y position of bottom right corner</param>
        /// <param name="color">color for the rectangle</param>
        void FillRectangle(IRgbRender render, int x0, int y0, int x1, int y1, RgbColor color);
    }
}

Layer Settings Panel

namespace Audectra.GUI
{
    /// <summary>
    /// Add settings for your effects to the settings side panel.
    /// </summary>
    public interface ILayerSettingsPanel
    {
        /// <summary>
        /// Add a text label to the current group/page.
        /// </summary>
        /// <param name="label">label text</param>
        void AddLabel(string label);

        /// <summary>
        /// Add a textbox to the current group/page.
        /// </summary>
        /// <param name="callback">callback, when content has changed</param>
        /// <param name="text">initial text to display</param>
        /// <param name="valueId">value id for this textbox</param>
        void AddTextBox(ISettingsObserver callback, string text, uint valueId);

        /// <summary>
        /// Add a trackbar to the current group/page.
        /// </summary>
        /// <param name="callback">callback, when content has changed</param>
        /// <param name="value">initial value of trackbar</param>
        /// <param name="min">minimum value of trackbar</param>
        /// <param name="max">maximum value of trackbar</param>
        /// <param name="valueId">value id for this trackbar</param>
        void AddTrackbar(ISettingsObserver callback, float value, float min, float max, uint valueId);

        /// <summary>
        /// Add a bindable trackbar to the current group/page. The bindable attribute
        /// allows the trackbar to be bound to a music feature.
        /// </summary>
        /// <param name="callback">callback, when content has changed</param>
        /// <param name="value">initial value of trackbar</param>
        /// <param name="min">minimum value of trackbar</param>
        /// <param name="max">maximum value of trackbar</param>
        /// <param name="valueId">value id for this trackbar</param>
        void AddBindableTrackbar(ISettingsObserver callback, float value, float min, float max, uint valueId);

        /// <summary>
        /// Add a bindable trigger button to the current group/page. The bindable
        /// attribute allows the trigger to be bound to a music feature.
        /// </summary>
        /// <param name="callback">callback, when triggered</param>
        /// <param name="triggerId">trigger id for this trigger</param>
        void AddBindableTrigger(ISettingsObserver callback, uint triggerId);

        /// <summary>
        /// Add a combobox to the current group/page.
        /// </summary>
        /// <param name="callback">callback, when selected item has changed</param>
        /// <param name="items">list of choosable string items</param>
        /// <param name="valueId">value id for this combobox</param>
        void AddComboBox(ISettingsObserver callback, List<string> items, uint valueId);

        /// <summary>
        /// Add a color group to the current page consisting of three
        /// bindable trackbars for red, green and blue.
        /// </summary>
        /// <param name="callback">callback, when color has changed</param>
        /// <param name="color">initial color</param>
        /// <param name="valueId">value id for the color group</param>
        void AddColorGroup(ISettingsObserver callback, RgbColor color, uint valueId);

        /// <summary>
        /// Start a new group on the current page.
        /// </summary>
        /// <param name="groupTitle">displayed group title</param>
        void GroupBegin(string groupTitle);
       
        /// <summary>
        /// End the current group on the current page.
        /// </summary>
        void GroupEnd();

        /// <summary>
        /// Start a new settings page.
        /// </summary>
        void NextPage();
    }
}

RGB Render

namespace Audectra.Graphics
{
    /// <summary>
    /// RGB Render, storing all your pixel informations.
    /// </summary>
    public interface IRgbRender
    {
        /// <summary>
        /// Height of the render in pixels.
        /// </summary>
        int Height { get; }

        /// <summary>
        /// Width of the render in pixels.
        /// </summary>
        int Width { get; }

        /// <summary>
        /// Clear all pixels. Resets their colors to black.
        /// </summary>
        void Clear();

        /// <summary>
        /// Apply a function to all pixels. First parameter
        /// corresponds to the current color, second parameter
        /// to the x coordinate and third parameter to the y
        /// coordinate of each pixel. Return value is the
        /// new value for the current pixel.
        /// </summary>
        /// <param name="mapFunc">function, which will be applied</param>
        void Map(Func<RgbColor, int, int, RgbColor> mapFunc);

        /// <summary>
        /// Apply an action to all pixels. First parameter
        /// corresponds to the current color, second parameter
        /// to the x coordinate and third parameter to the y
        /// coordinate of each pixel.
        /// </summary>
        /// <param name="mapFunc">action, which will be applied</param>
        void Map(Action<RgbColor, int, int> mapFunc);

        /// <summary>
        /// Create a new clone of this render.
        /// </summary>
        /// <returns>clone of this render</returns>
        IRgbRender Clone();

        /// <summary>
        /// Access the color the pixel with the supplied x
        /// and y coordinates. This can also be used to set
        /// the color of the corresponding pixel.
        /// </summary>
        /// <param name="x">x coordinate of the pixel</param>
        /// <param name="y">y coordinate of the pixel</param>
        /// <returns>current color of pixel</returns>
        RgbColor this[int x, int y] { get; set; }
    }
}

RGB Color

namespace Audectra.Graphics
{
    /// <summary>
    /// RGB color representation
    /// </summary>
    public interface IRgbColor
    {
        /// <summary>
        /// Red value, 0.0f - 1.0f
        /// </summary>
        float R { get; set; }

        /// <summary>
        /// Green value, 0.0f - 1.0f
        /// </summary>
        float G { get; set; }

        /// <summary>
        /// Blue value, 0.0f - 1.0f
        /// </summary>
        float B { get; set; }

        /// <summary>
        /// Color intensity or brightness
        /// </summary>
        float Intensity { get; }

        /// <summary>
        /// Saturate color values to 0.0f - 1.0f.
        /// </summary>
        void Saturate();

        /// <summary>
        /// Create a copy of this RGB color.
        /// </summary>
        /// <returns>copy of this color</returns>
        RgbColor Copy();
    }
}

HSV Color

namespace Audectra.Graphics
{
    public interface IHsvColor
    {
        /// <summary>
        /// Hue of the color, 0.0f - 360.0f
        /// </summary>
        float H { get; set; }

        /// <summary>
        /// Saturation of the color, 0.0f - 1.0f
        /// </summary>
        float S { get; set; }

        /// <summary>
        /// Value/Brightness of the color, 0.0f - 1.0f
        /// </summary>
        float V { get; set; }

        /// <summary>
        /// Convert this HSV color to RGB color
        /// </summary>
        /// <returns></returns>
        RgbColor ToRgb();
    }
}

HsvColor instances can be implicitly converted to RgbColor at any time. Analogously, you are able to create an HsvColor instance by passing a RgbColor to its constructor as well. This allows you to easily switch between both color spaces at any time.

Particle System

Documentation coming soon.

1D Wave Simulation

namespace Audectra.Mathematics
{
    public interface IWaveSimulation1D
    {
        /// <summary>
        /// Speed of the wave simulation. Default value is 1.0.
        /// </summary>
        double Speed { get; set; }

        /// <summary>
        /// Update the wave simulation according to the passed time.
        /// </summary>
        /// <param name="dt">passed time since last update</param>
        void Update(double dt);

        /// <summary>
        /// Render the wave simulation scene into the passed render object.
        /// </summary>
        /// <param name="render">simulation will be rendered into this object</param>
        void Render(IRgbRender render);

        /// <summary>
        /// Add a droplet to the wave simulation.
        /// </summary>
        /// <param name="x">position of the droplet</param>
        /// <param name="color">color of the droplet</param>
        void AddDrop(double x, RgbColor color);

        /// <summary>
        /// Add a droplet to the wave simulation and scale its size.
        /// </summary>
        /// <param name="x">position of the droplet</param>
        /// <param name="color">color of the droplet</param>
        /// <param name="scale">scale for the droplet size</param>
        void AddDrop(double x, RgbColor color, double scale);
    }
}