COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 01-10-2017, 06:53 AM   #1
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default Stepped Frequency or Gain

Now i'm build my first plugin.(Actually bundle)Vintage German EQs.There are three EQs.

EQs use stepped freq. and gain control.How can do that?

For example low band gain 11 steps.(-15,-9,-6,-4,-2,0,2,4,6,9,15)

So i want to do this like this;

I will set min value -6 and max value 6.(Total 11 steps)

mGainL : Low Gain Knob

if (mGainL == -6)
mGainL = -15;

if (mGainL == -5)
mGainL = -12;

if (mGainL == -4)
mGainL = -9;

.
.
.

if (mGainL == 6)
mGainL = 15;

I tried that but it's not working.How can do this in easy way?

Thanks.
Tunca is offline   Reply With Quote
Old 01-10-2017, 08:59 AM   #2
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 286
Default

I think your best bet is to setup the parameters as Int, like
Code:
GetParam(kLowGain)->InitInt("Low Freq Gain", 5, 0, 10);
Then you could set the gain in OnParamChange like
Code:
...
case kLowGain:{
    int g = GetParam(kLowGain)->Value();
    if (g==0) mLowGain = -15.;
    else if (g==1) mLowGain = -9.;
...
    CalcFilterWithNewGain();
}
break;
...
You could put the gain values on the background GUI.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 01-10-2017, 12:46 PM   #3
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

Thanks "random_id"!

Worked great for gain!

Last edited by Tunca; 01-10-2017 at 02:27 PM.
Tunca is offline   Reply With Quote
Old 01-10-2017, 01:30 PM   #4
stw
Human being with feelings
 
Join Date: Apr 2012
Posts: 203
Default

maybe it's easyer to distribute your gain vals by an array instead of crawling thru if else comparisons.

Code:
case kLowGain:{

    int gainvals[11] = {-15,-9,-6,...}
    mLowGain = gainvals[(int)GetParam(kLowGain)->Value()];
}

break;
stw is online now   Reply With Quote
Old 01-10-2017, 01:56 PM   #5
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

Thank you "stw" for another great example!
Tunca is offline   Reply With Quote
Old 01-10-2017, 02:36 PM   #6
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

I tried both of them for frequency but no luck.

Just getting defult value.When i turn my knob,frequency not changing.

My default freq is 2kHz as you can see.Can't change freq.

case kFreqM:{
int freqvals[7] = {700,1000,1400,2000,2800,4000,5600};
mFreqM = freqvals[(int)GetParam(kFreqM)->Value()];
}
break;

Last edited by Tunca; 01-10-2017 at 03:34 PM.
Tunca is offline   Reply With Quote
Old 01-11-2017, 05:36 AM   #7
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

Any idea?
Tunca is offline   Reply With Quote
Old 01-11-2017, 07:14 AM   #8
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 286
Default

One thing to check is that the kFreqM param is initialized as an integer between 0 and 6.

There isn't anything inherently different between the gain settings that were discussed previously and the frequencies. I would step through the code with the debugger and see what values are being returned.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 01-11-2017, 11:27 AM   #9
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

GetParam(kFreqM)->InitInt("FreqM", 3., 0., 6.);
GetParam(kFreqM)->SetShape(1.);

case kFreqM:{
int freqvals[7] = {700,1000,1400,2000,2800,4000,5600};
mFreqM = freqvals[(int)GetParam(kFreqM)->Value()];
}
break;

I initalized it.Tried with your code, also but still no luck.

I checked all code.But can't see any error.

As you can see,default value is "3".So it's 2kHz.If i can set default value to any other freqs,i can see and control it but can't change freq.
Tunca is offline   Reply With Quote
Old 01-12-2017, 12:22 AM   #10
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,773
Default

Although you set mFreqM, I don't see you passing this value to a filter object (but maybe you are doing that elsewhere in your code?).
Tale is offline   Reply With Quote
Old 01-12-2017, 02:07 AM   #11
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

Quote:
Originally Posted by Tale View Post
Although you set mFreqM, I don't see you passing this value to a filter object (but maybe you are doing that elsewhere in your code?).
You mean this?

mFilter3.setBiquad(bq_type_peak, mFreqM / mSampleRate, 1.0, mGainM);

Also i'm doing this but it's not working.

mFilter3.setFc(mFreqM);
mFilter33.setFc(mFreqM);
Tunca is offline   Reply With Quote
Old 01-12-2017, 05:59 AM   #12
random_id
Human being with feelings
 
random_id's Avatar
 
Join Date: May 2012
Location: PA, USA
Posts: 286
Default

Without seeing the entire code, it is hard to tell what is happening.

Since the filter is always set to the default frequency, I suspect turning the control is not calling OnParamChange() for the case kFreqM (therefore, mFreqM is never changing). This could be because the wrong param is used when initializing the knob control. It could also be something weird like missing a break within the OnParamChange.

That is why I would really want to step through the code with the debugger. What is being returned in OnParamChange with GetParam(kFreqM)->Value()? I would also put a break point on the line mFilter3.setBiquad and see what mFreqM is.

There could also be a chance that the code within setBiquad doesn't really change the fc of the filter (maybe that is why it always stays on the default frequency), but I don't know what code you are using for that.

I don't think this is the current problem, but you probably want the filter frequencies to be floating types instead of ints. There might be some problems with casting from ints to floats.
__________________
Website: LVC-Audio
random_id is offline   Reply With Quote
Old 01-12-2017, 06:29 AM   #13
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

setBiquad doesn't let me change freq.

I tried as InitDouble with variable freq but still only affecting to default value.

By the way i'm trying to debugging.Setting breakpoints but i can't debug.I have no idea why.Can't see anything in Debug Navigator.Xcode just building plugin...
Tunca is offline   Reply With Quote
Old 01-12-2017, 07:09 AM   #14
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

Finally fixed it!

Filters were in Reset().I moved them to ProcessDoubleReplacing and now it's working!

Thanks to everyone for help!

Now only trouble with AU versions.AU causes scan everytime for Logic.Any idea?

Last edited by Tunca; 01-12-2017 at 07:17 AM.
Tunca is offline   Reply With Quote
Old 01-12-2017, 10:19 AM   #15
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

By the way knob generate audiable click hen i turn them.Why?
Tunca is offline   Reply With Quote
Old 01-13-2017, 11:38 AM   #16
Add9
Human being with feelings
 
Join Date: Sep 2016
Posts: 4
Default

Quote:
Originally Posted by Tunca View Post
By the way knob generate audiable click hen i turn them.Why?
Because the changes you are making are having an instantaneous change on the output samples, causing a jump from one value to the next. Anytime this happens you will hear a click, the magnitude of which depends on how far the sample value happens to jump.

You can get rid of the click simply by applying a low pass filter to the parameter itself (so that, for example, the output is the average of the previous n values). That way even if you do make an instantaneous change to a parameter, you won't get any clicks because your parameter will change gracefully from one value to the next. This will still achieve the step-like effect you are going for if you keep n low, from like 10-25 samples, but you won't hear a click anymore.
Add9 is offline   Reply With Quote
Old 01-14-2017, 11:19 AM   #17
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 107
Default

Quote:
Originally Posted by Add9 View Post
Because the changes you are making are having an instantaneous change on the output samples, causing a jump from one value to the next. Anytime this happens you will hear a click, the magnitude of which depends on how far the sample value happens to jump.

You can get rid of the click simply by applying a low pass filter to the parameter itself (so that, for example, the output is the average of the previous n values). That way even if you do make an instantaneous change to a parameter, you won't get any clicks because your parameter will change gracefully from one value to the next. This will still achieve the step-like effect you are going for if you keep n low, from like 10-25 samples, but you won't hear a click anymore.
Thanks for reply! I will try what you say.
Tunca is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:45 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.