|
09-02-2010, 04:02 PM
|
#1
|
Human being with feelings
Join Date: Apr 2009
Posts: 191
|
Logarithmic knob Frequency Scaling
Hi!
Is in IPlug any way to specify the scale to use in a knob?
I've a knob from 20 to 22000 hz, it is very hard to set low frequencies.
Thanks
|
|
|
09-02-2010, 10:45 PM
|
#2
|
Human being with feelings
Join Date: Nov 2009
Location: memory
Posts: 633
|
sure, the faders in the iplug example project are logarithmically scaled to db. so as one moves a
fader down: the db reduction per unit of fader travel becomes progressively greater. similarly,
one could apply any 2 dimensional curve function to any fader or knob.
|
|
|
09-03-2010, 03:04 AM
|
#3
|
Human being with feelings
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
|
Code:
GetParam(kFilterCutoff)->InitDouble("Cutoff", 1000., 20., 10000., 0.000001, "Hz");
GetParam(kFilterCutoff)->SetShape(2.);
"The higher the shape, the more resolution around host value zero."
it doesn't work in AUs when you use the default interface
oli
|
|
|
09-03-2010, 08:28 AM
|
#4
|
Human being with feelings
Join Date: Apr 2009
Posts: 191
|
Quote:
Originally Posted by olilarkin
Code:
GetParam(kFilterCutoff)->InitDouble("Cutoff", 1000., 20., 10000., 0.000001, "Hz");
GetParam(kFilterCutoff)->SetShape(2.);
"The higher the shape, the more resolution around host value zero."
it doesn't work in AUs when you use the default interface
oli
|
thanks it works fine
|
|
|
09-03-2010, 06:49 PM
|
#5
|
Human being with feelings
Join Date: Nov 2009
Location: memory
Posts: 633
|
Quote:
Originally Posted by olilarkin
"The higher the shape, the more resolution around host value zero."
|
cool, i am starting to understand how to use the IParam class a bit better
from this tip, (i mean classes in general, seeing as i'm also learning c+)
e.g. i am calculating normalized values to set controls, but
i think i notice now there is a function to do that ( SetNormalized() ) ?
Quote:
it doesn't work in AUs when you use the default interface
|
thanks. that is useful to know: for now i have scaled a control by
applying a calculated curve to the variable it affects.
Last edited by cerberus; 09-03-2010 at 06:56 PM.
|
|
|
10-19-2014, 08:14 PM
|
#6
|
Human being with feelings
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
|
What's the math behind SetShape?
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
|
|
|
10-19-2014, 11:13 PM
|
#7
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
|
I believe f(x) = x^shape, see FromNormalizedParam() and ToNormalizedParam() in IParam.h.
|
|
|
10-21-2014, 01:37 AM
|
#8
|
Human being with feelings
Join Date: Nov 2008
Posts: 108
|
it's pow(normalized, SHAPE) and the reverse is done with pow(normalized, 1.0/SHAPE)
at shape 2.0 you get 0.25 (25%) in the middle of the param
i often want to set the shape so that a specific value of the parameter falls on the center
say, you have a freq param going from 20Hz to 18000Hz and you want to have 500Hz in the center
i can't pretend to like maths, so i use wolframalpha or a similar tool
the formula to get the "shape" is:
Code:
min + (0.5^x) * (max-min) = value
so in my case:
20 + (0.5^x) * (18000-20) = 500
http://www.wolframalpha.com/input/?i=20+%2B+%280.5^x%29+*+%2818000-20%29+%3D+500%2C+solve+for+real+x
shape = 5.2272
|
|
|
10-21-2014, 02:46 AM
|
#9
|
Human being with feelings
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
|
thanks, very helpfuel!!
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
|
|
|
07-10-2017, 01:40 AM
|
#10
|
Human being with feelings
Join Date: Nov 2015
Location: Germany
Posts: 82
|
Quote:
Originally Posted by olilarkin
it doesn't work in AUs when you use the default interface
oli
|
Does anybody manage to assign a logarithmic frequency parameter to the AU automation ? I tried this my setting the flag kAudioUnitParameterFlag_DisplayLogarithmic and unit kAudioUnitParameterUnit_Hertz in IPlugAU.cpp and the AU validation shows that the flag/unit is assign correctly but the automation lines at least in Reaper and Garageband are still linear (very low resolution in the lower frequencies). Studio one additionally displays wrong frequency numbers, but it seems that the line is logarithmic. It seems that the flag is somehow ignored in some DAWs.
|
|
|
07-31-2018, 03:10 PM
|
#11
|
Human being with feelings
Join Date: Jul 2018
Posts: 24
|
Thanks to this old thread I could figure this out. After having some struggle with reactivating my old school math the equation should be:
shape = log((center value - min) / (max - min)) / log(0.5)
so, for antto's example (filter from 20 to 18000 centered @ 500 Hz:
shape = log((500-20) / (18000 - 20)) / log(0.5) = 5.2272148047932911480721579798557
So, you won't need to have a Wolfram Alpha premium account, the calculator on the table solves it. The 0.5 can be adjusted to where ever the knob should default, in the middle should work in most cases.
If anybody can tell me, which log is actually right, I would appreciate it. In this example both LN and LOG works.
|
|
|
08-01-2018, 12:51 AM
|
#12
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
|
Quote:
Originally Posted by hannesmenzel
If anybody can tell me, which log is actually right, I would appreciate it. In this example both LN and LOG works.
|
Yeah, and it will also work with LOG2, or any base for that matter, as long as you use the same base for both logs (see Wikipedia). So LN is probably best, because it is likely more efficient.
|
|
|
08-03-2018, 11:11 AM
|
#13
|
Human being with feelings
Join Date: Dec 2015
Posts: 331
|
Quote:
Originally Posted by Tale
Yeah, and it will also work with LOG2, or any base for that matter, as long as you use the same base for both logs (see Wikipedia). So LN is probably best, because it is likely more efficient.
|
Curious—why would LN likely be more efficient? I mean, it doesn't really matter, but on a binary cpu you'd think log2 is the first choice. Anyway, the difference between any will be very small, so use whatever you want.
|
|
|
08-04-2018, 01:10 AM
|
#14
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
|
Quote:
Originally Posted by earlevel
Curious—why would LN likely be more efficient? I mean, it doesn't really matter, but on a binary cpu you'd think log2 is the first choice.
|
When using x87 log2 probably is faster. However, when using SSE2 the log functions are likely calculated in software, so it depends on the math lib implementation. In MSVC log(x) seems to be faster than log2(x) or log10(x). Do note that log2(x) is more precise than log(x)/log(2) though.
|
|
|
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 12:01 PM.
|