Commit 08170c1f authored by Jonathan Hyde's avatar Jonathan Hyde

Various fixes and improvements

parent 6c90498b
......@@ -113,7 +113,7 @@ UtilityAudioProcessorEditor::UtilityAudioProcessorEditor (UtilityAudioProcessor&
addAndMakeVisible(&m_softClip);
m_panL.setSliderStyle(Slider::RotaryVerticalDrag);
m_panL.setRange(0.0f, 1.0f, 0.01f);
m_panL.setRange(0.0f, 1.0f, 0.005f);
m_panL.setMouseCursor(MouseCursor::UpDownResizeCursor);
m_panL.setVelocityBasedMode(false);
m_panL.setVelocityModeParameters(0.5, 2, 0.01);
......@@ -124,7 +124,7 @@ UtilityAudioProcessorEditor::UtilityAudioProcessorEditor (UtilityAudioProcessor&
m_panL.addListener(this);
m_panR.setSliderStyle(Slider::RotaryVerticalDrag);
m_panR.setRange(0.0f, 1.0f, 0.01f);
m_panR.setRange(0.0f, 1.0f, 0.005f);
m_panR.setMouseCursor(MouseCursor::UpDownResizeCursor);
m_panR.setVelocityBasedMode(false);
m_panR.setVelocityModeParameters(0.5, 2, 0.01);
......@@ -135,7 +135,7 @@ UtilityAudioProcessorEditor::UtilityAudioProcessorEditor (UtilityAudioProcessor&
m_panR.addListener(this);
m_prePan.setSliderStyle(Slider::RotaryVerticalDrag);
m_prePan.setRange(0.0f, 1.0f, 0.01f);
m_prePan.setRange(0.0f, 1.0f, 0.005f);
m_prePan.setMouseCursor(MouseCursor::UpDownResizeCursor);
m_prePan.setVelocityBasedMode(false);
m_prePan.setVelocityModeParameters(0.5, 2, 0.01);
......@@ -157,6 +157,8 @@ UtilityAudioProcessorEditor::UtilityAudioProcessorEditor (UtilityAudioProcessor&
m_lprePan.setFont(12);
getPrePanText();
m_lchannel.setJustificationType(Justification::centred);
addChildComponent(&m_panL);
addChildComponent(&m_panR);
addChildComponent(&m_prePan);
......@@ -164,8 +166,9 @@ UtilityAudioProcessorEditor::UtilityAudioProcessorEditor (UtilityAudioProcessor&
addChildComponent(&m_lpanL);
addChildComponent(&m_lpanR);
addChildComponent(&m_lprePan);
addChildComponent(&m_lchannel);
if (*processor.p_input == 0 || *processor.p_input == 1)
if (*processor.p_input == 1 || *processor.p_input == 5)
{
m_panL.setVisible(true);
m_panR.setVisible(true);
......@@ -173,12 +176,22 @@ UtilityAudioProcessorEditor::UtilityAudioProcessorEditor (UtilityAudioProcessor&
m_lpanL.setVisible(true);
m_lpanR.setVisible(true);
}
if (*processor.p_input == 4)
else if (*processor.p_input == 4)
{
m_prePan.setVisible(true);
m_lprePan.setVisible(true);
}
else if (*processor.p_input == 2)
{
m_lchannel.setText("Left channel only", NotificationType::dontSendNotification);
m_lchannel.setVisible(true);
}
else if (*processor.p_input == 3)
{
m_lchannel.setText("Right channel only", NotificationType::dontSendNotification);
m_lchannel.setVisible(true);
}
m_gain.setSliderStyle(Slider::RotaryVerticalDrag);
m_gain.setRange(-35.0f, 35.0f, 0.1f);
......@@ -193,7 +206,7 @@ UtilityAudioProcessorEditor::UtilityAudioProcessorEditor (UtilityAudioProcessor&
m_gain.addListener(this);
m_pan.setSliderStyle(Slider::RotaryVerticalDrag);
m_pan.setRange(0.0f, 1.0f, 0.01f);
m_pan.setRange(0.0f, 1.0f, 0.005f);
m_pan.setMouseCursor(MouseCursor::UpDownResizeCursor);
m_pan.setVelocityBasedMode(false);
m_pan.setVelocityModeParameters(0.5, 2, 0.01);
......@@ -330,10 +343,10 @@ UtilityAudioProcessorEditor::UtilityAudioProcessorEditor (UtilityAudioProcessor&
lnfIn->setColour(FFAU::LevelMeter::lmMeterGradientLowColour, juce::Colours::green);
lnfOut->setColour(FFAU::LevelMeter::lmMeterGradientLowColour, juce::Colours::green);
meterIn = new FFAU::LevelMeter(FFAU::LevelMeter::MeterFlags::Default);
meterIn = new FFAU::LevelMeter(FFAU::LevelMeter::MaxNumber | FFAU::LevelMeter::Minimal);
meterIn->setLookAndFeel(lnfIn);
meterIn->setMeterSource(processor.getMeterSourceIn());
meterOut = new FFAU::LevelMeter(FFAU::LevelMeter::MeterFlags::Default);
meterOut = new FFAU::LevelMeter(FFAU::LevelMeter::MaxNumber | FFAU::LevelMeter::Minimal);
meterOut->setLookAndFeel(lnfOut);
meterOut->setMeterSource(processor.getMeterSourceOut());
addAndMakeVisible(meterIn);
......@@ -401,6 +414,8 @@ void UtilityAudioProcessorEditor::resized()
m_prePan.setBounds(horShift + 77, 67, 34, 34);
m_lprePan.setBounds(horShift + 64, 93, 60, 24);
m_lchannel.setBounds(horShift, 67, 200, 24);
m_mute.setBounds(horShift + 30, vertShift + 90, 40, 24);
m_pad.setBounds(horShift + 80, vertShift + 90, 40, 24);
m_DCoffset.setBounds(horShift + 130, vertShift + 90, 40, 24);
......@@ -615,6 +630,18 @@ void UtilityAudioProcessorEditor::comboBoxChanged(ComboBox * comboBoxThatHasChan
m_panR.setVisible(false);
m_lpanL.setVisible(false);
m_lpanR.setVisible(false);
if (*processor.p_input == 2)
{
m_lchannel.setText("Left channel only", NotificationType::dontSendNotification);
m_lchannel.setVisible(true);
}
else if (*processor.p_input == 3)
{
m_lchannel.setText("Right channel only", NotificationType::dontSendNotification);
m_lchannel.setVisible(true);
}
}
else
{
......@@ -622,12 +649,14 @@ void UtilityAudioProcessorEditor::comboBoxChanged(ComboBox * comboBoxThatHasChan
m_panR.setVisible(true);
m_lpanL.setVisible(true);
m_lpanR.setVisible(true);
m_lchannel.setVisible(false);
}
if (*processor.p_input == 4)
{
m_prePan.setVisible(true);
m_lprePan.setVisible(true);
m_lchannel.setVisible(false);
}
else
{
......@@ -705,6 +734,18 @@ void UtilityAudioProcessorEditor::timerCallback()
m_panR.setVisible(false);
m_lpanL.setVisible(false);
m_lpanR.setVisible(false);
if (*processor.p_input == 2)
{
m_lchannel.setText("Left channel only", NotificationType::dontSendNotification);
m_lchannel.setVisible(true);
}
else if (*processor.p_input == 3)
{
m_lchannel.setText("Right channel only", NotificationType::dontSendNotification);
m_lchannel.setVisible(true);
}
}
else
{
......@@ -712,12 +753,14 @@ void UtilityAudioProcessorEditor::timerCallback()
m_panR.setVisible(true);
m_lpanL.setVisible(true);
m_lpanR.setVisible(true);
m_lchannel.setVisible(false);
}
if (*processor.p_input == 4)
{
m_prePan.setVisible(true);
m_lprePan.setVisible(true);
m_lchannel.setVisible(false);
}
else
{
......
......@@ -80,6 +80,7 @@ private:
Label m_lWidth;
Label m_lLowpass;
Label m_lHighpass;
Label m_lchannel;
void getGainDB();
void getPanText();
......
......@@ -140,6 +140,8 @@ void UtilityAudioProcessor::changeProgramName (int index, const String& newName)
//==============================================================================
void UtilityAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
m_firstBuffer = true;
inFilterL.set_input_sampling_rate(sampleRate);
inFilterL.set_output_sampling_rate(sampleRate);
inFilterL2.set_input_sampling_rate(sampleRate);
......@@ -353,7 +355,10 @@ void UtilityAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer&
if (rampGainL != m_prevGainL)
{
buffer.applyGainRamp(0, 0, numSamples, m_prevGainL, rampGainL);
if (!m_firstBuffer)
buffer.applyGainRamp(0, 0, numSamples, m_prevGainL, rampGainL);
else
buffer.applyGain(0, 0, numSamples, rampGainL);
m_prevGainL = rampGainL;
}
else
......@@ -363,7 +368,10 @@ void UtilityAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer&
if (rampGainR != m_prevGainR)
{
buffer.applyGainRamp(1, 0, numSamples, m_prevGainR, rampGainR);
if (!m_firstBuffer)
buffer.applyGainRamp(1, 0, numSamples, m_prevGainR, rampGainR);
else
buffer.applyGain(1, 0, numSamples, rampGainR);
m_prevGainR = rampGainR;
}
else
......@@ -406,6 +414,8 @@ void UtilityAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer&
clipSamples(buffer);
meterSourceOut.measureBlock(buffer);
m_firstBuffer = false;
}
//==============================================================================
......@@ -514,6 +524,12 @@ void UtilityAudioProcessor::convertMono(AudioSampleBuffer & buffer)
rampGainR = *p_prePan;
}
if (m_firstBuffer)
{
m_prevPrePan = *p_prePan;
m_prevPreGainL = rampGainL;
m_prevPreGainR = rampGainR;
}
if (*p_prePan != m_prevPrePan)
{
......@@ -551,7 +567,7 @@ void UtilityAudioProcessor::midSideProcess(AudioSampleBuffer & buffer)
{
int numSamples = buffer.getNumSamples();
float* channelDataL = buffer.getWritePointer(0);
float *channelDataL = buffer.getWritePointer(0);
float *channelDataR = buffer.getWritePointer(1);
float *midData = m_midBuffer.getWritePointer(0);
float *sideData = m_sideBuffer.getWritePointer(0);
......@@ -577,6 +593,12 @@ void UtilityAudioProcessor::midSideProcess(AudioSampleBuffer & buffer)
sideData[i] = (channelDataL[i] - channelDataR[i]) * OVERRTTWO;
}
if (m_firstBuffer)
{
m_prevGainM = finalGainM;
m_prevGainS = finalGainS;
}
if (finalGainM != m_prevGainM)
{
m_midBuffer.applyGainRamp(0, numSamples, m_prevGainM, finalGainM);
......@@ -702,6 +724,16 @@ void UtilityAudioProcessor::channelPans(AudioSampleBuffer & buffer)
float r_rampGainL = cos(*p_panR * 2 * M_PI / 4); //* 1.414f;
float r_rampGainR = sin(*p_panR * 2 * M_PI / 4); //* 1.414f;
if (m_firstBuffer)
{
l_prevRampGainL = l_rampGainL;
l_prevRampGainR = l_rampGainR;
r_prevRampGainL = r_rampGainL;
r_prevRampGainR = r_rampGainR;
m_prevPanL = *p_panL;
m_prevPanR = *p_panR;
}
if (*p_panL != m_prevPanL || *p_panR != m_prevPanR)
{
......
......@@ -148,6 +148,8 @@ private:
float m_prevGainMDB = 0.0f;
float m_prevGainSDB = 0.0f;
bool m_firstBuffer = true;
void convertMono(AudioSampleBuffer &buffer);
void midSideProcess(AudioSampleBuffer &buffer);
void clipSamples(AudioSampleBuffer &buffer);
......
......@@ -60,9 +60,6 @@
#include <juce_gui_basics/juce_gui_basics.h>
#include <juce_events/juce_events.h>
#include <ff_meters/ff_meters_LevelMeterSource.h>
#include <ff_meters/ff_meters_LevelMeter.h>
#include <ff_meters/ff_meters_LookAndFeel.h>
This diff is collapsed.
This diff is collapsed.
......@@ -34,46 +34,49 @@
*/
#pragma once
namespace FFAU
{
class LevelMeterSource;
/** @addtogroup ff_meters */
/*@{*/
class LevelMeterSource;
/**
\class LevelMeterLookAndFeel
\brief Convenience LookAndFeel which derives from LookAndFeel_V3 and LevelMeter::LookAndFeelMethods
/** @addtogroup ff_meters */
/*@{*/
This is the shortcut, to get a component going without inheriting any LookAndFeel class.
If you write your own LookAndFeel, you can include ff_meters_LookAndFeelMethods.h inside your LookAndFeel:
/**
\class LevelMeterLookAndFeel
\brief Convenience LookAndFeel which derives from LookAndFeel_V3 and LevelMeter::LookAndFeelMethods
\code{.cpp}
class MyLookAndFeel : public LookAndFeel_V4, LevelMeter::LookAndFeelMethods
{
public:
This is the shortcut, to get a component going without inheriting any LookAndFeel class.
If you write your own LookAndFeel, you can include ff_meters_LookAndFeelMethods.h inside your LookAndFeel:
#include "ff_meters_LookAndFeelMethods.h"
\code{.cpp}
class MyLookAndFeel : public LookAndFeel_V4, LevelMeter::LookAndFeelMethods
{
public:
#include "ff_meters_LookAndFeelMethods.h"
// ...
// ...
};
\endcode
*/
class LevelMeterLookAndFeel : public juce::LookAndFeel_V3, public LevelMeter::LookAndFeelMethods
{
public:
LevelMeterLookAndFeel()
{
setupDefaultMeterColours();
}
};
\endcode
*/
class LevelMeterLookAndFeel : public juce::LookAndFeel_V3, public LevelMeter::LookAndFeelMethods
{
public:
LevelMeterLookAndFeel ()
{
setupDefaultMeterColours();
}
virtual ~LevelMeterLookAndFeel() {}
virtual ~LevelMeterLookAndFeel() {}
// do this include inside the class to get the default implementation instead of copying it there
#include "ff_meters_LookAndFeelMethods.h"
// do this include inside the class to get the default implementation instead of copying it there
#include "ff_meters_LookAndFeelMethods.h"
};
}
};
/*@}*/
} // end namespace FFAU
......@@ -112,7 +112,9 @@ juce::Rectangle<float> getMeterBarBounds (const juce::Rectangle<float> bounds,
else {
const float margin = bounds.getWidth() * 0.05;
const float top = bounds.getY() + 2.0 * margin + bounds.getWidth() * 0.5;
const float bottom = bounds.getBottom() - margin;
const float bottom = (meterType & FFAU::LevelMeter::MaxNumber) ?
bounds.getBottom() - (3.0f * margin + (bounds.getWidth() - margin * 2.0))
: bounds.getBottom() - margin;
return juce::Rectangle<float>(bounds.getX() + margin, top,
bounds.getWidth() - margin * 2.0, bottom - top);
}
......@@ -232,7 +234,26 @@ juce::Rectangle<float> getMeterMaxNumberBounds (const juce::Rectangle<float> bou
const FFAU::LevelMeter::MeterFlags meterType) const override
{
if (meterType & FFAU::LevelMeter::Minimal) {
return juce::Rectangle<float>();
if (meterType & FFAU::LevelMeter::MaxNumber) {
if (meterType & FFAU::LevelMeter::Horizontal) {
const float margin = bounds.getHeight() * 0.05;
const float h = bounds.getHeight() - 2.0 * margin;
return juce::Rectangle<float>(bounds.getRight() - (margin + h * 0.5),
bounds.getY() + margin,
h * 0.5, h);
}
else {
const float margin = bounds.getWidth() * 0.05;
const float w = bounds.getWidth() - margin * 2.0;
const float h = w * 0.6f;
return juce::Rectangle<float>(bounds.getX() + margin,
bounds.getBottom() - (margin + h),
w, h);
}
}
else {
return juce::Rectangle<float> ();
}
}
else if (meterType & FFAU::LevelMeter::Vintage) {
return bounds;
......@@ -295,6 +316,9 @@ void drawMeterBars (juce::Graphics& g,
juce::Rectangle<float> clip = getMeterClipIndicatorBounds (meter, meterType);
if (! clip.isEmpty())
drawClipIndicator (g, meterType, clip, source->getClipFlag (channel));
juce::Rectangle<float> maxNum = getMeterMaxNumberBounds (meter, meterType);
if (! maxNum.isEmpty())
drawMaxNumber(g, meterType, maxNum, source->getMaxOverallLevel (channel));
if (channel < numChannels-1) {
meter.setY (height * (channel * 2 + 1));
juce::Rectangle<float> ticks = getMeterTickmarksBounds (meter, meterType);
......@@ -314,6 +338,9 @@ void drawMeterBars (juce::Graphics& g,
juce::Rectangle<float> clip = getMeterClipIndicatorBounds (meter, meterType);
if (! clip.isEmpty())
drawClipIndicator (g, meterType, clip, source->getClipFlag (channel));
juce::Rectangle<float> maxNum = getMeterMaxNumberBounds (innerBounds.withWidth (innerBounds.getWidth() / numChannels).withX (innerBounds.getX() + channel * (innerBounds.getWidth() / numChannels)), meterType);
if (! maxNum.isEmpty())
drawMaxNumber(g, meterType, maxNum, source->getMaxOverallLevel (channel));
if (channel < numChannels-1) {
meter.setX (width * (channel * 2 + 1));
juce::Rectangle<float> ticks = getMeterTickmarksBounds (meter, meterType);
......@@ -463,6 +490,10 @@ void drawMeterBar (juce::Graphics& g,
const float rmsDb = juce::Decibels::gainToDecibels (rms, infinity);
const float peakDb = juce::Decibels::gainToDecibels (peak, infinity);
const juce::Rectangle<float> floored (ceilf (bounds.getX()) + 1.0f, ceilf (bounds.getY()) + 1.0f,
floorf (bounds.getRight()) - (ceilf (bounds.getX() + 2.0f)),
floorf (bounds.getBottom()) - (ceilf (bounds.getY()) + 2.0f));
if (meterType & FFAU::LevelMeter::Vintage) {
// TODO
}
......@@ -470,47 +501,47 @@ void drawMeterBar (juce::Graphics& g,
const float limitDb = juce::Decibels::gainToDecibels (rms, infinity);
g.setColour (findColour (FFAU::LevelMeter::lmMeterReductionColour));
if (meterType & FFAU::LevelMeter::Horizontal) {
g.fillRect (bounds.withLeft (bounds.getX() + limitDb * bounds.getWidth() / infinity));
g.fillRect (floored.withLeft (floored.getX() + limitDb * floored.getWidth() / infinity));
}
else {
g.fillRect (bounds.withBottom (bounds.getY() + limitDb * bounds.getHeight() / infinity));
g.fillRect (floored.withBottom (floored.getY() + limitDb * floored.getHeight() / infinity));
}
}
else {
if (meterType & FFAU::LevelMeter::Horizontal) {
juce::ColourGradient gradient (findColour (FFAU::LevelMeter::lmMeterGradientLowColour),
bounds.getX(), bounds.getY(),
floored.getX(), floored.getY(),
findColour (FFAU::LevelMeter::lmMeterGradientMaxColour),
bounds.getRight(), bounds.getY(), false);
floored.getRight(), floored.getY(), false);
gradient.addColour (0.5, findColour (FFAU::LevelMeter::lmMeterGradientLowColour));
gradient.addColour (0.75, findColour (FFAU::LevelMeter::lmMeterGradientMidColour));
g.setGradientFill (gradient);
g.fillRect (bounds.withRight (bounds.getX() - rmsDb * bounds.getWidth() / infinity));
g.fillRect (floored.withRight (floored.getX() - rmsDb * floored.getWidth() / infinity));
if (peakDb > -49.0) {
g.setColour (findColour ((peakDb > -0.3f) ? FFAU::LevelMeter::lmMeterMaxOverColour :
((peakDb > -5.0) ? FFAU::LevelMeter::lmMeterMaxWarnColour :
FFAU::LevelMeter::lmMeterMaxNormalColour)));
g.drawVerticalLine (bounds.getRight() - juce::jmax (peakDb * bounds.getWidth() / infinity, 0.0f),
bounds.getY(), bounds.getBottom());
g.drawVerticalLine (floored.getRight() - juce::jmax (peakDb * floored.getWidth() / infinity, 0.0f),
floored.getY(), floored.getBottom());
}
}
else {
juce::ColourGradient gradient (findColour (FFAU::LevelMeter::lmMeterGradientLowColour),
bounds.getX(), bounds.getBottom(),
floored.getX(), floored.getBottom(),
findColour (FFAU::LevelMeter::lmMeterGradientMaxColour),
bounds.getX(), bounds.getY(), false);
floored.getX(), floored.getY(), false);
gradient.addColour (0.5, findColour (FFAU::LevelMeter::lmMeterGradientLowColour));
gradient.addColour (0.75, findColour (FFAU::LevelMeter::lmMeterGradientMidColour));
g.setGradientFill (gradient);
g.fillRect (bounds.withTop (bounds.getY() + rmsDb * bounds.getHeight() / infinity));
g.fillRect (floored.withTop (floored.getY() + rmsDb * floored.getHeight() / infinity));
if (peakDb > -49.0) {
g.setColour (findColour ((peakDb > -0.3f) ? FFAU::LevelMeter::lmMeterMaxOverColour :
((peakDb > -5.0) ? FFAU::LevelMeter::lmMeterMaxWarnColour :
FFAU::LevelMeter::lmMeterMaxNormalColour)));
g.drawHorizontalLine (bounds.getY() + juce::jmax (peakDb * bounds.getHeight() / infinity, 0.0f),
bounds.getX(), bounds.getRight());
g.drawHorizontalLine (floored.getY() + juce::jmax (peakDb * floored.getHeight() / infinity, 0.0f),
floored.getX(), floored.getRight());
}
}
}
......@@ -549,8 +580,8 @@ void drawTickMarks (juce::Graphics& g,
bounds.getRight());
}
if (h > 10 && bounds.getWidth() > 20) {
// din't print tiny numbers
g.setFont (h * 0.8f);
// don't print tiny numbers
g.setFont (h * 0.3f);
for (int i=0; i<10; ++i) {
g.drawFittedText (juce::String (i * 0.1 * infinity),
bounds.getX(), bounds.getY() + i * h + 2, bounds.getWidth(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment