|
|
|
02-14-2014, 05:21 PM
|
#1
|
Human being with feelings
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
|
Converting Python to EEL script requests
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
|
|
|
02-14-2014, 05:31 PM
|
#2
|
Human being with feelings
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
|
Quote:
Originally Posted by Argitoth
|
Wow! Many Thanks.
Will test and report back as soon as get a chance.
Edit: After a quick test it seems to be working great.
Will check more.
Thanks, Wyatt
|
|
|
02-14-2014, 08:01 PM
|
#3
|
Human being with feelings
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
|
Here's another one I did awhile back that does reaper site search with google.
Is this one possible?
Code:
#Reaper Google Search.py
#Thanks gofer for the input box example.
import webbrowser
dialog_name = "Reaper Google Search"
howmanyfields = 1
field_names = "Search Reaper Forums"
default_values = ""
maxreturnlength = 100
User_Input = RPR_GetUserInputs(dialog_name,howmanyfields, field_names, default_values, maxreturnlength)
if User_Input[0] == 1:
UserValues = User_Input[4].split(',')
myinput = str(UserValues[0])
search = str('http://www.google.com/search?hl=en&biw=1280&bih=844&as_q=' + myinput +
'&as_epq=&as_oq=&as_eq=&tbs=&lr=&as_filetype=&ft=i&as_' +
'sitesearch=forum.cockos.com&as_qdr=all&as_rights=&as_occt=any&cr=&as_nlo=&as_nhi=&safe=images')
webbrowser.open(search)
Thanks, Wyatt
|
|
|
02-14-2014, 08:15 PM
|
#4
|
Human being with feelings
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
|
oh no that's really too difficult... I just converted 200 lines of python code into eel, this new script you posted is FAR MORE DIFFICULT!
jk.
ill do it.
edit: which is what I would have said if the script didn't have "import webbrowser". I don't think it's possible to translate.
edit: I'll have to ask the gurus, maybe they know a solution.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Last edited by Argitoth; 02-14-2014 at 08:22 PM.
|
|
|
02-16-2014, 09:36 AM
|
#5
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
Normalize selected items (active takes) to given range (EEL)
I converted this python script to EEL:
http://forum.cockos.com/showpost.php...&postcount=458
Normalize selected items to given range (fixed dB steps)
Code:
// Normalize selected items to given range
// ("take volumes" are adjusted)
function msg(m)
(
ShowConsoleMsg(m);
ShowConsoleMsg("\n");
);
function dialog()
(
#dialog_ret_vals = "-30.0,-6.0"; //default values
GetUserInputs("Normalize active takes to range", 2, "From (dB):,To (dB):", #dialog_ret_vals);
);
function normalize()
(
(sel_item_count = CountSelectedMediaItems(0)) >= 2 ? (
dialog() ? (
Undo_BeginBlock();
PreventUIRefresh(1);
Main_OnCommand(40108, 0); // normalize active takes to 0 dB (take volume)
match("%f,%f", #dialog_ret_vals, from_dB, to_dB);
i = 0;
loop(sel_item_count,
item = GetSelectedMediaItem(0, i);
take = GetActiveTake(item);
normalized_dB = 20 * log10(GetMediaItemTakeInfo_Value(take, "D_VOL")); // normalized_dB == take normalized to 0 dB
new_dB = normalized_dB + from_dB + (i * ((to_dB - from_dB) / (sel_item_count - 1)));
new_vol = pow(10, new_dB / 20);
SetMediaItemTakeInfo_Value(take, "D_VOL", new_vol);
i += 1;
);
PreventUIRefresh(-1);
Undo_EndBlock("Normalize to range", -1);
UpdateArrange();
)
) : ( // sel item count < 2 -> "quit" with error message
msg("Select at least two items");
);
);
normalize();
Last edited by spk77; 02-17-2014 at 10:57 AM.
Reason: added undo_beginblock/endblock
|
|
|
02-16-2014, 10:31 AM
|
#6
|
Human being with feelings
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
|
spk77, I feel like that would be useful with a few additions. I think the goal here would be to take a handful of samples and even out their dynamics. For example:
"set peak value of items up to #dB closer to the average peak value of all selected items"
for example
db values: -10 -5 -4 -3 +1 +6
averaged/target db: -2.5
#db = 3dB
-10 becomes -7 (you may only change value up to 3db)
-5 becomes -2.5
-4 becomes -2.5
-3 becomes -2.5
-1 becomes -2
+6 becomes +3 (you may only change value up to 3db)
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
|
|
|
02-16-2014, 02:15 PM
|
#7
|
Human being with feelings
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
|
Select items with color of selected items, way faster in EEL
Code:
// Select items with color of selected items
/* by Elan Hickler
www.Soundemote.com
www.elanhickler.com */
items = CountSelectedMediaItems(); // store number of items
items !=0 ? (
PreventUIRefresh(1);
Undo_BeginBlock2(0);
item = GetSelectedMediaItem(0, 0); // store first selected item
colorA = GetDisplayedMediaItemColor(item); // store color of first selected item
Main_OnCommand(40182,0); // *select all items
i=0;
loop(CountMediaItems(0), // *loop through every item and unselect if color does not match
item = GetMediaItem(0, i);
colorB = GetDisplayedMediaItemColor(item);
colorA != colorB ? (
SetMediaItemInfo_Value(item, "B_UISEL", 0); zz-=1;
);
i+=1;
);
Undo_EndBlock2(0, sprintf(#, "Select items with %{colorA}X color"), -1);
PreventUIRefresh(-1);
);
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Last edited by Argitoth; 02-17-2014 at 06:31 PM.
|
|
|
02-28-2014, 01:46 PM
|
#8
|
Human being with feelings
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
|
It's crazy that REAPER doesn't have this as a default action.
Code:
// Set number of channels for selected tracks
// by Elan Hickler
// www.Soundemote.com
// www.elanhickler.com
tracks = CountSelectedTracks(0);
tracks > 0 ? (
#input = "2";
Query = GetUserInputs("Set track number of channel count", 1, "number of channels:", #input);
match("%{input}i",#input);
Query == 1 ? (
Undo_BeginBlock2(0);
i = 0;
loop(tracks,
track = GetSelectedTrack(0, i);
SetMediaTrackInfo_Value(track, "I_NCHAN", input);
i+=1;
);
Undo_EndBlock2(0, sprintf(#,"Set number of channels for %{tracks}i tracks"), -1);
);
);
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
|
|
|
03-01-2014, 03:43 PM
|
#9
|
-blänk-
Join Date: Jun 2008
Posts: 11,359
|
Shameless request for EELization of (some of) these :
http://forum.cockos.com/showthread.php?p=1322189
Snippets would already help a lot to get me started learning this fishy stuff.
|
|
|
03-06-2014, 09:09 AM
|
#10
|
Human being with feelings
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
|
VERY USEFUL! Set item rate and decide whether you want to preserve length and or preserve pitch of item.
Code:
// Set item rate, 'preserve pitch', preserve length...
// by Elan Hickler
// www.Soundemote.com
// www.elanhickler.com
#userinputs = "0.5,0,0"; // defaults
query = GetUserInputs("Set item rate", 3, "rate,preserve pitch? (1=yes 0=no),preserve length? (1=yes 0=no)", #userinputs);
query == 1 ? (
Undo_BeginBlock();
match("%f,%i,%i",#userinputs,newRate,preservePitch,preserveLength);
items = CountSelectedMediaItems(0);
i=0;
loop(items,
item = GetSelectedMediaItem(0,i);
take = GetActiveTake(item);
length = GetMediaItemInfo_Value(item, "D_LENGTH");
rate = GetMediaItemTakeInfo_Value(take, "D_PLAYRATE");
// set rate
SetMediaItemTakeInfo_Value(take, "D_PLAYRATE", newRate);
// set preserve pitch
preservePitch != 0 ? #ppitch = ", clear 'preserve pitch'";
SetMediaItemTakeInfo_Value(take, "B_PPITCH", preservePitch);
// set preserve length
preserveLength != 0 ? #plength = " and preserve length";
preserveLength == 0 ? (
newLength = rate / newRate * length;
SetMediaItemLength(item, newLength, 0);
);
i+=1;
);
UpdateArrange();
sprintf(#undo,"Set item rate to %{newRate}g%{#plength}s%{#ppitch}s");
Undo_EndBlock(#undo, -1);
);
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Last edited by Argitoth; 03-06-2014 at 09:45 AM.
|
|
|
03-28-2014, 08:52 PM
|
#11
|
Human being with feelings
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
|
Hey guys,
My cut tool (split items) was coded in Python and I'd love to see how much faster it would run in EEL. Unfortunately, I know nothing about coding, let alone converting from one language to another.
I would love it if someone could convert this to EEL, please.
Code:
from reaper_python import *
from contextlib import contextmanager
@contextmanager
def undoable(message):
RPR_Undo_BeginBlock2(0)
try:
yield
finally:
RPR_Undo_EndBlock2(0,message,-1)
with undoable('Split item(s)'):
SelectItemUnderCursor = 40528
DeselectItems = 40289
MoveCursor = 40513
SplitItems = RPR_NamedCommandLookup('_SWS_AWSPLITXFADELEFT')
SelectPreviousItem = RPR_NamedCommandLookup('_SWS_SELPREVITEM2')
CrossfadeToTimeSel = 40916
selItems = RPR_CountSelectedMediaItems(0)
timeSel = RPR_GetSet_LoopTimeRange2(0, 0, 0, 0, 0, 0)[3] != RPR_GetSet_LoopTimeRange2(0, 0, 0, 0, 0, 0)[4]
RPR_Main_OnCommand(MoveCursor, 0)
if (selItems==0):
RPR_Main_OnCommand(SelectItemUnderCursor, 0)
RPR_Main_OnCommand(SplitItems, 0)
if (timeSel!=0):
RPR_Main_OnCommand(SelectPreviousItem, 0)
RPR_Main_OnCommand(CrossfadeToTimeSel, 0)
RPR_Main_OnCommand(DeselectItems, 0)
if (selItems!=0):
RPR_Main_OnCommand(SplitItems, 0)
if (timeSel!=0):
RPR_Main_OnCommand(SelectPreviousItem, 0)
RPR_Main_OnCommand(CrossfadeToTimeSel, 0)
Last edited by daxliniere; 05-24-2019 at 12:49 PM.
|
|
|
03-29-2014, 04:23 AM
|
#12
|
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
Quote:
Originally Posted by daxliniere
I would love it if someone could convert this to EEL, please.
|
Code:
function sel_prev_item_crossfade_to_time_sel()
(
Main_OnCommand(NamedCommandLookup("_SWS_SELPREVITEM2"), 0);
Main_OnCommand(40916, 0); // crossfade to time selection
);
function split_items()
(
Main_OnCommand(NamedCommandLookup("_SWS_AWSPLITXFADELEFT"), 0);
);
function dax_split()
(
PreventUIRefresh(1);
Undo_BeginBlock2(0);
GetSet_LoopTimeRange2(0, 0, 0, ts_start, ts_end, 0);
time_sel = ts_start !== ts_end;
Main_OnCommand(40513, 0); // move edit cursor to mouse cursor
CountSelectedMediaItems(0) === 0 ?
(
Main_OnCommand(40528, 0); // select item under cursor
split_items();
time_sel ?
sel_prev_item_crossfade_to_time_sel();
Main_OnCommand(40289, 0); // deselect items
) : // else
(
split_items();
time_sel ?
sel_prev_item_crossfade_to_time_sel();
);
PreventUIRefresh(-1);
Undo_EndBlock2(0, "Split item(s)", -1);
);
dax_split();
Here's a refactored Python version of your script also, for easier comparison:
Code:
from reaper_python import *
from contextlib import contextmanager
@contextmanager
def undoable(message):
RPR_Undo_BeginBlock2(0)
try:
yield
finally:
RPR_Undo_EndBlock2(0, message, -1)
def split_items():
RPR_Main_OnCommand(RPR_NamedCommandLookup('_SWS_AWSPLITXFADELEFT'), 0)
def sel_prev_item_crossfade_to_time_sel():
RPR_Main_OnCommand(RPR_NamedCommandLookup("_SWS_SELPREVITEM2"), 0)
RPR_Main_OnCommand(40916, 0) # crossfade to time selection
with undoable('Split item(s)'):
time_sel = RPR_GetSet_LoopTimeRange2(0, 0, 0, 0, 0, 0)
time_sel = time_sel[3] != time_sel[4]
RPR_Main_OnCommand(40513, 0) # move edit cursor to mouse cursor
if RPR_CountSelectedMediaItems(0) == 0:
RPR_Main_OnCommand(40528, 0) # select item under cursor
split_items()
if time_sel:
sel_prev_item_crossfade_to_time_sel()
RPR_Main_OnCommand(40289, 0) # deselect items
else:
split_items()
if time_sel:
sel_prev_item_crossfade_to_time_sel()
They both prevent the UI from refreshing during the edit, which makes them feel quicker ...
|
|
|
03-29-2014, 07:13 AM
|
#13
|
Human being with feelings
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
|
What a dude!! Thanks so much, Tim, I really appreciate it.
|
|
|
04-03-2014, 06:35 PM
|
#14
|
Human being with feelings
Join Date: Feb 2012
Posts: 1,972
|
Could somebody please convert this to EEL? (insert FX to a track)
Thanks in advance
Code:
RPR_Undo_BeginBlock()
FX = "H-Delay"
TrackIdx = 0
TrackCount = RPR_CountSelectedTracks(0)
while TrackIdx < TrackCount:
track = RPR_GetSelectedTrack(0, TrackIdx)
fxIdx = RPR_TrackFX_GetByName (track, FX, 1)
isOpen = RPR_TrackFX_GetOpen(track, fxIdx)
if isOpen ==0:
isOpen = 1
else:
isOpen = 0
RPR_TrackFX_SetOpen(track, fxIdx, isOpen)
TrackIdx +=1
RPR_Undo_EndBlock("Insert Waves H-Delay",0)
|
|
|
04-03-2014, 11:42 PM
|
#15
|
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
Code:
function insert_fx()
(
fx = "H-Delay";
i = 0;
Undo_BeginBlock();
loop(CountSelectedTracks(0),
track = GetSelectedTrack(0, i);
fx_idx = TrackFX_GetByName(track, fx, 1);
is_open = !TrackFX_GetOpen(track, fx_idx);
TrackFX_SetOpen(track, fx_idx, is_open);
i += 1;
);
#undo_msg = "Insert ";
Undo_EndBlock(strcat(#undo_msg, fx), 0);
);
insert_fx();
You might want to think about changing the way undo is used (or named) in this script. At the moment, if fx has just been:
- added to the track, undo will remove it
- toggled closed on the track, undo will show the fx GUI
- reopened on the track, undo will do nothing
But I'll leave it up to you
Last edited by timlloyd; 04-04-2014 at 12:01 AM.
|
|
|
04-04-2014, 02:36 AM
|
#16
|
Human being with feelings
Join Date: Feb 2012
Posts: 1,972
|
Thanks! Do you know why undo message isnt working? It shows me "ReaScript : Run"
|
|
|
04-04-2014, 04:54 AM
|
#17
|
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
Yeah, I've noticed that with EEL scripts as well, but I don't think it was occurring with that script when I checked it this morning ... don't remember :-/
IIRC you should actually be using a 2rd argument of -1 in Undo_EndBlock. -1 should be used if the state of the project is modified directly, rather than by calling 'native' reaper actions, in which case you can use 0.
See if it helps to remove the original call to Undo_EndBlock and just stick it at the end of the script ... not sure why that would make a difference.
Code:
function insert_fx()
(
fx = "ReaEQ";
i = 0;
Undo_BeginBlock();
loop(CountSelectedTracks(0),
track = GetSelectedTrack(0, i);
fx_idx = TrackFX_GetByName(track, fx, 1);
is_open = !TrackFX_GetOpen(track, fx_idx);
TrackFX_SetOpen(track, fx_idx, is_open);
i += 1;
);
#undo_msg = "Insert ";
strcat(#undo_msg, fx);
);
insert_fx();
Undo_EndBlock(#undo_msg, -1);
Last edited by timlloyd; 04-04-2014 at 05:03 AM.
|
|
|
04-04-2014, 02:22 PM
|
#18
|
Human being with feelings
Join Date: Feb 2012
Posts: 1,972
|
Still the same. Should we make bug report?
|
|
|
04-04-2014, 05:37 PM
|
#19
|
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
Yes, I think so.
|
|
|
04-05-2014, 02:11 AM
|
#20
|
Human being with feelings
Join Date: Jun 2012
Location: Spain
Posts: 7,239
|
|
|
|
04-05-2014, 03:34 AM
|
#21
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
Quote:
Originally Posted by heda
|
Add/Remove NO_TRP prefix (Creating an undo point doesn't work correctly - it adds an extra "ReaScript: run" -point. Tried also with "Undo_OnStateChange")
Code:
// Add/Remove NO_TRP prefix
function prepend_take_name() local (i)
(
i = 0;
#src_str = "(NO_TRP) ";
str_len = strlen(#src_str);
//Undo_BeginBlock();
loop(CountSelectedMediaItems(0),
(curr_item = GetSelectedMediaItem(0, i)) ? (
(take = GetActiveTake(curr_item)) ? (
GetTakeName(#take_name, take) ? (
match("(NO_TRP) *", #take_name) ? (
str_delsub(#take_name, 0, str_len); // deletes len chars at pos
) : (
str_insert(#take_name, "(NO_TRP) ", 0); //inserts srcstr at pos
);
GetSetMediaItemTakeInfo_String(take, "P_NAME", #take_name, 1);
);
);
);
i += 1;
);
//Undo_EndBlock("Add/Remove NO_TRP prefix", -1);
);
prepend_take_name();
|
|
|
04-05-2014, 11:53 AM
|
#22
|
Human being with feelings
Join Date: Jun 2012
Location: Spain
Posts: 7,239
|
thank you skp77. I am starting to learn Python and EEL. It helps.
EEL seems even more condensed language full of smilies
I forgot the "unselect items with NO_TRP in take name" script to be translated also:
Code:
###unselect items with NO_TRP in name 2###
from reaper_python import *
from contextlib import contextmanager
@contextmanager
def noUIRefresh():
RPR_PreventUIRefresh(1)
try:
yield
finally:
RPR_PreventUIRefresh(-1)
def make_usmiL():
csmi = RPR_CountSelectedMediaItems(0)
for i in range(csmi):
CurrItem = RPR_GetSelectedMediaItem(0, i)
CT = RPR_GetMediaItemInfo_Value(CurrItem, "I_CURTAKE")
GT = RPR_GetTake(CurrItem, int(CT))
if 'NO_TRP' in str(RPR_GetTakeName(GT)):
usmiL.append(CurrItem)
def unselect_from_usmiL():
while len(usmiL) >= 1:
unsel_item = usmiL.pop()
RPR_SetMediaItemSelected(unsel_item, 0)
RPR_UpdateItemInProject(unsel_item)
usmiL = []
with noUIRefresh():
make_usmiL()
unselect_from_usmiL()
|
|
|
04-05-2014, 01:06 PM
|
#23
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
Quote:
Originally Posted by heda
thank you skp77. I am starting to learn Python and EEL. It helps.
EEL seems even more condensed language full of smilies
|
I'm still learning too (manipulating strings is much easier in Python)
Unselect items with NO_TRP in name
Code:
// Unselect items with NO_TRP in name
function unselect() local (i)
(
i = 0;
//Undo_BeginBlock();
loop(CountSelectedMediaItems(0),
(curr_item = GetSelectedMediaItem(0, i)) ? (
(take = GetActiveTake(curr_item)) ? (
GetTakeName(#take_name, take) ? (
match("(NO_TRP) *", #take_name) == 0 ? (
// "(NO_TRP) " not found at the start of name -> unselect item
// -> subtract "1" from "i" to get the correct item at next iteration
SetMediaItemSelected(curr_item, 0);
i -= 1;
);
);
);
);
i += 1;
);
//Undo_EndBlock("Unselect items with NO_TRP in name", -1);
UpdateArrange();
);
unselect();
|
|
|
04-05-2014, 01:48 PM
|
#24
|
Human being with feelings
Join Date: Jun 2012
Location: Spain
Posts: 7,239
|
great
this selects only the items with NO_TRP in name
changing the 0 to 1 in the match line seems to do the unselect for those items
Code:
match("(NO_TRP) *", #take_name) == 1 ? (
|
|
|
04-09-2014, 11:11 PM
|
#25
|
Human being with feelings
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
|
Quote:
Originally Posted by timlloyd
Code:
function insert_fx()
(
fx = "ReaEQ";
i = 0;
Undo_BeginBlock();
loop(CountSelectedTracks(0),
track = GetSelectedTrack(0, i);
fx_idx = TrackFX_GetByName(track, fx, 1);
is_open = !TrackFX_GetOpen(track, fx_idx);
TrackFX_SetOpen(track, fx_idx, is_open);
i += 1;
);
#undo_msg = "Insert ";
strcat(#undo_msg, fx);
);
insert_fx();
Undo_EndBlock(#undo_msg, -1);
|
Can I simply swap 'track' for 'item' to insert FX on an item?
Cheers!
|
|
|
04-10-2014, 02:53 PM
|
#26
|
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
Quote:
Originally Posted by daxliniere
Can I simply swap 'track' for 'item' to insert FX on an item?
Cheers!
|
Nope, it's not that straight forward for item FX!
|
|
|
05-01-2014, 07:55 AM
|
#27
|
Human being with feelings
Join Date: Nov 2008
Location: London, UK
Posts: 2,581
|
Quote:
Originally Posted by timlloyd
Nope, it's not that straight forward for item FX!
|
Is it something you think you could do?
|
|
|
05-18-2014, 06:17 PM
|
#28
|
Human being with feelings
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
|
Request needed. I have a track volume script that raises track volume in 1dB steps. How could I round the digits after the decimal point?
e.g If I have a track volume of +4.26 how could I round that to +4.30?
Thanks
Edit: Here's my script
Code:
TrackCount = CountSelectedTracks(0);
TrackIndex = 0;
Undo_BeginBlock();
while ( TrackIndex < TrackCount ) (
tr = GetSelectedTrack(0, TrackIndex);
GetTrackUIVolPan(tr, vol, pan);
//If vol is at -inf, set to -150dB
vol < 0.00000002818383 ? (
SetMediaTrackInfo_Value(tr, "D_VOL", 0.00000003162278);
):
SetMediaTrackInfo_Value(tr, "D_VOL", vol*1.1220184543019633);
TrackIndex +=1;
#undo_msg = "Adjust Track Volume";
);
Undo_EndBlock(#undo_msg, -1);
Last edited by WyattRice; 05-18-2014 at 06:49 PM.
|
|
|
05-18-2014, 11:53 PM
|
#29
|
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
Quote:
Originally Posted by WyattRice
How could I round the digits after the decimal point?
e.g If I have a track volume of +4.26 how could I round that to +4.30?
|
To round to 1 dp, add 0.05, then multiply by 10. Then floor() this value and multiply by 0.1 (divide by 10).
Code:
v = floor((v + 0.05) * 10) * 0.1;
I think you'll see this result as, for example, 4.299999 instead of 4.3 if you convert to string and print to the console.
To round to 2 dp, use 0.005, 100 and 0.01 instead, etc.
Could make a generic round(value, dp) function for you, but in a rush, sorry!
Last edited by timlloyd; 05-19-2014 at 12:01 AM.
|
|
|
05-20-2014, 03:34 PM
|
#30
|
Human being with feelings
Join Date: Sep 2009
Location: Virginia
Posts: 2,067
|
Quote:
Originally Posted by timlloyd
To round to 1 dp, add 0.05, then multiply by 10. Then floor() this value and multiply by 0.1 (divide by 10).
Code:
v = floor((v + 0.05) * 10) * 0.1;
I think you'll see this result as, for example, 4.299999 instead of 4.3 if you convert to string and print to the console.
To round to 2 dp, use 0.005, 100 and 0.01 instead, etc.
Could make a generic round(value, dp) function for you, but in a rush, sorry!
|
Thanks Tim. I didn't do very well in math. Here's my latest try.
Could you check it for me? Thanks, Wyatt
Code:
//Round and adjust selected tracks volume in 1dB steps
//Can be used to adjust down also.
//On line starting with incr = +1 can be changed to -1 to decrease.
//Steps can changed to 0.5 etc.
TrackCount = CountSelectedTracks(0);
TrackIndex = 0;
Undo_BeginBlock();
while (TrackIndex < TrackCount) (
tr = GetSelectedTrack(0, TrackIndex);
GetTrackUIVolPan(tr, vol, pan);
// If vol is at -inf, set to -150dB
vol < 0.00000002818383 ? (
SetMediaTrackInfo_Value(tr, "D_VOL", 0.00000003162278);
):
incr = +1;
vol = GetMediaTrackInfo_Value(tr, "D_VOL");
v = (20.0 * log10(vol)) + incr;
v = floor((v + 0.05) * 10) * 0.1;
SetMediaTrackInfo_Value(tr, "D_VOL", 10.0 ^ (v / 20.0));
TrackIndex +=1;
#undo_msg = "Adjust Track Volume";
Undo_EndBlock(#undo_msg, -1);
);
Last edited by WyattRice; 05-20-2014 at 05:10 PM.
|
|
|
01-22-2015, 06:29 AM
|
#31
|
Human being with feelings
Join Date: Jun 2012
Posts: 2,173
|
Seriously...
Code:
abc = "123"
x = int(abc)
then,
Code:
abc = "1,2,3"
x = int(abc)[2]
then,
Code:
abc = "1,2,3"
x = int(abc.split(",")[1])
edit- match, then?
Last edited by FnA; 01-24-2015 at 04:54 PM.
|
|
|
11-24-2016, 12:54 PM
|
#33
|
Human being with feelings
Join Date: May 2008
Location: France
Posts: 138
|
Quote:
Originally Posted by Argitoth
It's crazy that REAPER doesn't have this as a default action.
Code:
// Set number of channels for selected tracks
// by Elan Hickler
// www.Soundemote.com
// www.elanhickler.com
tracks = CountSelectedTracks(0);
tracks > 0 ? (
#input = "2";
Query = GetUserInputs("Set track number of channel count", 1, "number of channels:", #input);
match("%{input}i",#input);
Query == 1 ? (
Undo_BeginBlock2(0);
i = 0;
loop(tracks,
track = GetSelectedTrack(0, i);
SetMediaTrackInfo_Value(track, "I_NCHAN", input);
i+=1;
);
Undo_EndBlock2(0, sprintf(#,"Set number of channels for %{tracks}i tracks"), -1);
);
);
|
any way to automaticly close the window ?
__________________
Reaper's community rocks...
|
|
|
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 11:52 PM.
|