Source/PluginEditor.cpp
//This function is to create the response Curve Component (the top rectangle)

This function is to create the response Curve Component (the top rectangle)
This function is to create the response Curve Component ( the top rectangle )
void ResponseCurveComponent::updateResponseCurve()
{
    using namespace juce;
    auto responseArea = getAnalysisArea();
    auto w = responseArea.getWidth();
    auto& lowcut = monoChain.get<ChainPositions::LowCut>();
    auto& peak = monoChain.get<ChainPositions::Peak>();
    auto& highcut = monoChain.get<ChainPositions::HighCut>();
    auto sampleRate = audioProcessor.getSampleRate();
    std::vector<double> mags;
    mags.resize(w);
    for( int i = 0; i < w; ++i )
    {
        double mag = 1.f;
        auto freq = mapToLog10(double(i) / double(w), 20.0, 20000.0);
        if(! monoChain.isBypassed<ChainPositions::Peak>() )
            mag *= peak.coefficients->getMagnitudeForFrequency(freq, sampleRate);
        if( !monoChain.isBypassed<ChainPositions::LowCut>() )
        {
            if( !lowcut.isBypassed<0>() )
                mag *= lowcut.get<0>().coefficients->getMagnitudeForFrequency(freq, sampleRate);
            if( !lowcut.isBypassed<1>() )
                mag *= lowcut.get<1>().coefficients->getMagnitudeForFrequency(freq, sampleRate);
            if( !lowcut.isBypassed<2>() )
                mag *= lowcut.get<2>().coefficients->getMagnitudeForFrequency(freq, sampleRate);
            if( !lowcut.isBypassed<3>() )
                mag *= lowcut.get<3>().coefficients->getMagnitudeForFrequency(freq, sampleRate);
        }
        if( !monoChain.isBypassed<ChainPositions::HighCut>() )
        {
            if( !highcut.isBypassed<0>() )
                mag *= highcut.get<0>().coefficients->getMagnitudeForFrequency(freq, sampleRate);
            if( !highcut.isBypassed<1>() )
                mag *= highcut.get<1>().coefficients->getMagnitudeForFrequency(freq, sampleRate);
            if( !highcut.isBypassed<2>() )
                mag *= highcut.get<2>().coefficients->getMagnitudeForFrequency(freq, sampleRate);
            if( !highcut.isBypassed<3>() )
                mag *= highcut.get<3>().coefficients->getMagnitudeForFrequency(freq, sampleRate);
        }
        mags[i] = Decibels::gainToDecibels(mag);
    }
    responseCurve.clear();
    const double outputMin = responseArea.getBottom();
    const double outputMax = responseArea.getY();
    auto map = [outputMin, outputMax](double input)
    {
        return jmap(input, -24.0, 24.0, outputMin, outputMax);
    };
    responseCurve.startNewSubPath(responseArea.getX(), map(mags.front()));
    for( size_t i = 1; i < mags.size(); ++i )
    {
        responseCurve.lineTo(responseArea.getX() + i, map(mags[i]));
    }
}
void ResponseCurveComponent :: updateResponseCurve ( ) { using namespace juce ; auto responseArea = getAnalysisArea ( ) ; auto w = responseArea . getWidth ( ) ; auto & lowcut = monoChain . get < ChainPositions :: LowCut > ( ) ; auto & peak = monoChain . get < ChainPositions :: Peak > ( ) ; auto & highcut = monoChain . get < ChainPositions :: HighCut > ( ) ; auto sampleRate = audioProcessor . getSampleRate ( ) ; std :: vector < double > mags ; mags . resize ( w ) ; for ( int i = 0 ; i < w ; ++ i ) { double mag = 1.f ; auto freq = mapToLog10 ( double ( i ) / double ( w ) , 20.0 , 20000.0 ) ; if ( ! monoChain . isBypassed < ChainPositions :: Peak > ( ) ) mag *= peak . coefficients -> getMagnitudeForFrequency ( freq , sampleRate ) ; if ( ! monoChain . isBypassed < ChainPositions :: LowCut > ( ) ) { if ( ! lowcut . isBypassed < 0 > ( ) ) mag *= lowcut . get < 0 > ( ) . coefficients -> getMagnitudeForFrequency ( freq , sampleRate ) ; if ( ! lowcut . isBypassed < 1 > ( ) ) mag *= lowcut . get < 1 > ( ) . coefficients -> getMagnitudeForFrequency ( freq , sampleRate ) ; if ( ! lowcut . isBypassed < 2 > ( ) ) mag *= lowcut . get < 2 > ( ) . coefficients -> getMagnitudeForFrequency ( freq , sampleRate ) ; if ( ! lowcut . isBypassed < 3 > ( ) ) mag *= lowcut . get < 3 > ( ) . coefficients -> getMagnitudeForFrequency ( freq , sampleRate ) ; } if ( ! monoChain . isBypassed < ChainPositions :: HighCut > ( ) ) { if ( ! highcut . isBypassed < 0 > ( ) ) mag *= highcut . get < 0 > ( ) . coefficients -> getMagnitudeForFrequency ( freq , sampleRate ) ; if ( ! highcut . isBypassed < 1 > ( ) ) mag *= highcut . get < 1 > ( ) . coefficients -> getMagnitudeForFrequency ( freq , sampleRate ) ; if ( ! highcut . isBypassed < 2 > ( ) ) mag *= highcut . get < 2 > ( ) . coefficients -> getMagnitudeForFrequency ( freq , sampleRate ) ; if ( ! highcut . isBypassed < 3 > ( ) ) mag *= highcut . get < 3 > ( ) . coefficients -> getMagnitudeForFrequency ( freq , sampleRate ) ; } mags [ i ] = Decibels :: gainToDecibels ( mag ) ; } responseCurve . clear ( ) ; const double outputMin = responseArea . getBottom ( ) ; const double outputMax = responseArea . getY ( ) ; auto map = [ outputMin , outputMax ] ( double input ) { return jmap ( input , -24.0 , 24.0 , outputMin , outputMax ) ; } ; responseCurve . startNewSubPath ( responseArea . getX ( ) , map ( mags . front ( ) ) ) ; for ( size_t i = 1 ; i < mags . size ( ) ; ++ i ) { responseCurve . lineTo ( responseArea . getX ( ) + i , map ( mags [ i ] ) ) ; } }
This function is to create the response Curve Component (the top rectangle)
This function is to create the response Curve Component ( the top rectangle )