|
|
|
04-22-2022, 02:21 AM
|
#41
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Quote:
Originally Posted by kartalex
Hi, Sexan!
I spent the night in math books)))
please, test the following code, I modified myKnob() a little. It may be an idea for making myKnob more universal. Not perfect, but I think math is right)
look at 2 main functions: percentageToDb() and dBToPercentage()
they convert dB scale to 0..1 range, and you may choose where your 0 dB is placed by setting zero argument. In our case we've set it 0.5 - half of knob is 0 dB
please look at the comments in these functions, and the comments in myKnob()
Code:
for key in pairs(reaper) do _G[key] = reaper[key] end
local ctx = ImGui_CreateContext('Template')
log = math.log
exp = math.exp
max = math.max
function Msg(S)
if S==nil then S="nil" end
ShowConsoleMsg(tostring(S) .. "\n")
end
function VAL2DB(x)
if x < 0.0000000298023223876953125 then
x = -150
else
x = max(-150, log(x) * 8.6858896380650365530225783783321)
end
return x
end
function DB2VAL(x)
return exp(x * 0.11512925464970228420089957273422)
end
function percentageToDb(p, max, zero)
--- p is 0..1 - knob value
--- max - 12dB - max value of track volume
--- zero - is the 0dB place in the knob range (in this program it is 0.5)
return max * (1 - (log(p) / log(zero)))
end
function dBToPercentage(dB, max, zero)
return zero^((-max + dB) / max)
end
function myKnob(tb)
-- tb has fields:
-- .center - 0.5, is zero for dBs on linear range of knob
-- .label - knob label
-- .min - 0
-- .max - 1
-- .def - 0.5
-- .val - current value 0..1
-- .unitFunc - function to convert from linear 0..1 scale to dB log scale, we pass percentageToDb() function here
-- also we may use another functions, linear or quadratic, if we want
-- .unit - 'dB' or any other text to show in tooltip, we may pass 'semitones', '%', or other text here
--- I pass arguments as table, it's more readable, we can see the names of arguments, like label = 'Volume'
---------------------------------------lines I've changed-------------------------
label, p_value, v_min, v_max, def_value = tb.label, tb.val, tb.min, tb.max, tb.def
-----------------------------------------------------------------------------------
local radius_outer = 20.0
local pos = { reaper.ImGui_GetCursorScreenPos(ctx) }
local center = { pos[1] + radius_outer, pos[2] + radius_outer }
local line_height = reaper.ImGui_GetTextLineHeight(ctx)
local draw_list = reaper.ImGui_GetWindowDrawList(ctx)
local item_inner_spacing = { reaper.ImGui_GetStyleVar(ctx, reaper.ImGui_StyleVar_ItemInnerSpacing()) }
local mouse_delta = { reaper.ImGui_GetMouseDelta(ctx) }
local ANGLE_MIN = 3.141592 * 0.75
local ANGLE_MAX = 3.141592 * 2.25
reaper.ImGui_InvisibleButton(ctx, label, radius_outer * 2, radius_outer * 2 + line_height + item_inner_spacing[2])
local value_changed = false
local is_active = reaper.ImGui_IsItemActive(ctx)
local is_hovered = reaper.ImGui_IsItemHovered(ctx)
if is_active and (mouse_delta[2] ~= 0.0 or mouse_delta[1] ~= 0.0) then
local step = (v_max - v_min) / 200.0
p_value = p_value - (mouse_delta[2] * step - mouse_delta[1] * step)
if p_value < v_min then p_value = v_min end
if p_value > v_max then p_value = v_max end
value_changed = true
end
local t = (p_value - v_min) / (v_max - v_min)
local angle = ANGLE_MIN + (ANGLE_MAX - ANGLE_MIN) * t
local angle_cos, angle_sin = math.cos(angle), math.sin(angle)
local radius_inner = radius_outer * 0.40
reaper.ImGui_DrawList_AddCircleFilled(draw_list, center[1], center[2], radius_outer, reaper.ImGui_GetColor(ctx, reaper.ImGui_Col_FrameBg()), 16)
reaper.ImGui_DrawList_AddLine(draw_list, center[1] + angle_cos * radius_inner, center[2] + angle_sin * radius_inner, center[1] + angle_cos * (radius_outer - 2), center[2] + angle_sin * (radius_outer - 2), reaper.ImGui_GetColor(ctx, reaper.ImGui_Col_SliderGrabActive()), 2.0)
reaper.ImGui_DrawList_AddCircleFilled(draw_list, center[1], center[2], radius_inner, reaper.ImGui_GetColor(ctx, is_active and reaper.ImGui_Col_FrameBgActive() or is_hovered and reaper.ImGui_Col_FrameBgHovered() or reaper.ImGui_Col_FrameBg()), 16)
reaper.ImGui_DrawList_AddText(draw_list, pos[1], pos[2] + radius_outer * 2 + item_inner_spacing[2], reaper.ImGui_GetColor(ctx, reaper.ImGui_Col_Text()), label)
if is_active or is_hovered then
local window_padding = { reaper.ImGui_GetStyleVar(ctx, reaper.ImGui_StyleVar_WindowPadding()) }
reaper.ImGui_SetNextWindowPos(ctx, pos[1] - window_padding[1] + 3, pos[2] - line_height - item_inner_spacing[2] - window_padding[2] + 82)
reaper.ImGui_BeginTooltip(ctx)
---------------------------------------lines I've changed
func_val = tb.unitFunc(t, 12, tb.center)
reaper.ImGui_Text(ctx, ('%.2f' .. ' '..tb.unit):format(func_val))
--------------------------------------------------------------------------------
reaper.ImGui_EndTooltip(ctx)
end
if reaper.ImGui_IsItemHovered(ctx) then
if reaper.ImGui_IsMouseDoubleClicked(ctx, 0) then
value_changed = true
p_value = def_value
end
end
---------------------------------------lines I've changed
return value_changed, p_value, func_val
----------------------------------------
end
function loop()
local flags = ImGui_WindowFlags_MenuBar() -- Add Menu bar and remove the rezise feature.
ImGui_SetNextWindowPos(ctx, 0, 0, ImGui_Cond_FirstUseEver())-- Set the position of the windows. Use in the 4th argument reaper.ImGui_Cond_FirstUseEver() to just apply at the first user run, so ImGUI remembers user position s2
ImGui_SetNextWindowSize(ctx, 0, 0, ImGui_Cond_Once())-- Set the size of the windows. Use in the 4th argument reaper.ImGui_Cond_FirstUseEver() to just apply at the first user run, so ImGUI remembers user resize s2
------------Begin
local visible, open = ImGui_Begin(ctx, 'Minimal GUI', true, flags) -- the 3rd argument show/hide the close button
if visible then
tr = GetSelectedTrack(0, 0)
local vol =1/ dBToPercentage(VAL2DB(reaper.GetMediaTrackInfo_Value(tr, 'D_VOL')), 12, 0.5)
local rv
--------------GUI
--- I pass arguments as table, it's more readable, we can see the names of arguments, like label = 'Volume'
rv, val, valDB = myKnob {val = vol, label = 'Volume', min = 0, max = 1, center = 0.5, unit = 'dB', def = 0.5,
unitFunc = function(p, max, zero) return percentageToDb(p, max,zero) end }
if tr and rv then
reaper.SetMediaTrackInfo_Value(tr, "D_VOL", DB2VAL(valDB))
end
------------- Ending
reaper.ImGui_End(ctx)
end
------------- Keep or Close ----------V-----
if open and (not ImGui_IsKeyDown(ctx, 27)) then
defer(loop)
else
ImGui_DestroyContext(ctx)
end
end
defer(loop)
I would be happy, if this code is useful for your script. I'd like to have this mixing homie as my tool, and I think log scale would be a good addition for this))) Good luck!
|
Thank you! Will check
Quote:
Originally Posted by hans
No chance of having the Lil track homie affect the volume & pan envelope?
|
Will add
EDIT: Code above works nearly identical as native ImGUI logarithmic scaling (clamps anything above -90ish dB to -inf). Increasing steps to little higher helps a bit (400-500).
BTW
this line is golden
Code:
for key in pairs(reaper) do _G[key] = reaper[key] end
Last edited by Sexan; 04-22-2022 at 02:41 AM.
|
|
|
04-22-2022, 03:11 AM
|
#42
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 15,821
|
Great script as usual.
Re scaling, there are the API function SLIDER2DB and DB2SLIDER that will convert numbers between [0, 1000] and [low db, high db] according to the user's preferences for volume fader range and shape.
You might also want to look at the handling of cfg_yscale in JSFX/analysis/loudness_meter.
|
|
|
04-22-2022, 03:41 AM
|
#43
|
Human being with feelings
Join Date: Dec 2015
Posts: 172
|
Quote:
Originally Posted by Sexan
this line is golden
Code:
for key in pairs(reaper) do _G[key] = reaper[key] end
|
Yes)))
As for low values (-150..-60 dB) - I think it's better to change log function's curvature. I'll try to find out how to to it. It's been a long since I'd learnt logarithms in hi-school, hehe
|
|
|
04-22-2022, 03:46 AM
|
#44
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Schwa to the rescue!
The only problem is JS is like alien language to me but will try to decipher
|
|
|
04-22-2022, 03:46 AM
|
#45
|
Human being with feelings
Join Date: Dec 2015
Posts: 172
|
Quote:
Originally Posted by schwa
Great script as usual.
Re scaling, there are the API function SLIDER2DB and DB2SLIDER that will convert numbers between [0, 1000] and [low db, high db] according to the user's preferences for volume fader range and shape.
You might also want to look at the handling of cfg_yscale in JSFX/analysis/loudness_meter.
|
Oh, schwa, where have you been, we are poor mathematicians))
Thank you!
|
|
|
04-22-2022, 04:07 AM
|
#46
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Ok I got something so far the best behavior (is it?) :
Code:
local vol = reaper.GetMediaTrackInfo_Value(tracks[1], 'D_VOL')
vol = VAL2DB(vol)
vol = reaper.DB2SLIDER(vol)
RVK, vol = MyKnob('VOL', vol or 0, 0, 1000)
if RVK then
vol = reaper.SLIDER2DB(vol)
vol = DB2VAL(vol)
reaper.SetMediaTrackInfo_Value(tracks[1], 'D_VOL', vol)
end
Last edited by Sexan; 04-22-2022 at 04:18 AM.
|
|
|
04-22-2022, 04:26 AM
|
#47
|
Human being with feelings
Join Date: Dec 2015
Posts: 172
|
Quote:
Originally Posted by Sexan
Ok I got something so far the best behavior (is it?) :
|
Cool!
|
|
|
04-22-2022, 04:43 AM
|
#48
|
Administrator
Join Date: Mar 2007
Location: NY
Posts: 15,821
|
For user expectations you might want to label anything below -150 or so as "-inf".
|
|
|
04-22-2022, 04:50 AM
|
#49
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Quote:
Originally Posted by schwa
For user expectations you might want to label anything below -150 or so as "-inf".
|
Yeah I know, but need to add more code since knob function can be pan, rate or anything. Just wanted to see if the behavior is better before I start fixing stuff around.
Thank you very much for helping!
|
|
|
05-16-2022, 02:16 AM
|
#50
|
Human being with feelings
Join Date: Aug 2020
Posts: 281
|
We must not forget about this lil treasure homie! Not abanboned before envelopes i hope hehe!
|
|
|
05-17-2022, 03:47 PM
|
#51
|
Human being with feelings
Join Date: Jan 2011
Posts: 1,182
|
Great script as usual!
I've seen several scripts that use colors from current reaper theme . Is it possible to implement this feature? Or at least easy way to manually set custom colors for more "organic" feel
|
|
|
05-17-2022, 07:05 PM
|
#52
|
Human being with feelings
Join Date: Sep 2016
Posts: 513
|
The sends wil be cool suppe responsive and no jesture its cool thand men
|
|
|
12-29-2022, 05:21 AM
|
#53
|
Human being with feelings
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,827
|
Unfortunately lil item homie is not working for me anymore. Anyone else could confirm?
|
|
|
12-29-2022, 05:27 AM
|
#54
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,334
|
Quote:
Originally Posted by Vagelis
Unfortunately lil item homie is not working for me anymore. Anyone else could confirm?
|
If you are using latest ReaImGui, then open those two scripts and change AttachFont to just Attach. You'll see they will be highlighted with red color. Save them and you are good to go.
|
|
|
12-29-2022, 05:32 AM
|
#55
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Quote:
Originally Posted by Vagelis
Unfortunately lil item homie is not working for me anymore. Anyone else could confirm?
|
Is there an error message happening? Or what exactly doesn't work anymore?
|
|
|
12-29-2022, 05:34 AM
|
#56
|
Human being with feelings
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,827
|
Quote:
Originally Posted by vitalker
If you are using latest ReaImGui, then open those two scripts and change AttachFont to just Attach. You'll see they will be highlighted with red color. Save them and you are good to go.
|
Oh it was that simple, thanks for the help!
|
|
|
12-29-2022, 05:35 AM
|
#57
|
Human being with feelings
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,827
|
Quote:
Originally Posted by Meo-Ada Mespotine
Is there an error message happening? Or what exactly doesn't work anymore?
|
There was a red mark to the attachfont line, i followed vitalker's suggestion and it worked
|
|
|
12-29-2022, 05:41 AM
|
#58
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Quote:
Originally Posted by Vagelis
There was a red mark to the attachfont line, i followed vitalker's suggestion and it worked
|
To be future-proof, add the following line into the code as well:
Code:
dofile(reaper.GetResourcePath() ..
'/Scripts/ReaTeam Extensions/API/imgui.lua')('0.7')
Add it as the first line. This should prevent such errors for the future.
|
|
|
12-29-2022, 05:50 AM
|
#59
|
Human being with feelings
Join Date: Dec 2012
Posts: 13,334
|
Quote:
Originally Posted by Meo-Ada Mespotine
To be future-proof, add the following line into the code as well:
Add it as the first line. This should prevent such errors for the future.
|
I'll add that it is a backward compatibility for scripts, which where made before ReaImGui 0.8 and don't work. Usually the developer updates scripts, but if not, you may use this. In case of the homies, it was enough to edit that line.
|
|
|
12-29-2022, 05:52 AM
|
#60
|
Human being with feelings
Join Date: Oct 2017
Location: Larisa, Greece
Posts: 3,827
|
Quote:
Originally Posted by Meo-Ada Mespotine
To be future-proof, add the following line into the code as well:
Code:
dofile(reaper.GetResourcePath() ..
'/Scripts/ReaTeam Extensions/API/imgui.lua')('0.7')
Add it as the first line. This should prevent such errors for the future.
|
Oh thanks a lot for the info
|
|
|
12-30-2022, 03:38 AM
|
#61
|
Human being with feelings
Join Date: Feb 2008
Posts: 189
|
I get:
> Lil_Track_Homie.lua:24: attempt to call a nil value (field 'SNM_GetIntConfigVar')
I have installed both Imgui and JS API. I see the code using "reaper.ImGui_*", "reaper.JS_*" and "reaper.SNM_*" functions. Is there a dependency unlisted on the fist page?
BTW, It would be nice for Reaper to provide this natively, so you get a single strip of the mixer (effects included) on the current track where the cursor is (FX included). It would allow freeing a lot of screen real estate on the left side.
|
|
|
12-30-2022, 03:44 AM
|
#62
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
Quote:
Originally Posted by rafa1981
> Lil_Track_Homie.lua:24: attempt to call a nil value (field 'SNM_GetIntConfigVar')
|
That one comes from SWS. https://sws-extension.org/
|
|
|
12-30-2022, 06:28 AM
|
#63
|
Human being with feelings
Join Date: Feb 2008
Posts: 189
|
Thanks! My suspicions seemed correct...
|
|
|
08-25-2023, 02:24 PM
|
#64
|
Human being with feelings
Join Date: Jul 2022
Location: Japan
Posts: 812
|
Hi, thanks for the great scripts.
I'm wondering if it's possible to have Lil Item Homie and Lil Track Homie open on where the mouse cursor is while the mouse cursor is at ReaImGui window.
Specifically, there are ReaImGui scripts which let users assign a shortcut script in their scripts (e.g. FX Device), and currently Lil Track Homie appears around the Main Toolbar instead of where the mouse cursor is.
|
|
|
08-25-2023, 02:32 PM
|
#65
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Hm.. not sure ... need to ask cfillion.
But it appears at cursor position when you are in arrange window?
BTW script is broken with newest Imgui, you obviously fixed it (there is no AttachFont and DestroyContext anymore).
Last edited by Sexan; 08-25-2023 at 02:38 PM.
|
|
|
08-25-2023, 03:38 PM
|
#66
|
Human being with feelings
Join Date: Jul 2022
Location: Japan
Posts: 812
|
Yeah, it appears at cursor when I'm in arrange, so it's not a deal breaker in terms of a basic functionality.
IIRC, I just added the snipet.
Code:
dofile(reaper.GetResourcePath() ..
'/Scripts/ReaTeam Extensions/API/imgui.lua')('0.7')
|
|
|
08-25-2023, 11:58 PM
|
#67
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
I've updated the scripts
|
|
|
08-26-2023, 02:22 PM
|
#68
|
Human being with feelings
Join Date: Apr 2017
Posts: 93
|
Big thanks for these scripts!
Lil Track Homie is working great, but Lil Item Homie is giving me this error message:
Lil_Item_Homie.lua:40: attempt to call a nil value (field 'ImGui_AttachFont')
What can I do to get it working?
__________________
"All humans are Homo Sapiens & the majority of us support human rights & equality. It's about common human decency & normal emotional intelligence that most have. It's normal good business ethics when companies support it. Go Reaper!"
|
|
|
08-26-2023, 03:21 PM
|
#69
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Did you synced reapack? I've pushed the update yesterday.
EdIT: did not pushed item version... just rename AttachFont to Attach until I fix it
|
|
|
08-28-2023, 04:34 PM
|
#70
|
Human being with feelings
Join Date: Jul 2022
Location: Japan
Posts: 812
|
Quote:
Originally Posted by Suzuki
Hi, thanks for the great scripts.
I'm wondering if it's possible to have Lil Item Homie and Lil Track Homie open on where the mouse cursor is while the mouse cursor is at ReaImGui window.
Specifically, there are ReaImGui scripts which let users assign a shortcut script in their scripts (e.g. FX Device), and currently Lil Track Homie appears around the Main Toolbar instead of where the mouse cursor is.
|
cfillion kindly solved this problem!
https://forum.cockos.com/showpost.ph...&postcount=935
|
|
|
03-01-2024, 06:33 PM
|
#71
|
Human being with feelings
Join Date: Sep 2016
Posts: 513
|
Hello i have crash Script: Lil_Item_Homie.lua
msg
Lil_Item_Homie.lua:40: attempt to call a nil value (field 'ImGui_AttachFont')
|
|
|
03-02-2024, 06:56 AM
|
#72
|
Human being with feelings
Join Date: Sep 2019
Posts: 24
|
Media Playback Offset Option
Is there any way to add Media Playback Offset to the Lil Mixing Homie? Or possibly the code I could add to make it appear. It would probably need the offset activate button along with the amount to offset.
This comes in handy when dealing with sample String Libraries and such.
|
|
|
03-02-2024, 01:04 PM
|
#73
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Quote:
Originally Posted by grandfougue
Hello i have crash Script: Lil_Item_Homie.lua
msg
Lil_Item_Homie.lua:40: attempt to call a nil value (field 'ImGui_AttachFont')
|
Fixed. Resync ReaPack
|
|
|
03-02-2024, 01:06 PM
|
#74
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Quote:
Originally Posted by b3shoals
Is there any way to add Media Playback Offset to the Lil Mixing Homie? Or possibly the code I could add to make it appear. It would probably need the offset activate button along with the amount to offset.
This comes in handy when dealing with sample String Libraries and such.
|
Will check is there API to access it, if yes then I will add
EDIT: Will add it tomorrow
Last edited by Sexan; 03-02-2024 at 01:12 PM.
|
|
|
03-02-2024, 10:56 PM
|
#75
|
Human being with feelings
Join Date: Jan 2020
Location: In the studio at my desk
Posts: 365
|
Sorry I have refreshed ReaPack
ReaIMGui is up to date.
Running Win 11 using latest pre-release
Yet no gui at all shows up and no error message.
I must have messed something up.
Any ideas?
Thanks
Warren
|
|
|
03-03-2024, 04:23 AM
|
#76
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Quote:
Originally Posted by WarrenG
Sorry I have refreshed ReaPack
ReaIMGui is up to date.
Running Win 11 using latest pre-release
Yet no gui at all shows up and no error message.
I must have messed something up.
Any ideas?
Thanks
Warren
|
JS_API installed?
|
|
|
03-03-2024, 07:10 AM
|
#77
|
Human being with feelings
Join Date: Jan 2020
Location: In the studio at my desk
Posts: 365
|
Quote:
Originally Posted by Sexan
JS_API installed?
|
Thanks Sexan
Yes I have all the bleeding edge setup of the latest versions
On JS_API and ReaIMgui
Still no gui or error message
Warren
|
|
|
03-03-2024, 07:35 AM
|
#78
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Using track or item one?
Item one needs item to be selected first
|
|
|
03-03-2024, 08:04 AM
|
#79
|
Human being with feelings
Join Date: Jan 2020
Location: In the studio at my desk
Posts: 365
|
Quote:
Originally Posted by Sexan
Using track or item one?
Item one needs item to be selected first
|
Both, FX Slot is the only one the comes up.
There state never turns on in the action list.
Last edited by WarrenG; 03-03-2024 at 08:11 AM.
|
|
|
03-03-2024, 08:22 AM
|
#80
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Hm....will look into it
|
|
|
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 01:52 AM.
|