COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 09-02-2010, 04:02 PM   #1
pylorca
Human being with feelings
 
Join Date: Apr 2009
Posts: 191
Default 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
pylorca is offline   Reply With Quote
Old 09-02-2010, 10:45 PM   #2
cerberus
Human being with feelings
 
Join Date: Nov 2009
Location: memory
Posts: 633
Default

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.
cerberus is offline   Reply With Quote
Old 09-03-2010, 03:04 AM   #3
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: Berlin, Germany
Posts: 1,248
Default

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
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 09-03-2010, 08:28 AM   #4
pylorca
Human being with feelings
 
Join Date: Apr 2009
Posts: 191
Default

Quote:
Originally Posted by olilarkin View Post
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
pylorca is offline   Reply With Quote
Old 09-03-2010, 06:49 PM   #5
cerberus
Human being with feelings
 
Join Date: Nov 2009
Location: memory
Posts: 633
Default

Quote:
Originally Posted by olilarkin View Post
"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.
cerberus is offline   Reply With Quote
Old 10-19-2014, 08:14 PM   #6
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

What's the math behind SetShape?
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 10-19-2014, 11:13 PM   #7
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

I believe f(x) = x^shape, see FromNormalizedParam() and ToNormalizedParam() in IParam.h.
Tale is offline   Reply With Quote
Old 10-21-2014, 01:37 AM   #8
antto
Human being with feelings
 
Join Date: Nov 2008
Posts: 108
Default

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
antto is offline   Reply With Quote
Old 10-21-2014, 02:46 AM   #9
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

thanks, very helpfuel!!
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 07-10-2017, 01:40 AM   #10
Andi!
Human being with feelings
 
Andi!'s Avatar
 
Join Date: Nov 2015
Location: Germany
Posts: 82
Default

Quote:
Originally Posted by olilarkin View Post

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.
Andi! is offline   Reply With Quote
Old 07-31-2018, 03:10 PM   #11
hannesmenzel
Human being with feelings
 
Join Date: Jul 2018
Posts: 24
Default

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.
hannesmenzel is offline   Reply With Quote
Old 08-01-2018, 12:51 AM   #12
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by hannesmenzel View Post
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.
Tale is offline   Reply With Quote
Old 08-03-2018, 11:11 AM   #13
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

Quote:
Originally Posted by Tale View Post
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.
earlevel is offline   Reply With Quote
Old 08-04-2018, 01:10 AM   #14
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by earlevel View Post
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.
Tale 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 12:01 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.