Precision gain reduction idea

hi i have an idea for a plug-in
i’m not looking to make money from it but i was hoping someone might be interested enough to teach me how to code my idea.
my fluency with c++ is very limited but i think i have a good idea. any help would be appreciated…

here’s my idea…

precision incremental gain reduction (idea)

gain reduction fader{

0 = off // input level

100.00 = max gain reduction}
//possibly more than 100.00 considering potential functionality//

gain reduction multiplier knob array{

reduction vol1 = input level 0.99940

reduction vol*2 = input level * 0.99880

reduction vol*3 = input level * 0.99820

reduction vol*4 = input level * 0.99760

reduction vol*5 = input level * 0.99700

reduction vol*6 = input level * 0.99640

reduction vol*7 = input level * 0.99580

reduction vol*8 = input level * 0.99520

reduction vol*9 = input level * 0.99460

reduction vol*10 = input level * 0.99400

reduction vol*11 = input level * 0.99340

reduction vol*12 = input level * 0.99280

reduction vol*13 = input level * 0.99220

reduction vol*14 = input level * 0.99160

reduction vol*15 = input level * 0.99100

reduction vol*16 = input level * 0.99040

reduction vol*17 = input level * 0.98980

reduction vol*18 = input level * 0.98920

reduction vol*19 = input level * 0.98860

reduction vol*20 = input level * 0.98800

reduction vol*21 = input level * 0.98740

reduction vol*22 = input level * 0.98680

reduction vol*23 = input level * 0.98620

reduction vol*24 = input level * 0.98560

reduction vol*25 = input level * 0.98500

}

I find your pseudo code confusing, I don’t know what you want to achieve.
Maybe someone will understand better, but could you explain your idea with words?

i want to be able to reduce volume precisely with a gain fader and i want to multiply the amount of reduction with a knob

Ok so that should be trivial. You can take the JUCE Gain Plugin Demo, and simply add a second parameter that would be the amount of reduction.

right i get that but how would i be able to change how much the reduction is multiplied by incrementally while still having the input mix amount fader?

you’ll have to learn how to make juce projects at all first. use the official tutorials as well the juce6-ones by the audio programmer on youtube, and the cherno for c++.

then, when you know the basics, like how parameters work, how the processor and editor interact with each other, how to serialize state etc., you can make your project.

if i get you right it’s basically a gain knob where 0 means no change and 100 means silence. changing a signal’s gain is the process of muliplying it with a number. say you have a sample called “sample”, letting it have the same volume as before is
sample *= 1

letting it have silence is
sample *= 0

so your parameter would need to go from 1 to 0.

so you can have a juce::RangedAudioParameter have values between 0 and 1, then let its value-to-string lambda multiply its output with 100 so that it looks like a 0 to 100 range, but in your dsp code you’d do 1 - parameterValue, so that 0to1 becomes 1to0. you’d then multiply that with your signal. a 2nd parameter could then be used to give that gain value even more of an offset based on the logic you described in your pseudo-code, which i also don’t fully understand, but i understand enough to see that you wanna manipulate the gain reduction value before using it on the signal.

at some point tho, you’ll realize that directly manipulating gain with a 0to1 range can feel a little tricky, which is why decibel scales are usually used for gain-stuff. the juce::Decibels class has useful helper functions to convert a value from db to gain and from gain to db. then you could define your gain reduction parameter differently. only problem is that decibel values only approach gain=0 but never reach it. usually this is solved by just saying if the db value is lower than some inaudible threshold, then just return 0.

if some of this is confusing now, don’t worry, it will make sense when you dive into your project practically

wow thanks! that is a lot to take in but so far it makes a lot of sense