Old 08-14-2015, 12:49 PM   #1
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: Berlin
Posts: 10,670
Default Item/Take volume with Mousewheel

Change the item(or take) volume with the mousewheel and this script.

Promptly written by Justin Frankel after a "this would be really useful" request.

Download here :
https://stash.reaper.fm/24815/ItemTak...Mousewheel.eel
Use:

Place the script in the "Scripts" directory in your Reaper Resources Directory. (Options/Show ... to get to that)

Load and bind this script to the mousewheel(with any or no modifiers) in the Action window to use it.
Configuration:
want_item = 1; // set to 0 for take volume rather than item volume

In the The line:
vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));
Those last two numbers, 0.5 and -0.5 are the mousewheel up/down step width.
__________________
Dialogue/FX Editor & Re-Recording Mixer
(Video)Using Latch Preview - Faderport16 CSI
"My ego comes pre-shrunk" - Randy Thom

Last edited by airon; 08-14-2015 at 12:58 PM.
airon is offline   Reply With Quote
Old 08-14-2015, 01:49 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,519
Default

A script by Justin Frankel ???
X-Raym is offline   Reply With Quote
Old 08-14-2015, 02:09 PM   #3
EpicSounds
Human being with feelings
 
EpicSounds's Avatar
 
Join Date: Jul 2009
Posts: 5,865
Default

Quote:
Originally Posted by X-Raym View Post
A script by Justin Frankel ???
Yeah, who dat? LOL

Works great. I'm using CMD+Option
__________________
REAPER Video Tutorials, Tips & Tricks and more at The REAPER Blog
EpicSounds is offline   Reply With Quote
Old 08-14-2015, 02:33 PM   #4
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,416
Default

But but.. I was the first one to do a script with the "get_action_context" mousewheel trick... Pouty face
...or not
(it was all from spk77)
James HE is offline   Reply With Quote
Old 08-14-2015, 04:06 PM   #5
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: Berlin
Posts: 10,670
Default

I'd been editing dialogue in Protools 11, and a friend told me about how you can change the item gain with WIN+SHIFT+Mousewheel for selected items.

"This is actually a good idea. In Protools. Whoda thunk."

So the search began. I couldn't do it with vanilla or SWS actions. Justin wrote this in 20 minutes, and hey, I was off to the races.

Using the mousewheel makes it even easier to edit the item/take volume as you don't even have to point the mouse anywhere. And since Reaper has marquee selection, it's even faster than Protools at this particular thing(again).

I really wish I was editing dialogue in Reaper these days.
__________________
Dialogue/FX Editor & Re-Recording Mixer
(Video)Using Latch Preview - Faderport16 CSI
"My ego comes pre-shrunk" - Randy Thom
airon is offline   Reply With Quote
Old 08-14-2015, 04:53 PM   #6
BenK-msx
Human being with feelings
 
BenK-msx's Avatar
 
Join Date: Jun 2008
Location: Whales, UK
Posts: 5,773
Default

mousewheel should be a mouse modifier option.
__________________
JS Super8 Looper Template & intro | BCF2000 uber info Thread | Who killed the Lounge?
BenK-msx is offline   Reply With Quote
Old 08-15-2015, 06:55 AM   #7
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: Berlin
Posts: 10,670
Default

Put it up in the issue tracker as a request.

I'll certainly vote for it. The first place I looked to do this was the preferences page for the mouse modifiers.
__________________
Dialogue/FX Editor & Re-Recording Mixer
(Video)Using Latch Preview - Faderport16 CSI
"My ego comes pre-shrunk" - Randy Thom
airon is offline   Reply With Quote
Old 08-15-2015, 10:20 AM   #8
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 15,403
Default

love this script... thanks much Justin and Airon... works a treat! ...and indeed VERY useful and fast.
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva/angel-rain
hopi is offline   Reply With Quote
Old 08-15-2015, 12:42 PM   #9
Pasajeromoronmoreno
Human being with feelings
 
Join Date: Nov 2013
Location: Argentina
Posts: 326
Default

Any idea if the script has any advantages over this?



Edit: Forget it, they do the same. I was hoping the script to be context sensitive to the take under cursor, and mousewheeling mouseovering the take. But no, you had to click the take first, in the script and in my custom action too. I canīt find a way to do that with the actions, because there is no "select take under mouse cursor", only "select item". But maybe itīs posible to alter a bit the script for that...? What do you think?

__________________
Living la vida loca

Last edited by Pasajeromoronmoreno; 08-15-2015 at 01:13 PM.
Pasajeromoronmoreno is offline   Reply With Quote
Old 08-15-2015, 01:15 PM   #10
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,416
Default

search actions for

"activate take under mouse"
James HE is offline   Reply With Quote
Old 08-15-2015, 01:29 PM   #11
Pasajeromoronmoreno
Human being with feelings
 
Join Date: Nov 2013
Location: Argentina
Posts: 326
Default

Well, itīs not the first, and itīs not gonna be the last time me not finding something in that list, Every thing has a hundred different names...
Anyways, that do the trick James, itīs working mousovering over the takes now. Thanks for the help!!!!!
__________________
Living la vida loca
Pasajeromoronmoreno is offline   Reply With Quote
Old 08-15-2015, 03:56 PM   #12
BenK-msx
Human being with feelings
 
BenK-msx's Avatar
 
Join Date: Jun 2008
Location: Whales, UK
Posts: 5,773
Default

Quote:
Originally Posted by airon View Post
Put it up in the issue tracker as a request.

I'll certainly vote for it. The first place I looked to do this was the preferences page for the mouse modifiers.
Unfortunately imo the Issue tracker may as well be the side of the sofa as a good place for things, it was cool in v3 days now just where ideas go to decay slowly.

Polite mentions in a pre thread is the only way to seed a developer!
__________________
JS Super8 Looper Template & intro | BCF2000 uber info Thread | Who killed the Lounge?
BenK-msx is offline   Reply With Quote
Old 08-15-2015, 04:39 PM   #13
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,969
Default

Nice script!

Could a similar script be made to control the TCP volumes for selected tracks using the mousewheel as well?

I like the dB steps.
WyattRice is offline   Reply With Quote
Old 08-16-2015, 02:27 AM   #14
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Adjust take volume via mousewheel (take under mouse cursor):



Code:
function VAL2DB(x)(
  x < 0.0000000298023223876953125 ? -150 : max(-150, log(x)* 8.6858896380650365530225783783321);  
);
function DB2VAL(x) ( exp((x)*0.11512925464970228420089957273422 ));

function adjust_take_vol()
(
  extension_api("BR_GetMouseCursorContext", "", "", "");
  get_action_context(#foo,0,0, mode, res, val);
  val != 0 ? (
    (tk = extension_api("BR_GetMouseCursorContext_Take")) ? (
      vol = GetMediaItemTakeInfo_Value(tk,"D_VOL");
      ph = vol < 0.0;
      vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));      
      SetMediaItemTakeInfo_Value(tk,"D_VOL",ph ? -vol : vol);
      UpdateTimeline();
      Undo_OnStateChangeEx("Adjust take volume", -1, -1);
    );
  );
);

defer("adjust_take_vol()");
spk77 is offline   Reply With Quote
Old 08-16-2015, 02:31 AM   #15
Pasajeromoronmoreno
Human being with feelings
 
Join Date: Nov 2013
Location: Argentina
Posts: 326
Default

Hi Wyatt!!
Maybe you prefer a script, but in the meantime this custom actions is what i use to accomplish that.
Assign to Mousewheel and done.
Need Sws, and you had to configure the steps you want for the volume nudges in the xenaxios command parameter window. (search command parameter in actions). I have it in 0.5 db steps, for example. Hope it helps!!

Edit: Hehehe, Ok, never mind, too late... spk77 did it already...

Edit 2: Sorry, he make the script for the takes, not for the TCP, so, this actions are still usefull. (Hahaha, for a bunch of minutes until someone come up with the scripts).
__________________
Living la vida loca

Last edited by Pasajeromoronmoreno; 08-16-2015 at 04:37 AM.
Pasajeromoronmoreno is offline   Reply With Quote
Old 08-16-2015, 02:36 AM   #16
Pasajeromoronmoreno
Human being with feelings
 
Join Date: Nov 2013
Location: Argentina
Posts: 326
Default

Thanks spk77!!, gonna test it instead of the custom action. any advantages over that?

Edit: Yeah, you Script itīs better, with the custom action i had to select the track first, the script does not need that extra step. Thanks Again spk77!!
__________________
Living la vida loca

Last edited by Pasajeromoronmoreno; 08-16-2015 at 02:50 AM.
Pasajeromoronmoreno is offline   Reply With Quote
Old 08-16-2015, 04:40 AM   #17
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by WyattRice View Post
Nice script!

Could a similar script be made to control the TCP volumes for selected tracks using the mousewheel as well?

I like the dB steps.

Edit: ("Undo" should work now) Undo isn't working correctly - I'll see if I can fix it.

TrackItemTakeVolume_via_Mousewheel.eel
  • Mouse cursor on TCP -> adjust track volume (selected tracks)
  • Mouse cursor on arrange view-> adjust item or take volume (selected items)

Code:
function VAL2DB(x)(
  x < 0.0000000298023223876953125 ? -150 : max(-150, log(x)* 8.6858896380650365530225783783321);  
);
function DB2VAL(x) ( exp((x)*0.11512925464970228420089957273422 ));
 
want_item = 1; // set to 0 for take volume rather than item volume
cnt=0;
tr=0;
get_action_context(#foo,0,0, mode, res, val);
extension_api("BR_GetMouseCursorContext", #window, "", "");
val != 0 && match("tcp", #window) ? (
  i = 0;
  loop(CountSelectedTracks(0),
    trh = GetSelectedTrack(0, i);
    vol = GetMediaTrackInfo_Value(trh, "D_VOL");
    ph = vol < 0.0;
    vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));      
    SetMediaTrackInfo_Value(trh,"D_VOL",ph ? -vol : vol); 
    i=i+1;  
  );
  Undo_OnStateChangeEx("Adjust track volume", -1, -1);
):

val != 0 && match("arrange", #window) ? (
  loop(GetNumTracks(),
    trh = GetTrack(0,tr);
    idx=0;
    loop(GetTrackNumMediaItems(trh),
      item = GetTrackMediaItem(trh,idx);
      IsMediaItemSelected(item) && (want_item || (tk = GetActiveTake(item))) ? (
        vol = want_item ? GetMediaItemInfo_Value(item,"D_VOL") : GetMediaItemTakeInfo_Value(tk,"D_VOL");
        ph = vol < 0.0;
        vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));      
        want_item ? SetMediaItemInfo_Value(item,"D_VOL",vol) : SetMediaItemTakeInfo_Value(tk,"D_VOL",ph ? -vol : vol);      
        cnt+=1;
        z=1;
      );
      idx+=1
    );
    tr+=1;
  );
  Undo_OnStateChangeEx("Adjust item or take volume", 4, -1);
);
 
 
cnt ? UpdateTimeline();
Thanks to Breeder for the GetMouseCursorContext functions!




Quote:
Originally Posted by Pasajeromoronmoreno View Post
Thanks spk77!!, gonna test it instead of the custom action. any advantages over that?

Edit: Yeah, you Script itīs better, with the custom action i had to select the track first, the script does not need that extra step. Thanks Again spk77!!
Thanks, glad it worked!

Last edited by spk77; 08-16-2015 at 04:58 AM. Reason: "Undo" fixed
spk77 is offline   Reply With Quote
Old 08-16-2015, 04:43 AM   #18
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,808
Default

Sorry to post here, but is it possible to move Selected Envelope Points +- 0,2 with mousewheel ?
Sexan is offline   Reply With Quote
Old 08-16-2015, 04:48 AM   #19
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Sexan View Post
Sorry to post here, but is it possible to move Selected Envelope Points +- 0,2 with mousewheel ?
Yes, I think. (More difficult, but possible )
spk77 is offline   Reply With Quote
Old 08-16-2015, 07:39 AM   #20
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,969
Default

Quote:
Originally Posted by spk77 View Post
Edit: ("Undo" should work now) Undo isn't working correctly - I'll see if I can fix it.

TrackItemTakeVolume_via_Mousewheel.eel[LIST][*]Mouse cursor on TCP -> adjust track volume (selected tracks)[*]Mouse cursor on arrange view-> adjust item or take volume (selected items)
Thanks spk77.
For some reason, I can't get the TCP track volume to work.
Media items are working.

I have the script assigned to just the mousewheel.

I'm on v5.01 pre2 with the latest sws extension (2.8.0)

Thanks, Wyatt
WyattRice is offline   Reply With Quote
Old 08-16-2015, 07:50 AM   #21
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 15,403
Default

Quote:
Originally Posted by spk77 View Post
Edit: ("Undo" should work now) Undo isn't working correctly - I'll see if I can fix it.

TrackItemTakeVolume_via_Mousewheel.eel
  • Mouse cursor on TCP -> adjust track volume (selected tracks)
  • Mouse cursor on arrange view-> adjust item or take volume (selected items)

Code:
function VAL2DB(x)(
  x < 0.0000000298023223876953125 ? -150 : max(-150, log(x)* 8.6858896380650365530225783783321);  
);
function DB2VAL(x) ( exp((x)*0.11512925464970228420089957273422 ));
 
want_item = 1; // set to 0 for take volume rather than item volume
cnt=0;
tr=0;
get_action_context(#foo,0,0, mode, res, val);
extension_api("BR_GetMouseCursorContext", #window, "", "");
val != 0 && match("tcp", #window) ? (
  i = 0;
  loop(CountSelectedTracks(0),
    trh = GetSelectedTrack(0, i);
    vol = GetMediaTrackInfo_Value(trh, "D_VOL");
    ph = vol < 0.0;
    vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));      
    SetMediaTrackInfo_Value(trh,"D_VOL",ph ? -vol : vol); 
    i=i+1;  
  );
  Undo_OnStateChangeEx("Adjust track volume", -1, -1);
):

val != 0 && match("arrange", #window) ? (
  loop(GetNumTracks(),
    trh = GetTrack(0,tr);
    idx=0;
    loop(GetTrackNumMediaItems(trh),
      item = GetTrackMediaItem(trh,idx);
      IsMediaItemSelected(item) && (want_item || (tk = GetActiveTake(item))) ? (
        vol = want_item ? GetMediaItemInfo_Value(item,"D_VOL") : GetMediaItemTakeInfo_Value(tk,"D_VOL");
        ph = vol < 0.0;
        vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));      
        want_item ? SetMediaItemInfo_Value(item,"D_VOL",vol) : SetMediaItemTakeInfo_Value(tk,"D_VOL",ph ? -vol : vol);      
        cnt+=1;
        z=1;
      );
      idx+=1
    );
    tr+=1;
  );
  Undo_OnStateChangeEx("Adjust item or take volume", 4, -1);
);
 
 
cnt ? UpdateTimeline();
Thanks to Breeder for the GetMouseCursorContext functions!





Thanks, glad it worked!

spk77.... I assumed this is a lua script, yes?

I copied the text and loaded it as lua, but get this when trying to run it:

..reaper 64 Portable\Scripts\Volume by MW Track and Item.lua:2: ')' expected (to close '(' at line 1) near '?'

what did I do wrong? I wonder if you can post it to the stash so I can just dl it as you intended it to be?
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva/angel-rain
hopi is offline   Reply With Quote
Old 08-16-2015, 08:00 AM   #22
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by WyattRice View Post
Thanks spk77.
For some reason, I can't get the TCP track volume to work.
Media items are working.

I have the script assigned to just the mousewheel.

I'm on v5.01 pre2 with the latest sws extension (2.8.0)

Thanks, Wyatt
Hmmm...it seems it doesn't work without a modifier key - don't know why.

Quote:
Originally Posted by hopi View Post
spk77.... I assumed this is a lua script, yes?

I copied the text and loaded it as lua, but get this when trying to run it:

..reaper 64 Portable\Scripts\Volume by MW Track and Item.lua:2: ')' expected (to close '(' at line 1) near '?'

what did I do wrong? I wonder if you can post it to the stash so I can just dl it as you intended it to be?
It's an EEL script - save as Volume by MW Track and Item.eel
spk77 is offline   Reply With Quote
Old 08-16-2015, 12:26 PM   #23
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Sexan View Post
Sorry to post here, but is it possible to move Selected Envelope Points +- 0,2 with mousewheel ?
Here:
http://forum.cockos.com/showthread.p...68#post1559068
(Adjust volume envelope points (values) via mousewheel)
spk77 is offline   Reply With Quote
Old 08-16-2015, 12:27 PM   #24
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 10,066
Default

spk77

Why the hell it don't work over mcp?

Code:
function VAL2DB(x)(
  x < 0.0000000298023223876953125 ? -150 : max(-150, log(x)* 8.6858896380650365530225783783321);  
);
function DB2VAL(x) ( exp((x)*0.11512925464970228420089957273422 ));
 
want_item = 1; // set to 0 for take volume rather than item volume
cnt=0;
tr=0;
get_action_context(#foo,0,0, mode, res, val);
extension_api("BR_GetMouseCursorContext", #window, "", "");
val != 0 && match("tcp", #window) ? (
  i = 0;
  loop(CountSelectedTracks(0),
    trh = GetSelectedTrack(0, i);
    vol = GetMediaTrackInfo_Value(trh, "D_VOL");
    ph = vol < 0.0;
    vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));      
    SetMediaTrackInfo_Value(trh,"D_VOL",ph ? -vol : vol); 
    i=i+1;  
  );
  Undo_OnStateChangeEx("Adjust track volume", -1, -1);
):

val != 0 && match("mcp", #window) ? (
  i = 0;
  loop(CountSelectedTracks(0),
    trh = GetSelectedTrack(0, i);
    vol = GetMediaTrackInfo_Value(trh, "D_VOL");
    ph = vol < 0.0;
    vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));      
    SetMediaTrackInfo_Value(trh,"D_VOL",ph ? -vol : vol); 
    i=i+1;  
  );
  Undo_OnStateChangeEx("Adjust track volume", -1, -1);
):

val != 0 && match("arrange", #window) ? (
  loop(GetNumTracks(),
    trh = GetTrack(0,tr);
    idx=0;
    loop(GetTrackNumMediaItems(trh),
      item = GetTrackMediaItem(trh,idx);
      IsMediaItemSelected(item) && (want_item || (tk = GetActiveTake(item))) ? (
        vol = want_item ? GetMediaItemInfo_Value(item,"D_VOL") : GetMediaItemTakeInfo_Value(tk,"D_VOL");
        ph = vol < 0.0;
        vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));      
        want_item ? SetMediaItemInfo_Value(item,"D_VOL",vol) : SetMediaItemTakeInfo_Value(tk,"D_VOL",ph ? -vol : vol);      
        cnt+=1;
        z=1;
      );
      idx+=1
    );
    tr+=1;
  );
  Undo_OnStateChangeEx("Adjust item or take volume", 4, -1);
);
 
 
cnt ? UpdateTimeline();
And it would be very cool to make it all context
Reno.thestraws is offline   Reply With Quote
Old 08-16-2015, 12:32 PM   #25
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Reno.thestraws View Post
spk77

Why the hell it don't work over mcp?

And it would be very cool to make it all context
I don't know . I was wondering that too.



Yes, this should work
Code:
val != 0 && match("mcp", #window)

Don't know which one is broken, get_action_context or BR_GetMouseCursorContext
spk77 is offline   Reply With Quote
Old 08-16-2015, 12:35 PM   #26
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 10,066
Default

I got the same issue with this

http://forum.cockos.com/showthread.php?t=159151

work in every context 100% of times exept mcp

Sometimes it works... sometimes it doesn't!

and if I restart REAPER it works again :S
Reno.thestraws is offline   Reply With Quote
Old 08-16-2015, 12:44 PM   #27
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,808
Default

Quote:
Originally Posted by spk77 View Post
Here:
http://forum.cockos.com/showthread.p...68#post1559068
(Adjust volume envelope points (values) via mousewheel)
Sir You are amazing!!! Thank you!

Edit: It works great as custom action with this one!

Last edited by Sexan; 08-16-2015 at 12:54 PM.
Sexan is offline   Reply With Quote
Old 08-16-2015, 02:26 PM   #28
hopi
Human being with feelings
 
hopi's Avatar
 
Join Date: Oct 2008
Location: Right Hear
Posts: 15,403
Default

thanks for that info spk.... works nicely now... what a difference a day makes, ...and the diff is SPK!
__________________
...should be fixed for the next build... http://tinyurl.com/cr7o7yl
https://soundcloud.com/hopikiva/angel-rain
hopi is offline   Reply With Quote
Old 08-17-2015, 04:44 AM   #29
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,808
Default

I know I'm asking too much,but could these two scripts be merged into one (Item/Track Volume and Envelope)?I know EEL would need to be ported to LUA
Sexan is offline   Reply With Quote
Old 09-14-2015, 02:08 AM   #30
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: Berlin
Posts: 10,670
Default

Little bump. Some folks are starting to miss this.
__________________
Dialogue/FX Editor & Re-Recording Mixer
(Video)Using Latch Preview - Faderport16 CSI
"My ego comes pre-shrunk" - Randy Thom
airon is offline   Reply With Quote
Old 12-30-2015, 12:59 PM   #31
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: Berlin
Posts: 10,670
Default

Tiny bump. Pointing some folks to this.
__________________
Dialogue/FX Editor & Re-Recording Mixer
(Video)Using Latch Preview - Faderport16 CSI
"My ego comes pre-shrunk" - Randy Thom
airon is offline   Reply With Quote
Old 12-30-2015, 02:19 PM   #32
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Just outside of Glacier National Park
Posts: 12,955
Default

Quote:
Originally Posted by airon View Post
Tiny bump. Pointing some folks to this.
Thanks airon, I DLed it and will check it out.
Tod is online now   Reply With Quote
Old 12-30-2015, 03:37 PM   #33
timothys_monster
Human being with feelings
 
timothys_monster's Avatar
 
Join Date: Jan 2012
Location: Germany
Posts: 912
Default

Thanks for bumping. I would have missed it. Life is way easier now
timothys_monster is offline   Reply With Quote
Old 12-30-2015, 10:06 PM   #34
gpunk_w
Human being with feelings
 
Join Date: Dec 2010
Posts: 3,248
Default

so there is no way to have this adjust volume on items when over items, but zoom when over empty arrange ?
__________________
Reaper scripters, that is all !!!!!!!!!!!!!!!!
gpunk_w is offline   Reply With Quote
Old 01-02-2016, 11:35 AM   #35
Subz
Human being with feelings
 
Subz's Avatar
 
Join Date: Jun 2006
Location: UK
Posts: 2,966
Default

thanks to those who bumped!

lovely little script!

Subz
Subz is offline   Reply With Quote
Old 01-03-2016, 04:50 PM   #36
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Yeah, I missed it the first time too I guess.

My question is, does this:

get_action_context(#foo,0,0, mode, res, val);

have any connection to the clicker buttons on the mouse? I'd like to be able to suspend or enable defer functions with it. Looks like "no", but figured I'd ask.

I would guess partial answer to gpunk_w might be: Probably could trigger the keyboard (one direction) zoom actions like that. Don't know about passing wheel through it. Can't try now.
FnA is offline   Reply With Quote
Old 02-09-2016, 09:46 AM   #37
bladlus
Human being with feelings
 
bladlus's Avatar
 
Join Date: Dec 2011
Location: Oslo
Posts: 29
Default

Quote:
Originally Posted by BenK-msx View Post
mousewheel should be a mouse modifier option.
I agree!
bladlus is offline   Reply With Quote
Old 07-13-2016, 11:01 AM   #38
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 12,792
Default

Here's a version of the script that waits to process undo until after mouse tweaking has finished:
Code:
function VAL2DB(x)(
  x < 0.0000000298023223876953125 ? -150 : max(-150, log(x)* 8.6858896380650365530225783783321);  
);
function DB2VAL(x) ( exp((x)*0.11512925464970228420089957273422 ));
 
want_item = 1; // set to 0 for take volume rather than item volume

function run(first) (
  val=cnt=tr=0;
  get_action_context(#foo,0,0, mode, res, val)||first ? (
    pc=time_precise();
    val != 0 ? loop(GetNumTracks(),
      trh = GetTrack(0,tr);
      idx=0;
      loop(GetTrackNumMediaItems(trh),
        item = GetTrackMediaItem(trh,idx);
        IsMediaItemSelected(item) && (want_item || (tk = GetActiveTake(item))) ? (
          vol = want_item ? GetMediaItemInfo_Value(item,"D_VOL") : GetMediaItemTakeInfo_Value(tk,"D_VOL");
          ph = vol < 0.0;
          vol = DB2VAL(VAL2DB(abs(vol)) + (val > 0 ? 0.5 : -0.5));      
          want_item ? SetMediaItemInfo_Value(item,"D_VOL",vol) : SetMediaItemTakeInfo_Value(tk,"D_VOL",ph ? -vol : vol);      
          cnt+=1;
          z=1;
        );
        idx+=1
      );
      tr+=1
    );
    cnt != 0 ? UpdateTimeline();
  );
  time_precise() < pc+1 ? defer("run(0)") : Undo_OnStateChange("Adjust Item Volume"); 
);

run(1);
Justin is offline   Reply With Quote
Old 07-13-2016, 12:02 PM   #39
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Justin View Post
Here's a version of the script that waits to process undo until after mouse tweaking has finished:
That's nice, thank you!

(..And a weird coincidence: I was trying to do the same "delayed undo point" thing yesterday .
Actually I tried different things with time_precise, Undo_BeginBlock/Undo_EndBlock and Get/SetExtState combination, but couldn't get it to work).
spk77 is offline   Reply With Quote
Old 07-15-2016, 11:05 AM   #40
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Edit: fixed - thanks cfillion! The code below is also updated.

So, this...
reaper.defer(main(false))
is replaced with...
reaper.defer(function() main(false) end)




I'm not able to get this undo thing working in Lua...
Can we pass functions with parameters to "reaper.defer" function? Like this: reaper.defer(main(false))?

I get Adjust hue via mousewheel.lua:164: stack overflow -error with this code:



Code:
--------------
-- Settings --
--------------

-- If track has default color, this value is used (as a starting point):
local default_color = 9732439     -- blue
--local default_color = 9211010   -- default track color of REAPER 5 theme

-- These variables define how many steps (mouse wheel turns) it takes to go from min val to max val
local hue_steps = 36
local sat_steps = 25
local lum_steps = 25

-- Min and max values for saturation and luminosity
local min_sat = 0.1
local max_sat = 1
local min_lum = 0.1
local max_lum = 0.9
-- End of settings --

local floor = math.floor
local min_v = math.min
local max_v = math.max

local defer_count = 0
local pc

function msg(m)
  return reaper.ShowConsoleMsg(tostring(m) .. "\n")
end

function intToRgb(color_int)
  local r = color_int & 255
  local g = (color_int >> 8) & 255
  local b = (color_int >> 16) & 255
  r = r/255
  g = g/255
  b = b/255
  return r, g, b
end


function rgbToHsl(r, g, b)
  --r, g, b = r / 255, g / 255, b / 255
  local max, min = max_v(r, g, b), min_v(r, g, b)
  local h, s, l

  l = (max + min) / 2

  if max == min then
    h, s = 0, 0 -- achromatic
  else
    local d = max - min
    --local s
    if l > 0.5 then s = d / (2 - max - min) else s = d / (max + min) end
    if max == r then
      h = (g - b) / d
      if g < b then h = h + 6 end
    elseif max == g then h = (b - r) / d + 2
    elseif max == b then h = (r - g) / d + 4
    end
    h = h / 6
  end
  return h, s, l
end



function hslToRgb(h, s, l)
  local r, g, b

  if s == 0 then
    r, g, b = l, l, l -- achromatic
  else
    function hue2rgb(p, q, t)
      if t < 0   then t = t + 1 end
      if t > 1   then t = t - 1 end
      if t < 1/6 then return p + (q - p) * 6 * t end
      if t < 1/2 then return q end
      if t < 2/3 then return p + (q - p) * (2/3 - t) * 6 end
      return p
    end

    local q
    if l < 0.5 then q = l * (1 + s) else q = l + s - l * s end
    local p = 2 * l - q

    r = hue2rgb(p, q, h + 1/3)
    g = hue2rgb(p, q, h)
    b = hue2rgb(p, q, h - 1/3)
  end

  --return r * 255, g * 255, b * 255
  return r, g, b
end


function adjust_hsl(val, adjust_hue, adjust_sat, adjust_lum)
  --local is_new_value, filename, sectionID, cmdID, mode, resolution, val = reaper.get_action_context()
  --msg(is_new_value)
  --msg(mode)
  --msg(resolution)
  --msg(val)
  --[[
  if val == -1 then
    return
  end
  --]]
  for i=1, reaper.CountSelectedTracks(0) do
    local tr = reaper.GetSelectedTrack(0, i-1)
    local color_int = reaper.GetTrackColor(tr)
    if color_int == 0 then color_int = default_color end
    local r,g,b = intToRgb(color_int)
    local h,s,l = rgbToHsl(r,g,b)

    if val < -1 then
      if adjust_hue then
        h = h + 1/(hue_steps)
      end
      if adjust_sat then
        s = s + 1/(sat_steps)
        if s > max_sat then 
          s = max_sat
        elseif s < min_sat then
          s = min_sat
        end
      end
      if adjust_lum then
        l = l + 1/(lum_steps)
        if l > max_lum then
          l = max_lum
        elseif l < min_lum then
          l = min_lum
        end
      end
    elseif val > -1 then
      if adjust_hue then
        h = h - 1/(hue_steps)
      end
      if adjust_sat then
        s = s - 1/(sat_steps)
        if s < min_sat then
          s = min_sat
        elseif s > max_sat then
          s = max_sat
        end
      end
      if adjust_lum then
        l = l - 1/(lum_steps)
        if l < min_lum then
          l = min_lum
        elseif l > max_lum then 
          l = max_lum
        end
      end
    end
    r,g,b = hslToRgb(h,s,l)
    reaper.SetTrackColor(tr, reaper.ColorToNative(floor(r*255+0.5), floor(g*255+0.5), floor(b*255+0.5)))
  end
end


function main(first_time)
  local is_new_value, filename, sectionID, cmdID, mode, resolution, val = reaper.get_action_context()
  if is_new_value or first_time then
    pc = reaper.time_precise()
    if val ~= 0 then
      -- Desc: adjust_hsl(boolean adjust_hue, boolean adjust_sat, boolean adjust_lum)
      adjust_hsl(val, true, false, false)
      -- adjust_hsl(false, true, false) -- adjust saturation
      -- adjust_hsl(false, false, true) -- adjust luminosity
    end
  end
  ---[[
  if reaper.time_precise() < pc + 1 then
    --defer_count = defer_count+1
    --reaper.ClearConsole()
    --msg(val)
    reaper.defer(function() main(false) end)
  else
    reaper.Undo_OnStateChangeEx("Adjust track color", -1, -1)
  end
  --]]
end

main(true)

Remove the red text and it works, but it creates an undo point every time:


Last edited by spk77; 07-15-2016 at 11:43 AM.
spk77 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 09:29 PM.


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