hi, Im trying to edit a knobs sensitivity because it’s well… it’s too sensitive. if I even so much as slightly drag it, it jumps up by increments of .43. I want it to go by increments of .1
p.s. is there a tutorial in the JUCE Tutorial section of setting custom .pngs for knobs and/or Sliders?
You can set the interval of the slider using setRange. If you’re using a parameter attachment you’ll have to set the interval in the parameter RangedAudioParameter itself when you create it.
Could also try setMouseDragSensitivity for the slider sensitivity if its still too strong.
In the past I’ve used juce::ImageComponent to draw png images in components. Something like this:
juce::Image image = juce::ImageFileFormat::loadFrom(BinaryData::image_png, BinaryData::image_pngSize);
thank you! and I’m guessing this is going in the AudioProcessorEditor class? I’m still learning and that’s just where Im assuming it goes or in the paint class… that’s what I’m thinking atleast (for the juce::ImageComponent atleast)
Definitely possible to store the juce::ImageComponent in the AudioProcessorEditor. If you’re using a LookAndFeel it might make more sense to use Graphics::drawImage. Idea is roughly the same, though.
A strategy you could use:
- create a custom LookAndFeel class that overrides the appropriate slider painting methods: Slider::LookAndFeelMethods
- the custom LookAndFeel class contains the Image as a member. The Image gets drawn using the drawImage function. Check out AffineTransform and Graphics::addTransform for rotating the image.
- AudioProcessorEditor contains the custom LookAndFeel and the juce::Slider as members.
- in the constructor for AudioProcessorEditor call setLookAndFeel on your slider with the address of your custom LookAndFeel as its argument.
this video shows you how to add sensitive mousewheel support at all, but you can also use the same technique to adjust the drag sensitivity.
to be more precise: you’d override mouseDrag() and there if ctrl multiply the y-drag offset by some value and then call the base class’ mouseDrag with it.
ok i figured it out. took a bit of tinkering but I think i got the right value… thank you!
also would that code go in the .cpp or .h? reminder that I’m still really new to C++
Here’s a possible way (ignoring boilerplate JUCE stuff) of displaying an image in your editor.
class AudioProcessorEditor : public juce::AudioProcessorEditor
image = juce::ImageFileFormat::loadFrom(BinaryData::image_png, BinaryData::image_pngSize);
for some reason i’m getting a Use of undeclared identifier error ‘BinaryData’ error
ok i fixed it, I forgot to save the jucer project
also i’m guessing I need to replace “image” with the image name?
Yep. When you add a file in the projucer it shows up in the BinaryData namespace. Dots are generally replaced with underscores: “Image.png” →