|
01-10-2017, 06:53 AM
|
#1
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
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.
|
|
|
01-10-2017, 08:59 AM
|
#2
|
Human being with feelings
Join Date: May 2012
Location: PA, USA
Posts: 356
|
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.
|
|
|
01-10-2017, 12:46 PM
|
#3
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Thanks "random_id"!
Worked great for gain!
Last edited by Tunca; 01-10-2017 at 02:27 PM.
|
|
|
01-10-2017, 01:30 PM
|
#4
|
Human being with feelings
Join Date: Apr 2012
Posts: 279
|
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;
|
|
|
01-10-2017, 01:56 PM
|
#5
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Thank you "stw" for another great example!
|
|
|
01-10-2017, 02:36 PM
|
#6
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
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.
|
|
|
01-11-2017, 05:36 AM
|
#7
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Any idea?
|
|
|
01-11-2017, 07:14 AM
|
#8
|
Human being with feelings
Join Date: May 2012
Location: PA, USA
Posts: 356
|
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.
|
|
|
01-11-2017, 11:27 AM
|
#9
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
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.
|
|
|
01-12-2017, 12:22 AM
|
#10
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
|
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?).
|
|
|
01-12-2017, 02:07 AM
|
#11
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Quote:
Originally Posted by Tale
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);
|
|
|
01-12-2017, 05:59 AM
|
#12
|
Human being with feelings
Join Date: May 2012
Location: PA, USA
Posts: 356
|
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.
|
|
|
01-12-2017, 06:29 AM
|
#13
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
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...
|
|
|
01-12-2017, 07:09 AM
|
#14
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
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.
|
|
|
01-12-2017, 10:19 AM
|
#15
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
By the way knob generate audiable click hen i turn them.Why?
|
|
|
01-13-2017, 11:38 AM
|
#16
|
Human being with feelings
Join Date: Sep 2016
Posts: 4
|
Quote:
Originally Posted by Tunca
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.
|
|
|
01-14-2017, 11:19 AM
|
#17
|
Human being with feelings
Join Date: Apr 2016
Posts: 264
|
Quote:
Originally Posted by Add9
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.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 07:24 PM.
|