Dial Rotate

Hello

I have made a custom look and feel class for my dial to rotate, But it won’t rotate even though it comes up on the interface, Does anyone have any idea how to rectify this? Thanks.

Not going to be an easy question to answer without seeing your code - there could be multiple reasons things aren’t working.

I do something like this

addAndMakeVisible(mVelModSlider);
mVelModSlider.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
mVelModSlider.hideTextBox(true);
mVelModSlider.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, true, 1, 1);
mVelModSlider.setRange(0, 127);
mVelModSlider.setValue(64);
mVelModSlider.setColour(juce::Slider::rotarySliderFillColourId, juce::Colours::green);
mVelModSlider.setColour(juce::Slider::rotarySliderOutlineColourId, juce::Colours::darkgrey);
mVelModSlider.setColour(juce::Slider::thumbColourId, juce::Colours::transparentBlack);
mVelModSlider.addListener(this);

Just a wild guess, but could using transparentBlack for the thumb be the problem? Would that show up over the green background of the slider?

Thanks for that, I’ve done that part what did you put in the plugineditor.h file

| mihai
November 21 |

  • | - |

I do something like this

addAndMakeVisible(mVelModSlider);
mVelModSlider.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
mVelModSlider.hideTextBox(true);
mVelModSlider.setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, true, 1, 1);
mVelModSlider.setRange(0, 127);
mVelModSlider.setValue(64);
mVelModSlider.setColour(juce::Slider::rotarySliderFillColourId, juce::Colours::green);
mVelModSlider.setColour(juce::Slider::rotarySliderOutlineColourId, juce::Colours::darkgrey);
mVelModSlider.setColour(juce::Slider::thumbColourId, juce::Colours::transparentBlack);
mVelModSlider.addListener(this);

Will send over the code later. Thanks.

You can remove all that, if you declare your slider like this:

juce::Slider mVelModSlider { juce::Slider::RotaryVerticalDrag, juce::Slider::NoTextBox };

But unrelated to your problem… the transparentBlack sounds like a good lead

1 Like

This is from the plugineditor.cpp and .h

I have done those parts already, But what did you put in the plugineditor.h file for your dial to come on the interface, Not the default slider

I have done those parts already, But what did you put in the plugineditor.h file for your dial to come on the interface, Not the default slider but your own slider? Thanks

Thanks.

idk if it’s related to your issue but since this is for a plugin you better get into the habit of not using Slider::Listener but SliderAttachment to attach a parameter to a slider. cause then information about the parameter state is owned by the parameter only and the slider only visualizes it. in practice that means you don’t have to call setValue, setRange and all that on your sliders anymore. they know this automatically from the attachment then. the only methods left in your editor are purely about the look and feel then which is less errorprone and easier to read as well

Thanks fro that but i am getting this one error.

(attachments)

Thanks for getting back to me, But i am still getting this, If i sent you the file are you able to do this? Thanks.

i would read the code, yes

I am trying to upload the file, But it said it is to big.

This is the plugineditor.cpp //setLookAndFeel(&customLookAndFeel);
// Make sure that before the constructor has finished, you’ve set the
// editor’s size to whatever you need it to be.

//Load Images

// knob1= juce::ImageFileFormat::loadFrom(BinaryData::BlackDials_png, BinaryData::BlackDials_pngSize);
// knob2= juce::ImageFileFormat::loadFrom(BinaryData::BlackKnob2_png, BinaryData::BlackKnob2_pngSize);
// SwitchUP = juce::ImageFileFormat::loadFrom(BinaryData::switchmetal1_png, BinaryData::switchmetal1_pngSize);
// SwitchDown = juce::ImageFileFormat::loadFrom(BinaryData::switchmetal2_png, BinaryData::switchmetal2_pngSize);
// Slider3 = juce::ImageFileFormat::loadFrom(BinaryData::slider3_png, BinaryData::slider3_pngSize);
// Led_Clear = juce::ImageFileFormat::loadFrom(BinaryData::led_clear_png, BinaryData::led_clear_pngSize);
// Led_Red = juce::ImageFileFormat::loadFrom(BinaryData::led_red_png, BinaryData::led_red_pngSize);

/* addAndMakeVisible(Switch);
Switch.setImages(false, false, true,
    SwitchUP, 1.0, {}, juce::Image(), 1.0, {},
SwitchDown, 1.0f, {});
Switch.setToggleable(true);
Switch.setToggleState(false, juce::dontSendNotification);
Switch.onClick = [this]
    {
        if (Switch.getToggleState() == false)
        {
            Switch.setToggleState(!Switch.getToggleState(), juce::dontSendNotification);
        }
        else if (Switch.getToggleState() == true)
        {
            Switch.setToggleState(!Switch.getToggleState(), juce::dontSendNotification);
        }
        audioProcessor.OnOff = Switch.getToggleState();
    }; */


setSize (600, 350);

// setResizable(true, true);
// setResizeLimits(575, 218.5, 700, 700);
// getConstrainer()->setFixedAspectRatio(1.0);

addAndMakeVisible(gain);

// auto* param = dynamic_castjuce::AudioParameterFloat*(audioProcessor.getParameters()[0]);

gain.setRange(0.0,100.0,0.1);
gain.setSliderStyle(juce::Slider::SliderStyle::RotaryVerticalDrag);
gain.setTextBoxStyle(juce::Slider::TextBoxBelow, false,55,20);
gain.setTextValueSuffix("dB");
gain.setColour(juce::Slider::ColourIds::textBoxTextColourId, juce::Colours::white);
gain.centreWithSize(150, 250);
gain.setDoubleClickReturnValue(true, 0.0);
gain.setValue(-100);
gain.onValueChange = [this]() {
  float gainVal = juce::Decibels::decibelsToGain((float)gain.getValue());
  *dynamic_cast<juce::AudioParameterFloat*>(audioProcessor.getParameters()[0]) = gainVal;

plugineditor.h #pragma once

#include <JuceHeader.h>
#include “PluginProcessor.h”
//#include “ImageKnob.h”
//#include “CustomLookAndFeel.h”

//==============================================================================
/**
*/
class DistortionAudioProcessorEditor : public juce::AudioProcessorEditor
{
public:
DistortionAudioProcessorEditor (DistortionAudioProcessor&);
~DistortionAudioProcessorEditor() override;

//==============================================================================
void paint (juce::Graphics&) override;
void resized() override;

private:
// This reference is provided as a quick way for your editor to
// access the processor object that created it.
DistortionAudioProcessor& audioProcessor;

juce::Image background,Blackknob2,SwitchUP,SwitchDown,BlackDials,LedRed,LedClear,Slider3;
juce::Slider gain;
juce::Slider low ;
juce::Slider high;
juce::Slider crunch;
juce::ComboBox DropdownMenu;


// Attachments sliders with parameters
 std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> gainAttachment;
 std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> crunchAttachment;
 std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> lowAttachment;
 std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> highAttachment;






// This reference is provided as a quick way for your editor to
// access the processor object that created it.

// GainAudioProcessor& audioProcessor;

// Custom look and feel

// CustomLookAndFeel customLookAndFeel;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DistortionAudioProcessorEditor)

};

Thanks

ok so here are the things that stand out to me, without knowing if any of these fixes your problem:

  1. you initiate a lot of slider/knob-related images in the editor. i think those belong into your custom lookAndFeel class, where you use them to implement the sliders’ look and feel.
  2. the switch is related to the audioProcessor, so it should probably represent a plugin parameter and thus be solved with ButtonAttachment instead of manually setting the click behaviour and stuff
  3. the gain parameter should also not need all these method cals with setTextValueSuffix and setValue etc, because you use the SliderAttachments for that
  4. you have a lot of inconsistency with uppercase and lowercase variables. that’s confusing to read because i’m used to uppercase words relating to class names and constexprs
  5. the sliderAttachments don’t need to be wrapped in unique_ptrs, unless you wanna dynamically reasign sliders to other parameters sometimes. it doesn’t look like it. instead you can initialize them in the initializer list. make sure that the slider was initialized before its attachment.
  6. there is no lookAndFeel code in the code you are showing, so idk why your images don’t do the right thing

Thanks for getting back to me, As the file size is to big to send via the website is there another way to send the file?

Mrugalla
December 13 |

  • | - |

ok so here are the things that stand out to me, without knowing if any of these fixes your problem:

  1. you initiate a lot of slider/knob-related images in the editor. i think those belong into your custom lookAndFeel class, where you use them to implement the sliders’ look and feel.
  2. the switch is related to the audioProcessor, so it should probably represent a plugin parameter and thus be solved with ButtonAttachment instead of manually setting the click behaviour and stuff
  3. the gain parameter should also not need all these method cals with setTextValueSuffix and setValue etc, because you use the SliderAttachments for that
  4. you have a lot of inconsistency with uppercase and lowercase variables. that’s confusing to read because i’m used to uppercase words relating to class names and constexprs
  5. the sliderAttachments don’t need to be wrapped in unique_ptrs, unless you wanna dynamically reasign sliders to other parameters sometimes. it doesn’t look like it. instead you can initialize them in the initializer list. make sure that the slider was initialized before its attachment.
  6. there is no lookAndFeel code in the code you are showing, so idk why your images don’t do the right thing