Giter VIP home page Giter VIP logo

viatordsp's Introduction

Viator DSP JUCE Plugin Library

License: GPL v3 Downloads

Description

The viatordsp library is made up of dsp and gui classes that help make creating plugins faster, easier, and more fun! The dsp namespace contains dsp classes such as clippers, filters, and much more to come. The gui namespace contains stylized versions of JUCE's built-in widgets (like sliders and comboboxes) that have their own lookandfeel overrides to make them look awesome!

DISCLAIMER

I unfortunately cannot give you permission to use the gui objects that have images attached to them per the license of the images. You can however copy the logic and apply your own images to them!

Installation

Clone the repo viatordsp or download it as a zip. Cloning it would be better, since when there is an update, you simply pull the changes without needing to download another version of the zip file.

Just include the viator_modules folder in the Projucer's module window.

Use

To use viatordsp, there are three namespaces:

  • viator_dsp
  • viator_gui
  • viator_utils

You can create an instance of a class in the folder viator_dsp, like the Distortion, with:

  • viator_dsp::Distortion distortion (In the PluginProcessor.h)

Update parameters, e.g.:

  • distortion.setClipperType(viator_dsp::Distortion::ClipperType::kSoft);

Be sure to call the prepare method of every DSP module in the PluginProcessor.cpp's prepare method!

Or a gui component inside of viator_gui/Widgets, like a dial, with:

  • viator_gui::Dial dial {" textValueSuffix", rangeStart, rangeEnd, rangeInterval, returnValue} (In the PluginEditor.h)

Contributing

Contributions are most welcome! Check out the issues page for more details.

License

viatordsp is licensed under the GNU General Public License (GPLv3) agreement.

Support

If you like my work and would like to support me creating more audio applications, check out my Patreon where you can donate and download all of my current plugins!

Online Presence:

viatordsp's People

Contributors

landonviator avatar nstilt1 avatar

Stargazers

 avatar  avatar Yomi avatar Oliver Greschke avatar  avatar migizo avatar Brady Boettcher avatar Tim Carey avatar Jehoshaphat Allenlyon avatar  avatar  avatar  avatar  avatar Paul Jones avatar SangkoDeng avatar Roger Chen avatar Tyler Lavoie avatar  avatar Tatsuya Shiozawa avatar  avatar Dimitris Vasil avatar Benjamin Quiédeville avatar Ian A. Cook avatar  avatar

Watchers

 avatar  avatar

Forkers

0xniel logsod

viatordsp's Issues

GUI Classes

We can use this issue to add GUI classes/widgets to the library.

For now, this is the format for a GUI class:

just a header file for now

#pragma once
#include "../Widgets/StyleSheet.h"

namespace viator_gui
{
class LV_Dial  : public juce::Slider
{
public:
    
    LV_Dial
    (   juce::String suffix,
        double rangeStart,
        double rangeEnd,
        double intervalValue,
        double returnValue
    )
    {
        initShadows();
        initProps(suffix, rangeStart, rangeEnd, intervalValue, returnValue);
    }
    
    ~LV_Dial() override
    {
        setLookAndFeel(nullptr);
    }

    enum class DialStyle
    {
        kHardDial,
        kAlphaDial,
        kAbleDial
    };
    
    void setDialStyle(DialStyle dialStyle)
    {
        switch (dialStyle)
        {
            case DialStyle::kHardDial:
            {
                setLookAndFeel(&hardDial);
                break;
            }
                
            case DialStyle::kAlphaDial:
            {
                setLookAndFeel(&alphaDial);
                break;
            }
                
            case DialStyle::kAbleDial:
            {
                setLookAndFeel(&ableDial);
                break;
            }
        }
    }
    
    void forceShadow()
    {
        setComponentEffect(&dialShadow);
    }

private:
    
    void mouseEnter (const juce::MouseEvent& event) override
    {
        setColour(juce::Slider::ColourIds::thumbColourId, findColour(juce::Slider::ColourIds::thumbColourId).withMultipliedLightness(1.25));
        setComponentEffect(&dialShadow);
    }
    
    void mouseExit (const juce::MouseEvent& event) override
    {
        setColour(juce::Slider::ColourIds::thumbColourId, findColour(juce::Slider::ColourIds::thumbColourId).withMultipliedLightness(0.8f));
        setComponentEffect(&dialShadow);
    }
    
    /** Slider ================================================================*/
    Slider dial;
    juce::LV_HardDialLAF hardDial;
    juce::LV_AlphaDialLAF alphaDial;
    juce::LV_CustomAbleDialLAF ableDial {false};
    
    /** Methods ================================================================*/
    void initProps(juce::String suffix,
                   double rangeStart,
                   double rangeEnd,
                   double intervalValue,
                   double returnValue)
    {
        setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
        setTextBoxStyle(juce::Slider::TextBoxBelow, false, 96, 32);
        setColour(juce::Slider::ColourIds::rotarySliderFillColourId, findColour(Slider::ColourIds::thumbColourId));
        setColour(juce::Slider::ColourIds::rotarySliderOutlineColourId, juce::Colours::black.brighter(0.1).withAlpha(0.8f));
        setColour(juce::Slider::ColourIds::trackColourId, juce::Colours::whitesmoke.darker(1.75f).withAlpha(0.7f));
        setColour(juce::Slider::ColourIds::textBoxOutlineColourId, juce::Colours::black.withAlpha(0.0f));
        setColour(juce::Slider::ColourIds::textBoxTextColourId, juce::Colours::whitesmoke.withAlpha(0.36f));
        setColour(juce::Slider::ColourIds::thumbColourId, juce::Colour::fromFloatRGBA(0.392f, 0.584f, 0.929f, 1.0f).darker(1.0f));
        setRange(rangeStart, rangeEnd, intervalValue);
        setDoubleClickReturnValue(true, returnValue);
        setTextValueSuffix(suffix);
        setLookAndFeel(&hardDial);
        setComponentEffect(&dialShadow);
    }
    
    /** Fader shadow ===========================================================*/
    void initShadows()
    {
        shadowProperties.radius = 24;
        shadowProperties.offset = juce::Point<int> (-1, 4);
        shadowProperties.colour = juce::Colours::black.withAlpha(0.5f);
        dialShadow.setShadowProperties (shadowProperties);
    }
    
    juce::DropShadow shadowProperties;
    juce::DropShadowEffect dialShadow;
    
};
}

DSP Classes

We can use this issue to add more DSP classes to the library.

For now, this is the format for a DSP class:
Notice the implementation of the process methods are in the header (because of templates)

header

#ifndef Clipper_h
#define Clipper_h

#include "../Common/Common.h"

namespace viator_dsp
{
template <typename SampleType>
class Clipper
{
public:
    
    /** Creates an uninitialised clipper. Call prepare() before first use. */
    Clipper();
    
    /** Initialises the clipper. */
    void prepare(const juce::dsp::ProcessSpec& spec);
    
    /** Processes the input and output buffers supplied in the processing context. */
    template <typename ProcessContext>
    void process (const ProcessContext& context) noexcept
    {
        if (mGlobalBypass)
        {
            return;
        }
        
        auto&& inBlock  = context.getInputBlock();
        auto&& outBlock = context.getOutputBlock();

        jassert (inBlock.getNumChannels() == outBlock.getNumChannels());
        jassert (inBlock.getNumSamples() == outBlock.getNumSamples());

        auto len         = inBlock.getNumSamples();
        auto numChannels = inBlock.getNumChannels();


        for (size_t channel = 0; channel < numChannels; ++channel)
        {
            for (size_t sample = 0; sample < len; ++sample)
            {
                auto* input = inBlock.getChannelPointer (channel);
                auto* output = outBlock.getChannelPointer (channel);
                
                auto x = input[sample] * viator_utils::utils::dbToGain(mRawGain.getNextValue());
                output[sample] = processSample(x);
            }
        }
    }
    
    /** Process an individual sample */
    SampleType processSample(SampleType input) noexcept
    {
        switch(mClipType)
        {
            case ClipType::kHard: return hardClipData(input * mGainDB, mThresh); break;
            case ClipType::kSoft: return softClipData(input * mGainDB); break;
            case ClipType::kDiode: return diodeClipper(input * mGainDB); break;
        }
    }
    
    /** The parameters of this module. */
    enum class ParameterId
    {
        kPreamp,
        kSampleRate,
        kThresh,
        kBypass
    };
    
    /** Different clipper types*/
    enum class ClipType
    {
        kHard,
        kSoft,
        kDiode
    };
        
    /** One method to change any parameter. */
    void setParameter(ParameterId parameter, SampleType parameterValue);
    void setClipperType(ClipType clipType);
    
private:
    
    // Member variables
    bool mGlobalBypass;
    juce::SmoothedValue<float> mRawGain;
    float mCurrentSampleRate, mThresh, mPiDivisor, mGainDB;
    
    // Methods
    SampleType hardClipData(SampleType dataToClip, const float thresh);
    SampleType softClipData(SampleType dataToClip);
    SampleType diodeClipper(SampleType dataToClip);
    
    ClipType mClipType;
};
} // namespace viator_dsp

#endif /* Clipper_h */



cpp
#include "Clipper.h"

template <typename SampleType>
viator_dsp::Clipper<SampleType>::Clipper() :
mGlobalBypass(false), mThresh(1.0f), mGainDB(1.0), mClipType(viator_dsp::Clipper<SampleType>::ClipType::kHard)
{
    mPiDivisor = 2.0 / juce::MathConstants<float>::pi;
}

template <typename SampleType>
void viator_dsp::Clipper<SampleType>::prepare(const juce::dsp::ProcessSpec& spec)
{
    mCurrentSampleRate = spec.sampleRate;
    mRawGain.reset(mCurrentSampleRate, 0.02);
    mRawGain.setTargetValue(0.0);
}

template <typename SampleType>
void viator_dsp::Clipper<SampleType>::setParameter(ParameterId parameter, SampleType parameterValue)
{
    switch (parameter)
    {
        case ParameterId::kPreamp:
        {
            mRawGain.setTargetValue(parameterValue); break;
            mGainDB = viator_utils::utils::dbToGain(mRawGain.getNextValue());
        }
        case ParameterId::kSampleRate: mCurrentSampleRate = parameterValue; break;
        case ParameterId::kThresh: mThresh = parameterValue; break;
        case ParameterId::kBypass: mGlobalBypass = static_cast<bool>(parameterValue);
    }
}

template <typename SampleType>
void viator_dsp::Clipper<SampleType>::setClipperType(ClipType clipType)
{
    switch (clipType)
    {
        case ClipType::kHard: mClipType = viator_dsp::Clipper<SampleType>::ClipType::kHard; break;
        case ClipType::kSoft: mClipType = viator_dsp::Clipper<SampleType>::ClipType::kSoft; break;
        case ClipType::kDiode: mClipType = viator_dsp::Clipper<SampleType>::ClipType::kDiode; break;
    }
}

template <typename SampleType>
SampleType viator_dsp::Clipper<SampleType>::hardClipData(SampleType dataToClip, const float thresh)
{
    /** Don't do anything if the module is off*/
    if (mGlobalBypass) return dataToClip;
    
    /** Hard Clipping algorithim*/
    if (std::abs(dataToClip) > thresh)
    {
        dataToClip *= thresh / std::abs(dataToClip);
    }
    
    return dataToClip;
}

template <typename SampleType>
SampleType viator_dsp::Clipper<SampleType>::softClipData(SampleType dataToClip)
{
    /** Don't do anything if the module is off*/
    if (mGlobalBypass) return dataToClip;
    
    /** Soft Clipping algorithim*/
    auto softClipper = mPiDivisor * std::atan(dataToClip) * 2.0;
    
    /** Auto gain stage the soft clipper*/
    softClipper *= viator_utils::utils::dbToGain(-mRawGain.getNextValue() * 0.25);
    
    return softClipper;
}

template <typename SampleType>
SampleType viator_dsp::Clipper<SampleType>::diodeClipper(SampleType dataToClip)
{
    /** Don't do anything if the module is off*/
    if (mGlobalBypass) return dataToClip;
    
    /** Diode Clipping algorithim*/
    auto diode = 0.105 * (juce::dsp::FastMathApproximations::exp(0.1 * dataToClip / (2.0 * 0.0253)) - 1.0);
    diode -= 0.28;
    diode *= 3.0;
    
    return softClipData(diode);
}
template class viator_dsp::Clipper<float>;
template class viator_dsp::Clipper<double>;


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.