Old 04-12-2014, 04:48 AM   #481
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Does this do what you want adastra? If so just copy the script a bunch of times changing the number 31 in the function.

Code:
from reaper_python import *

RPR_GoToMarker(0, 31, 0)
note about the last number in the function from the help menu-

Python: RPR_GoToMarker(ReaProject* proj, Int marker_index, Boolean use_timeline_order)

Go to marker. If use_timeline_order==true, marker_index 1 refers to the first marker on the timeline. If use_timeline_order==false, marker_index 1 refers to the first marker with the user-editable index of 1

I don't know how to do the other one

Last edited by FnA; 04-12-2014 at 05:57 AM.
FnA is offline   Reply With Quote
Old 04-12-2014, 03:14 PM   #482
adastra
Human being with feelings
 
Join Date: Mar 2014
Posts: 9
Default

Thanks very much! I'll give it a try and let you know how it goes.
Cheers.
adastra is offline   Reply With Quote
Old 04-12-2014, 03:44 PM   #483
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

The other script might not be so bad if the markers already exist and you just want to move them to edit or play cursor. Is that the case?

Here's that one anyway-

Code:
###move marker 11 to edit or play cursor###
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 move_marker():
    POS = 0
    if RPR_GetToggleCommandState(1007):#transport-play
        POS = RPR_GetPlayPosition()
    else:
        POS = RPR_GetCursorPosition()

    RPR_SetProjectMarker(11, 0, POS, 0, "")#switch the 11 out

with undoable("move marker 11"):
    move_marker()

Last edited by FnA; 04-12-2014 at 04:07 PM.
FnA is offline   Reply With Quote
Old 04-12-2014, 04:28 PM   #484
adastra
Human being with feelings
 
Join Date: Mar 2014
Posts: 9
Default

You have it right, the other markers would already exist. I have tried both scripts and they seem to be working! I am extremely grateful. I've got a little more testing to do, but you have really helped me out, basically this means I can use Reaper with my Avid live console with all the same functionality of ProTools. Kind of a game changer.
Kudos and Thanks!
adastra is offline   Reply With Quote
Old 04-12-2014, 06:51 PM   #485
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Hope it works out. Markers are turning out to be a little trickier than I had thought they would be.
FnA is offline   Reply With Quote
Old 04-14-2014, 12:17 PM   #486
FnA
Human being with feelings
 
FnA's Avatar
 
Join Date: Jun 2012
Posts: 2,173
Default

Here you go James. I think it does what it is supposed to. Test it out. I don't think it needs to go into a separate place as per timlloyds post, if you're on windows 7. Don't know about XP or anything else.

Code:
###renumber markers starting with named markers###
from reaper_python import *
from sws_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0,message,-1)

def renumber_named_markers_first():
    num_markers = RPR_CountProjectMarkers(0, 0, 0)[0]
    LOL1 = []
    LOL2 = []
    counter = 0

    for i in range(num_markers):
        epm3 = RPR_EnumProjectMarkers3(0, i, 0, 0, 0, '', 0, 0)
        if epm3[3]:
            continue

        fs = SNM_CreateFastString("")
        SNM_GetProjectMarkerName(0, epm3[7], 0, fs)
        name = SNM_GetFastString(fs)
        SNM_DeleteFastString(fs)

        if name == '':
            LOL2.append(epm3)
        else:
            LOL1.append(epm3)
            counter += 1

    for i in range(len(LOL1)):
        epm3 = LOL1.pop(0)
        RPR_SetProjectMarkerByIndex(0, epm3[2], 0, epm3[4], 0, i + 1, '', 0)

    for i in range(len(LOL2)):
        epm3 = LOL2.pop(0)
        RPR_SetProjectMarkerByIndex(0, epm3[2], 0, epm3[4], 0, i + 1 + counter, '', 0)

with undoable('renumber markers- named first'):
    renumber_named_markers_first()
FnA is offline   Reply With Quote
Old 04-14-2014, 01:09 PM   #487
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,268
Default

Script request:
I have a .csv file with frequencies and gain for each frequencies
like:
...
103.01,-0.63
115.81,-0.73
130.19,0.04
207.96,0.02
233.79,-0.95
...
etc

is it possible a script that reads the csv, adds a band in ReaEQ for each line in the csv and sets Frequency and gain for each band accordingly and a defined bandwidth for all?
is it possible?
heda is offline   Reply With Quote
Old 04-14-2014, 04:08 PM   #488
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Quote:
Originally Posted by FnA View Post
Here you go James. I think it does what it is supposed to. Test it out. I don't think it needs to go into a separate place as per timlloyds post, if you're on windows 7. Don't know about XP or anything else.
PERFECT!!!!!!!!!!!!!!!!!!!!
James HE is offline   Reply With Quote
Old 04-14-2014, 09:29 PM   #489
plamuk
Human being with feelings
 
Join Date: Feb 2007
Posts: 3,221
Default

EDIT - perfect. looks like there's already a sws action from which i could roll my own. thanks anyway, and thanks viente for bringing me here.

request: hide tracks that don't contain items.

this would make for a very quick "item overview" - hiding folder, template, and otherwise empty tracks. it would help a lot for lasso-based copy/move and similar functions.

source thread:

http://forum.cockos.com/showthread.p...91#post1341491

Last edited by plamuk; 04-15-2014 at 07:55 AM.
plamuk is offline   Reply With Quote
Old 04-18-2014, 06:25 AM   #490
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

I badly need an EEL script which check if selected item is in range of current time selection. Somebody please help!
Viente is offline   Reply With Quote
Old 04-18-2014, 07:38 AM   #491
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Viente View Post
I badly need an EEL script which check if selected item is in range of current time selection. Somebody please help!
Code:
// convert int to string and show message
function msg_d(m)
(
  ShowConsoleMsg(sprintf(#, "%d", m)); // "convert" int to string
  ShowConsoleMsg("\n");
);

function is_item_within_time_sel()
(
  (itemId = GetSelectedMediaItem(0, 0)) ? ( // get first selected item (if GetSelectedMediaItem() returns 0 -> do nothing)
    // GetSet_LoopTimeRange(bool isSet, bool isLoop, &startOut, &endOut, bool allowautoseek)
    GetSet_LoopTimeRange(0, 0, time_sel_start, time_sel_end, 0);  // get time selection start/end
    time_sel_start != time_sel_end ? ( // no time selection -> do nothing
      pos = GetMediaItemInfo_Value(itemId, "D_POSITION"); // item start
      length = GetMediaItemInfo_Value(itemId, "D_LENGTH"); // item end
      end_pos = pos + length; // item length
      pos >= time_sel_start && end_pos <= time_sel_end ? 1 : 0; // if item is in time selection -> return 1, else 0
    );
  );
);

msg_d(is_item_within_time_sel());
spk77 is offline   Reply With Quote
Old 04-18-2014, 07:44 AM   #492
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

or you could do

save item selection
unselect all items
select items within time selection
is item selected?
restore item selection

might be more efficient.
__________________
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 04-18-2014, 07:46 AM   #493
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Thank you guys!
Viente is offline   Reply With Quote
Old 04-20-2014, 06:33 AM   #494
Ozymandias
Human being with feelings
 
Join Date: Apr 2011
Posts: 144
Default

Hi all,

A request for the EEL experts here:

Transpose selected notes using Ctrl+Alt+Shift & mouse wheel.

I imagine this would have to be a background script listening out for Ctrl+Alt+Shift...

Thanks.
Ozymandias is offline   Reply With Quote
Old 04-20-2014, 07:38 AM   #495
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Can't this be done with a custom action?

I use Shift-Alt mousewheel to change peak zoom.


Edit: no, sorry, I can move all notes in a selected MIDI item by mousewheel using the "Skip next action..." action, but it needs to be on selected notes in the ME action list, and that Skip action isn't in there...


>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 04-20-2014, 08:54 AM   #496
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Ozymandias View Post
Hi all,

A request for the EEL experts here:

Transpose selected notes using Ctrl+Alt+Shift & mouse wheel.

I imagine this would have to be a background script listening out for Ctrl+Alt+Shift...

Thanks.
Hi,
This is a little problematic: it would need a GUI (and that window should be focused). I think there isn't another way to get "key presses".
spk77 is offline   Reply With Quote
Old 04-20-2014, 10:26 AM   #497
Ozymandias
Human being with feelings
 
Join Date: Apr 2011
Posts: 144
Default

Thanks Spk77. I wasn't sure whether it was possible or not. A GUI would definitely make it too long-winded.

Quote:
Originally Posted by planetnine View Post
Edit: no, sorry, I can move all notes in a selected MIDI item by mousewheel using the "Skip next action..." action, but it needs to be on selected notes in the ME action list, and that Skip action isn't in there...
You're transposing all notes in an item using the mousewheel? Even that would be interesting to me. How are you going about it?
Ozymandias is offline   Reply With Quote
Old 04-20-2014, 11:54 AM   #498
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Quote:
Originally Posted by Ozymandias View Post
You're transposing all notes in an item using the mousewheel? Even that would be interesting to me. How are you going about it?
By transposing, I'm meaning moving all by the same number of semitones.

Create a custom action like this:
Code:
Action: Skip next action if CC parameter <0/mid
SWS/FNG: Transpose selected MIDI items up a semitone
Action: Skip next action if CC parameter >0/mid
SWS/FNG: Transpose selected MIDI items down a semitone
That works on all notes in any selected items in the arrange (main) window, but for selected notes it would have to be a ME custom action and the "Skip next action..." Actions don't exist in that action list.

Sorry I jumped to a conclusion there, I though it would be easily done...

Edit: ...and assign it to "Ctrl+Alt+Shift+Mousewheel"



>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.

Last edited by planetnine; 04-20-2014 at 12:04 PM.
planetnine is offline   Reply With Quote
Old 04-20-2014, 01:26 PM   #499
Ozymandias
Human being with feelings
 
Join Date: Apr 2011
Posts: 144
Default

Thanks!

I'll have a play with that. I didn't think to look in the Main section for a solution, so I've never seen those actions 'til now.
Ozymandias is offline   Reply With Quote
Old 04-20-2014, 02:37 PM   #500
Ozymandias
Human being with feelings
 
Join Date: Apr 2011
Posts: 144
Default

You've cracked it, planetnine!

By importing move notes up/down into the Main section, we can use them with the "Skip next..." actions.

Code:
MIDIEditor_LastFocused_OnCommand(40178,0); //Move notes down one semitone
Code:
MIDIEditor_LastFocused_OnCommand(40177,0); //Move notes up one semitone


Works great!

Ideally, I would import the "Skip next..." actions into the MIDI Editor list instead, but I've tried it and for some reason it didn't work. I assume this has something to do with the way Reaper handles MIDI CC control.

Consequently, the mouse has to be hovering over the arrange window for this to work. That's no great hardship, though.
Ozymandias is offline   Reply With Quote
Old 04-21-2014, 02:14 PM   #501
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 7,268
Default

another script idea:
Set item to random colors based on source filename.
for example all items which their source is "audio_a.wav" assign them a random color, all items with "audio_b.wav" assign them to another random color and so on.
heda is offline   Reply With Quote
Old 04-22-2014, 02:57 PM   #502
planetnine
Human being with feelings
 
planetnine's Avatar
 
Join Date: Oct 2007
Location: Lincoln, UK
Posts: 7,942
Default

Quote:
Originally Posted by Ozymandias View Post
You've cracked it, planetnine!

By importing move notes up/down into the Main section, we can use them with the "Skip next..." actions.

Code:
MIDIEditor_LastFocused_OnCommand(40178,0); //Move notes down one semitone
Code:
MIDIEditor_LastFocused_OnCommand(40177,0); //Move notes up one semitone
Works great!

Ideally, I would import the "Skip next..." actions into the MIDI Editor list instead, but I've tried it and for some reason it didn't work. I assume this has something to do with the way Reaper handles MIDI CC control.

Consequently, the mouse has to be hovering over the arrange window for this to work. That's no great hardship, though.
That's neat, glad I could help.

I think I'll have a play with that tomorrow...


>
__________________
Nathan, Lincoln, UK. | Item Marker Tool. (happily retired) | Source Time Position Tool. | CD Track Marker Tool. | Timer Recording Tool. | dB marks on MCP faders FR.
planetnine is offline   Reply With Quote
Old 04-23-2014, 11:06 AM   #503
spinlud
Human being with feelings
 
Join Date: Jun 2012
Posts: 442
Default

This is a little EEL function, thanks to the great help of spk77:

Code:
function doubleClickMediaItem() (

	itemId = GetSelectedMediaItem(0, 0);
	active_take = GetActiveTake(itemId);	// get active take
	PCM_source = GetMediaItemTake_Source(active_take);	// get PCM source from active take
	
	GetMediaSourceType(PCM_source, #buffer);  // get source type from source -> store type to #buffer
		/* GetMediaSourceType(PCM_source* source, #typebuf)  
		   copies the media source type ("WAV", "MIDI", etc) to typebuf 
		*/

		
	// stricmp(str, str2) -- compares str to str2, ignoring case, returns -1, 0, or 1
	// NOTE: returns 0 if #buf == "MIDI"

 	stricmp(#buffer, "MIDI") == 0 ? (		
		
	
		Main_OnCommand(40153, 0); 			// open selected item in MIDI editor
		MIDIEditor_OnCommand(MIDIEditor_GetActive(), 40468);	// zoom one loop iteration

	) : (

 		Main_OnCommand(40290, 0);	 // time selection to items
 		Main_OnCommand(41622, 0);	 // toggle zoom to selected item 

	);
);

doubleClickMediaItem();
It uses the media type condition: if a midi item is selected, it opens the midi editor and zoom to one loop iteration for that item; if an audio item is selected, it zoom to that item and select time selection on item (run again will zoom out). Didn't find a way to restore the previous time selection though.

I've assigned this in mouse modifiers 'media item' 'double click'. cheers
spinlud is offline   Reply With Quote
Old 04-23-2014, 02:00 PM   #504
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Is it possible with Reascript to up or down envelope point to minimum/maximum value?
Viente is offline   Reply With Quote
Old 04-23-2014, 03:01 PM   #505
witti
Human being with feelings
 
witti's Avatar
 
Join Date: May 2012
Posts: 1,216
Default

I want to add a slash (/) as a suffix to a track name,
so when rendering, reaper creates a subfolder for the rendered items, folder named by the track.
After rendering i want to remove the slash again.

spk77 was so kind to help me with a script, so i can add a suffix to track names
(which is also possible via the Xenakios command parameters by the way,
but eel is more flexible...).

Code 'Add suffix'

Code:
i = 0;
loop(CountSelectedTracks(0),
  (track = GetSelectedTrack(0, i)) ? (  // if track pointer != 0 -> do the code inside brackets
    GetSetMediaTrackInfo_String(track, "P_NAME", #track_name, 0); // get track name
    #track_name += "/"; // add "/" suffix
    GetSetMediaTrackInfo_String(track, "P_NAME", #track_name, 1); // set track name
  );
  i += 1;
);
I tried hard, but couldn't find a way to remove this suffix again from the track name.


So i created a macro with some 'undos' (consolidate undo points unticked).
If you want to try it, just select some items on a track, or set a time selection to some items on a track.

sws: select only track(s) with selected items
custom: Add suffix.eel
track: render selected area of tracks to stereo post-fader stem tracks
edit: undo
edit: undo
time selection: remove time selection
track: unselect all tracks


Works great. Still have to find out how to rename the rendered (source) file (during this macro).
For some reason the rendered file is not named after the track/item name. Needs another eel script i suppose...

...currently i'm too stupid for that. I'm still learning.
But today i've 'created' two small scripts which are really filling some editing holes in reaper.

One script resets the item snap offset to default and the other one resets the media item source offset to default.
No real biggies, but for me these opened a complete new world of editing possibilities...

Code:
// Reset snap offset

function resetsnapoffset() local (i)
(
i = 0;
loop(CountSelectedMediaItems(0),
(curr_item = GetSelectedMediaItem(0, i)) ? (
GetMediaItemInfo_Value(curr_item,"D_SNAPOFFSET");
SetMediaItemInfo_Value(curr_item, "D_SNAPOFFSET", 0);
);
i += 1;
);
UpdateArrange();
);

resetsnapoffset();
Code:
// Reset item source offset

function resetsourceoffset() local (i)
(
i = 0;
loop(CountSelectedMediaItems(0),
(curr_item = GetSelectedMediaItem(0, i)) ? (
(curr_take = GetActiveTake(curr_item)) ? (
SetMediaItemTakeInfo_Value(curr_take, "D_STARTOFFS", 0);
);
);
i += 1;
);
UpdateArrange();
);

resetsourceoffset();
witti is offline   Reply With Quote
Old 04-23-2014, 05:04 PM   #506
mehmethan
Human being with feelings
 
mehmethan's Avatar
 
Join Date: Jun 2011
Posts: 610
Default

Hi, is this possible with reascript ?

"Paste items to the same relative position to the bar gridlines." My recorded midi or audio items generally starts slightly before or after bar gridlines. When i try to copy & paste them to another bar, they paste from the edit cursor position so they lose their original relative position.(Snap is on) Is it possible to change this behavior and make a new paste function that take care of relative position of items ?
mehmethan is offline   Reply With Quote
Old 04-24-2014, 06:51 AM   #507
witti
Human being with feelings
 
witti's Avatar
 
Join Date: May 2012
Posts: 1,216
Default

Try the action 'copy selected area'.
Draw a time selection around the selected items first. If the time selection starts at measure or beat everything will be pasted with preserved positions.




Can someone help me with this script, please? I'm too stupid. (See my previous post...)

It should add a suffix (/) to a track name when there is none,
and should remove it, when there is one.

The blue part is not working, and i don't know why...
(I can imagine what's wrong, but cannot solve it...)

Code:
function add_remove_suffix()

(
i = 0;
#src_str = "/";
str_len = strlen(#src_str);

loop(CountSelectedTracks(0),
	(track = GetSelectedTrack(0, i)) ? (
		GetSetMediaTrackInfo_String(track, "P_NAME", #track_name, 0); // get track name
			match(#track_name, "*/") ? (
			str_delsub(#track_name, 0, str_len); // deletes len chars at pos
			) : (
			strcat(#track_name, "/"); //inserts srcstr at pos
			);
		GetSetMediaTrackInfo_String(track, "P_NAME", #track_name, 1); // set track name
	);
i += 1;
);
);

add_remove_suffix();
witti is offline   Reply With Quote
Old 04-24-2014, 07:24 AM   #508
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by witti View Post
Try the action 'copy selected area'.
Draw a time selection around the selected items first. If the time selection starts at measure or beat everything will be pasted with preserved positions.




Can someone help me with this script, please? I'm too stupid. (See my previous post...)

It should add a suffix (/) to a track name when there is none,
and should remove it, when there is one.

The blue part is not working, and i don't know why...
(I can imagine what's wrong, but cannot solve it...)
This might be close:

Code:
function add_remove_suffix()

(
i = 0;
#src_str = "/";
str_len = strlen(#src_str);

loop(CountSelectedTracks(0),
  (track = GetSelectedTrack(0, i)) ? (
    GetSetMediaTrackInfo_String(track, "P_NAME", #track_name, 0); // get track name
      match("*/", #track_name) ? (
      track_name_len = strlen(#track_name); 
      str_delsub(#track_name, track_name_len - str_len, str_len); // Deletes len characters at offset pos from #str, and returns #str.
      ) : (
      strcat(#track_name, "/"); //inserts srcstr at pos
      );
    GetSetMediaTrackInfo_String(track, "P_NAME", #track_name, 1); // set track name
  );
i += 1;
);
);

add_remove_suffix();
spk77 is offline   Reply With Quote
Old 04-24-2014, 07:50 AM   #509
witti
Human being with feelings
 
witti's Avatar
 
Join Date: May 2012
Posts: 1,216
Default

Muchas muchas gracias ! You saved my day !

Now the macro in one of my previous posts is much more elegant with this script.

Thanks again ! This eel stuff is really great.
witti is offline   Reply With Quote
Old 04-24-2014, 07:54 AM   #510
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by witti View Post
Muchas muchas gracias ! You saved my day !

Now the macro in one of my previous posts is much more elegant with this script.

Thanks again ! This eel stuff is really great.
I'm glad it worked
spk77 is offline   Reply With Quote
Old 04-24-2014, 08:02 AM   #511
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by mehmethan View Post
Hi, is this possible with reascript ?

"Paste items to the same relative position to the bar gridlines." My recorded midi or audio items generally starts slightly before or after bar gridlines. When i try to copy & paste them to another bar, they paste from the edit cursor position so they lose their original relative position.(Snap is on) Is it possible to change this behavior and make a new paste function that take care of relative position of items ?
Maybe this would work: "Snap/Grid settings -> Set "snap relative to grid" -> ctrl + drag to copy-paste items.

spk77 is offline   Reply With Quote
Old 04-24-2014, 12:50 PM   #512
mehmethan
Human being with feelings
 
mehmethan's Avatar
 
Join Date: Jun 2011
Posts: 610
Default

Quote:
Originally Posted by spk77 View Post
Maybe this would work: "Snap/Grid settings -> Set "snap relative to grid" -> ctrl + drag to copy-paste items.

This is the way I do now. (drag copy with snap relative to grid) I'm asking if this possible with ctrl+c & ctrl+v
mehmethan is offline   Reply With Quote
Old 04-24-2014, 12:58 PM   #513
mehmethan
Human being with feelings
 
mehmethan's Avatar
 
Join Date: Jun 2011
Posts: 610
Default

Quote:
Originally Posted by witti View Post
Try the action 'copy selected area'.
Draw a time selection around the selected items first. If the time selection starts at measure or beat everything will be pasted with preserved positions.
[/code]
Yes this works but this action only pastes selected area. Relative position is preserved but length of item changed. So you have to grow or shorten item edges manually. This is another pain for me. But thank you
mehmethan is offline   Reply With Quote
Old 04-24-2014, 09:16 PM   #514
witti
Human being with feelings
 
witti's Avatar
 
Join Date: May 2012
Posts: 1,216
Default

Quote:
Originally Posted by mehmethan View Post
Yes this works but this action only pastes selected area. Relative position is preserved but length of item changed. So you have to grow or shorten item edges manually. This is another pain for me. But thank you
Draw the time selection bigger than the actual size of the selected items.
witti is offline   Reply With Quote
Old 04-26-2014, 12:48 AM   #515
mehmethan
Human being with feelings
 
mehmethan's Avatar
 
Join Date: Jun 2011
Posts: 610
Default

Quote:
Originally Posted by witti View Post
Draw the time selection bigger than the actual size of the selected items.
Yes I know this method works when there is no other item close to the one you want to copy. Because it copies everthing inside selection. But drag copy method is better for me. I'm just asking a ctrl c & ctrl v to do it.
mehmethan is offline   Reply With Quote
Old 04-26-2014, 03:14 AM   #516
mehmethan
Human being with feelings
 
mehmethan's Avatar
 
Join Date: Jun 2011
Posts: 610
Default

- set snap offset to nearest grid line
- copy items/tracks......

This is my copy macro for relative positon copy paste. This works with big grid divisions. When I work with small divisions you may miss the right place for pasting.

But I thought reascript gurus may find a better way. Thanks
mehmethan is offline   Reply With Quote
Old 04-26-2014, 03:58 AM   #517
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by mehmethan View Post
- set snap offset to nearest grid line
- copy items/tracks......

This is my copy macro for relative positon copy paste. This works with big grid divisions. When I work with small divisions you may miss the right place for pasting.

But I thought reascript gurus may find a better way. Thanks
This might work (I'll try to make these two scripts):
  • First script copies selected items and stores the offset (offset = (first) item position from the start of a measure)
  • Second script pastes the items at the start of a measure + moves each item by the offset. (Measure in the second script would be the current edit cursor position)
spk77 is offline   Reply With Quote
Old 04-26-2014, 09:25 AM   #518
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by mehmethan View Post
Hi, is this possible with reascript ?

"Paste items to the same relative position to the bar gridlines." My recorded midi or audio items generally starts slightly before or after bar gridlines. When i try to copy & paste them to another bar, they paste from the edit cursor position so they lose their original relative position.(Snap is on) Is it possible to change this behavior and make a new paste function that take care of relative position of items ?
Quote:
Originally Posted by spk77 View Post
This might work (I'll try to make these two scripts):
  • First script copies selected items and stores the offset (offset = (first) item position from the start of a measure)
  • Second script pastes the items at the start of a measure + moves each item by the offset. (Measure in the second script would be the current edit cursor position)

Copy items and store positions.eel:

Code:
function store_pos(pos)
(
  pos = sprintf(#, "%.20f", pos);
  //ShowConsoleMsg(pos);
  SetExtState("copy_paste", "relative_pos", pos, 0);
);

// Get (first) item start position from start of measure (in seconds)
function get_item_pos_in_measure() local(item, pos, time_to_beats, beats_to_time, pos_in_measure)
(
  (item = GetSelectedMediaItem(0, 0)) ? (
    pos = GetMediaItemInfo_Value(item, "D_POSITION");
    //TimeMap2_timeToBeats(ReaProject* proj, tpos, optional int &measuresOutOptional, optional int &cmlOutOptional, optional &fullbeatsOutOptional, optional int &cdenomOutOptional)
    time_to_beats = TimeMap2_timeToBeats(0, pos, measuresOut, cmlOutOptional, fullbeatsOutOptional, cdenomOutOptional);
    beats_to_time = TimeMap2_beatsToTime(0, 0, measuresOut);
    pos_in_measure = pos - beats_to_time; // first item start position from start of measure (in seconds)
    
    //ShowConsoleMsg(sprintf(#, "%f", pos_in_measure));
    //ShowConsoleMsg("s from start of measure ");
    //ShowConsoleMsg(sprintf(#, "%d", measuresOut));
    //ShowConsoleMsg("\n"); 

    store_pos(pos_in_measure);
  );
);

get_item_pos_in_measure();
Main_OnCommand(40698, 0); // copy items
Paste items and recall positions.eel: (pastes to the measure under the edit cursor)

Code:
// Get (first) item start position from start of measure (in seconds)
function get_item_pos_in_measure() local(item, pos, time_to_beats, beats_to_time, pos_in_measure)
(
  (item = GetSelectedMediaItem(0, 0)) ? (
    pos = GetMediaItemInfo_Value(item, "D_POSITION");
    //TimeMap2_timeToBeats(ReaProject* proj, tpos, optional int &measuresOutOptional, optional int &cmlOutOptional, optional &fullbeatsOutOptional, optional int &cdenomOutOptional)
    time_to_beats = TimeMap2_timeToBeats(0, pos, measuresOut, cmlOutOptional, fullbeatsOutOptional, cdenomOutOptional);
    beats_to_time = TimeMap2_beatsToTime(0, 0, measuresOut);
    pos_in_measure = pos - beats_to_time; // first item start position from start of measure (in seconds)
  );
);

function relative_paste() local(i, item, pos)
(
  Main_OnCommand(40058, 0); // paste items
  i = 0;
  HasExtState("copy_paste", "relative_pos") ? (
    GetExtState(#rel_pos, "copy_paste", "relative_pos");
    match("%f", #rel_pos, rel_pos);
    //ShowConsoleMsg(sprintf(#, "%.20f", rel_pos));
    pos_in_measure = get_item_pos_in_measure();
    loop(CountSelectedMediaItems(0),
      item = GetSelectedMediaItem(0, i);
      pos = GetMediaItemInfo_Value(item, "D_POSITION");
      SetMediaItemInfo_Value(item, "D_POSITION", pos - pos_in_measure + rel_pos);
      i += 1;
    );
  );
);

PreventUIRefresh(1);
relative_paste();
PreventUIRefresh(-1);

Last edited by spk77; 04-28-2014 at 02:49 AM.
spk77 is offline   Reply With Quote
Old 04-26-2014, 09:41 AM   #519
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

OOO SKP! Is that an example of how to store variables for other scripts? I really have been needing a script to store selected media item names, then apply stored media item names to other items.

can I do that with set/get ext state?

What about for GetUserInputs? Can I store last inputted values and recall them?
__________________
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 04-26-2014, 09:50 AM   #520
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Argitoth View Post
OOO SKP! Is that an example of how to store variables for other scripts? I really have been needing a script to store selected media item names, then apply stored media item names to other items.

can I do that with set/get ext state?

What about for GetUserInputs? Can I store last inputted values and recall them?
Yes, you can store string variables with SetExtState (you have to convert int/float to string first)
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 10:30 AM.


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