Old 04-16-2019, 08:48 PM   #1
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default Using slider2DB

My thought was that this would normalize the 0..1 of stock parameter values to DB values for controlling a fader.

It certainly doesn't do that. Looks like 1000 is 12 db. But it also seems crazily extra-exponential...

No documentation in the API, and a search doesn't turn up anybody who seems to have used it.

Any suggestions welcome, thanks!!

EDIT: okay looked further afield and found that I can normalize with 20*log(n). That gives lovely value on readout. But I'm trying to set a send level, and they are not budging.

Anybody know what range this method expects? I guess I'll mess around. A little documention would be so helpful...
Code:
 reaper.SetTrackSendUIVol( track, send_idx, vol, isend )
EDIT:
okay, they do seem to want a value between 0 and 1, but the movement is not linear....

EDIT:
looks like n*n, where (0<n<1) gives a fairly similar motion to the gui sliders themselves...

Is there better math than this?? Otherwise, I guess I'll call this good enough.
__________________
eric moon
Very Stable Genius
https://gogolab.com/

Last edited by woodslanding; 04-16-2019 at 09:26 PM.
woodslanding is offline   Reply With Quote
Old 04-17-2019, 09:58 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

If I understood right, this should solve it:

https://mespotin.uber.space/Ultrasch....html#MKVOL2DB
https://mespotin.uber.space/Ultrasch....html#DB2MKVOL
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-18-2019, 08:25 PM   #3
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Quote:
Originally Posted by mespotine View Post
Oh great, yes indeed this looks to be just the thing.... thank you!
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 04-21-2019, 11:33 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Kudos to Justin, who wrote the original function for the WebRC-part of Reaper. This is the one I ported over to Lua for that
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 01-25-2021, 11:23 AM   #5
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

Well, it is just the thing, but just not the only thing...

the ultraschall methods are allowing me to set the faders by db which is great, as I'd like to store db values in my preset files.

But my thought that I could take these db values and parameter-ize them with SLIDER2DB is false.

I will look again at the methods I suggest above. I'm grateful to myself for keeping my notes here in the forum

(And to mespotine for her multifarious methods, of course!)

EDIT: okay the 20 * log(n) above is a generic method for converting db into a normalized parameter value... code should look like this, I think:
Code:
param = math.exp(dB/20)
dB = 20 * math.log(param);
EDIT: combination of the db and mespotine methods above seems to work correctly. The max value is 0 db. Not sure how you would get the extra 12 db. I need to review exponential math!

YET ANOTHER EDIT: okay looks like you can just add/subtract 12 to the db values, and it still scales down to zero.
__________________
eric moon
Very Stable Genius
https://gogolab.com/

Last edited by woodslanding; 01-25-2021 at 12:03 PM.
woodslanding is offline   Reply With Quote
Old 01-26-2021, 01:17 AM   #6
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

I have no idea what this is for (so maybe this doesn't apply), but isn't this missing log(10)? I.e.:

Code:
param = exp(dB*log(10)/20)
dB = 20/log(10)*log(param)
Also beware that param can't be zero.
Tale is online now   Reply With Quote
Old 01-26-2021, 09:59 AM   #7
woodslanding
Human being with feelings
 
woodslanding's Avatar
 
Join Date: Mar 2007
Location: Denver, CO
Posts: 633
Default

woah, I was NOT aware that param can't be zero. And params CAN be zero, actually ;0) So I need something like:

if param == 0 return 0 else dothemath

correct?

but dotheothermath can't ever return zero, I guess?

Lua defaults to log10 unless you tell it to use something else.... this seems to work, although I haven't tested it thoroughly.
__________________
eric moon
Very Stable Genius
https://gogolab.com/
woodslanding is offline   Reply With Quote
Old 01-27-2021, 01:20 AM   #8
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Quote:
Originally Posted by woodslanding View Post
woah, I was NOT aware that param can't be zero. And params CAN be zero, actually ;0)
Well, mathematically speaking exp(x) always returns a value greater than 0, and likewise log(0) isn't defined.

Quote:
Originally Posted by woodslanding View Post
So I need something like:

if param == 0 return 0 else dothemath

correct?
Yeah, probably, but I don't really understand what you're after.

Quote:
Originally Posted by woodslanding View Post
Lua defaults to log10 unless you tell it to use something else....
I know almost nothing about Lua, but I thought math.log() is the natural log, and math.log10() is log base 10. Also, exp() will almost certainly not be the same as 10^x.
Tale is online now   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:59 AM.


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