11-14-2012, 02:44 PM | #41 |
Human being with feelings
Join Date: Jun 2009
Location: Earth
Posts: 1,340
|
gwok,
Hmmm, not sure what the error is, the only thing I can think of is maybe when you copied and pasted it the formating got messed up, maybe a line break was inserted or something. Anyway I've uploaded the actual .py file to the stash..., here. https://stash.reaper.fm/14551/Copy2new.py Let me know if you still get any errors. |
11-14-2012, 03:10 PM | #42 |
Human being with feelings
Join Date: Jun 2010
Location: canada
Posts: 3,402
|
I though the same thing, though I;m getting a different error with the stash version -
[IMG]http://img19.**************/img19/3185/screenshot20121114at309.png[/IMG] Uploaded with ************** |
11-14-2012, 10:47 PM | #43 |
Human being with feelings
Join Date: Jun 2009
Location: Earth
Posts: 1,340
|
Ok.., I just thought of one thing it might be. Which version of the SWS extension are you using? This line (from sws_python import *) calls to this file (sws_python.py) which on Windows resides in the (\REAPER\Plugins) directory, on the Mac I'm not sure but the installer should put it where it needs to be. So what I would do is get the latest Beta(sws_2.3.0.8) of the SWS extension. Install and try to run the script again. Let me know how it goes.
|
11-15-2012, 12:25 AM | #44 |
Human being with feelings
Join Date: Jun 2010
Location: canada
Posts: 3,402
|
no dice, newest sws installed. I'm starting to wonder if there are some OS conflicts maybe happening here, as some scripts work for me and others don't.
Too bad, I really want to use that tempo\time sig action. Maybe something will come to light..... cheers |
11-15-2012, 12:53 AM | #45 |
Human being with feelings
Join Date: Jun 2009
Location: Earth
Posts: 1,340
|
gwok,
Maybe try "from sws_python import" instead of "from sws_python import * " or if that does'nt work try it without the "from" just "sws_python import" |
11-15-2012, 01:28 AM | #46 |
Mortal
Join Date: Dec 2008
Location: France
Posts: 1,969
|
gwok, (due to a little "deployment" annoyance on OSX) make sure the script resides in ~/Library/Application Support/REAPER/Scripts, i.e. where sws_python resides. When installing the sws extension, also use the new "double-click" thingy: it installs a few required files for reascript function export (contrary to a simple/portable drag-drop the .dylib file..)
|
11-15-2012, 01:37 AM | #47 |
Human being with feelings
Join Date: Jun 2009
Location: Earth
Posts: 1,340
|
Ahhh..., Jeffos appears and saves the day
Thank you!!! |
11-15-2012, 03:21 PM | #48 |
Human being with feelings
Join Date: Jun 2010
Location: canada
Posts: 3,402
|
thanks guys,
Ok i did the dbl click install of sws, and the scripts folder now has sws_python.py(32\64bit) files. Though I'm still getting the same error as the above post Anton with the script from the stash - |
11-15-2012, 03:31 PM | #49 |
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
Just to let you know Anton - seems to work fine here in 10.6.8 with Py 3.2 (reaper 32-bit).
What version of Python are you using Gwok? |
11-15-2012, 03:40 PM | #50 |
Human being with feelings
Join Date: Jun 2010
Location: canada
Posts: 3,402
|
I'm running 3.3 on OSX 10.6.8, will check out 3.2
|
11-24-2012, 07:21 AM | #51 |
Human being with feelings
Join Date: Apr 2011
Posts: 158
|
sorry, just ignore
Last edited by john doe; 11-27-2012 at 07:20 AM. Reason: double post |
12-16-2012, 01:20 PM | #52 |
Human being with feelings
Join Date: Dec 2012
Posts: 7,566
|
Sorry, this didn't belong here...
Last edited by ashcat_lt; 12-16-2012 at 01:26 PM. |
03-06-2013, 02:59 PM | #53 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
Are scripters still taking request?
I would love to have a scrip that tells REAPER to set fade time to all selected media item to a percentage of their length, individually, sooo, maybe a popup window that asks for a percentage. This is useful for creating sample libraries, for example with a piano, you have low notes that have a long decay and high notes which have a short decay. After cutting up the recording, I could then set a length based on a percentage rather than a fixed seconds value. |
03-06-2013, 04:36 PM | #54 |
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
Code:
# ------------------------------------- # Set fade in and/or out length of all # selected media items to the given # percentage of their length # # (Un)comment lines 25/27 as required # # Currently there's no intelligence # to modify behaviour if both fade # in and out are given a % > 50 ... # ------------------------------------- from reaper_python import * usr_input = RPR_GetUserInputs("Set fade length of item(s)", 1, "Percent", "", 1024) if usr_input[0]: RPR_Undo_BeginBlock2(0) for i in range(0, RPR_CountSelectedMediaItems(0)): item = RPR_GetSelectedMediaItem(0, i) length = RPR_GetMediaItemInfo_Value(item, "D_LENGTH") fade_len = length * (float(usr_input[4]) / 100.0) # set fade in # RPR_SetMediaItemInfo_Value(item, "D_FADEINLEN", fade_len) # set fade out RPR_SetMediaItemInfo_Value(item, "D_FADEOUTLEN", fade_len) RPR_Undo_EndBlock2(0, "Set item fade to percentage of length", -1) RPR_UpdateArrange() Last edited by timlloyd; 03-06-2013 at 04:49 PM. |
03-06-2013, 05:11 PM | #55 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
wow! f*** that was fast. thank you!
|
03-06-2013, 11:42 PM | #56 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
Oh man, well I have another request:
user input X seconds --> "Shorten selected media items to X seconds, but only if media item length is greater than X seconds." Basically, I am trying to define a maximum length for a number of media items. Preferrably, the input format should be 1.000 (which would be 1000ms) |
03-07-2013, 12:15 AM | #57 |
Human being with feelings
Join Date: Mar 2010
Posts: 4,713
|
I haven't tested this, but it should work ...
Code:
# ----------------------------------------------- # Shorten selected media items to X seconds, # if media item length is greater than X seconds. # ----------------------------------------------- from reaper_python import * usr_input = RPR_GetUserInputs("Shorten item(s) if longer than x", 1, "x (seconds)", "", 1024) if usr_input[0]: RPR_Undo_BeginBlock2(0) for i in range(0, RPR_CountSelectedMediaItems(0)): item = RPR_GetSelectedMediaItem(0, i) length = RPR_GetMediaItemInfo_Value(item, "D_LENGTH") trim_len = float(usr_input[4]) if length > trim_len: RPR_SetMediaItemInfo_Value(item, "D_LENGTH", trim_len) RPR_Undo_EndBlock2(0, "Shorten item(s) if longer than x", -1) RPR_UpdateArrange() |
03-07-2013, 12:18 AM | #58 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
*throw arms in the air* alright, I give up!
You are too kind. Thank you! |
03-12-2013, 03:48 PM | #59 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
Alright, I tried out both scripts, very satisfactory!
|
03-28-2013, 02:31 PM | #60 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
Maybe this is a difficult or impossible script. If it is, just let me know if you think it's at least in the realm of possibility. I need a script that does something at the media item's highest peak, so it has to analyze the item to find it.
* Set snap offset of media item(s) to its peak And this: * (only useful to me in combination with the above script) Set left edge of media item(s) to its snap offset Thank you! Last edited by Argitoth; 03-28-2013 at 02:43 PM. |
04-04-2013, 04:41 PM | #61 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
If anyone could get back to me about the post above, I could offer payment.
|
04-04-2013, 08:06 PM | #62 |
Human being with feelings
Join Date: Mar 2013
Posts: 28
|
For the first one, try creating the following custom action (you'll have to install the SWS extension if you don't have it already):
+SWS: Move cursor to item peak in sample +Item: Set snap offset to cursor Does that work as you want it to on one item? If it does, then putting it into a script to handle multiple selected items and restore the cursor position at the end would be very easy. For the second one, do you want to just move the media item to where the snap offset was? So if you use the SWS action above to set the edit cursor to peak and then set the snap offset to the cursor, is your second request to move the media item so the left end is at the edit cursor and then cut off the right end of the media item to preserve its previous end point? Or do you just want to shorten the media item from the left end up to the cursor (in which case why set the snap-offset initially at all? you could just skip setting snap offset and immediately cut the item from the left up to the cursor point). Just slightly confused by what you mean when you say "Set the left edge of media item to snap offset" If you select the action: +Item edit: Move left edge of item to edit cursor Is that similar to the behavior you're looking for? If it is, then this can easily be built into the script as well (or do you want it separate?) Last edited by Astonisher; 04-04-2013 at 08:26 PM. |
04-04-2013, 10:03 PM | #63 | |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
Quote:
Ok, I know where the confusion is. See, when I said "move" I actually meant "trim". Sooo Script 1: Set snap offset of media item to its highest peak (all selected items) -Now I can adjust snap offsets where needed, I can "preview" the trim. Script 2: Trim left edge of media item to its snap offset (all selected items) -Now I commit to my trim. It's a "set length of time before highest peak" function, but split up in a few steps. Edit: I'm going to add a 3rd step Script 3: Expand left edge of media item by X seconds (input format should be 1 = 1 second, .001 = 1ms) -Now I don't have to arbitrarily move the left edge of selected items, I can input a specific amount of time. Last edited by Argitoth; 04-04-2013 at 10:22 PM. |
|
04-05-2013, 09:41 AM | #64 | |
Human being with feelings
Join Date: Mar 2013
Posts: 28
|
Quote:
SCRIPT # 1: Code:
# ----------------------------------------------- # Set snap offset to highest peak in media item # ----------------------------------------------- from reaper_python import * RPR_PreventUIRefresh(1) RPR_Undo_BeginBlock2(0) try : num_selected = RPR_CountSelectedMediaItems(0) orig_selection = [] # Save original item selection and cursor position for i in range(num_selected): itm = RPR_GetSelectedMediaItem(0, i) orig_selection.append(itm) orig_cursor = RPR_GetCursorPosition() # Item: Unselect all items RPR_Main_OnCommand(40289, 0) # Process each item for itm in orig_selection: # Select item RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 1) # SWS: Move cursor to item peak sample RPR_Main_OnCommand(RPR_NamedCommandLookup('_SWS_FINDITEMPEAK'), 0) # Item: Set snap offset to cursor RPR_Main_OnCommand(40541, 0) # Unselect item RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 0) # Restore state for itm in orig_selection: RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 1) RPR_SetEditCurPos(orig_cursor, False, False) finally: RPR_PreventUIRefresh(-1) RPR_Undo_EndBlock2(0,"Set snap offset to highest peak for selected items",-1) RPR_UpdateTimeline() SCRIPT #2: Code:
# ----------------------------------------------- # Trim edge to snap offset for selected items # ----------------------------------------------- from reaper_python import * RPR_PreventUIRefresh(1) RPR_Undo_BeginBlock2(0) try : num_selected = RPR_CountSelectedMediaItems(0) orig_selection = [] # Save original item selection and cursor position for i in range(num_selected): itm = RPR_GetSelectedMediaItem(0, i) orig_selection.append(itm) orig_cursor = RPR_GetCursorPosition() # Item: Unselect all items RPR_Main_OnCommand(40289, 0) # Process each item for itm in orig_selection: # Select item RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 1) # Put cursor at snap offset pos = RPR_GetMediaItemInfo_Value(itm, "D_POSITION") offset = RPR_GetMediaItemInfo_Value(itm, "D_SNAPOFFSET") RPR_SetEditCurPos(pos+offset, False, False) # Item edit: Trim left edge of item to edit cursor RPR_Main_OnCommand(41305, 0) # Unselect item RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 0) # Restore state for itm in orig_selection: RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 1) RPR_SetEditCurPos(orig_cursor, False, False) finally: RPR_PreventUIRefresh(-1) RPR_Undo_EndBlock2(0,"Trim edge to snap offset for selected items",-1) RPR_UpdateTimeline() Unfortunately had to do it with selecting items individually and moving the edit cursor around, so it's not completely elegant, but it works as expected. Regarding SCRIPT #3, how do you want the snap offset to be treated in that case? (preserve where it was at in time before the added length or have it move with the left edge?) |
|
04-05-2013, 11:57 AM | #65 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
Ah yes! Thank you. For the "expand left edge" should not affect snap offset.
|
04-06-2013, 12:45 AM | #66 | |
Human being with feelings
Join Date: Mar 2013
Posts: 28
|
Quote:
SCRIPT #3 Code:
# ------------------------------------------------------- # Expand left edge of selected media items by X seconds # ------------------------------------------------------- from reaper_python import * RPR_PreventUIRefresh(1) RPR_Undo_BeginBlock2(0) try : inpt = RPR_GetUserInputs("Expand left edge of items", 1, "x (seconds): ", "", 10) if inpt[0]: try: x_sec = float(inpt[4]) except: RPR_ShowMessageBox("Invalid input!", "Error", 0) raise num_selected = RPR_CountSelectedMediaItems(0) orig_selection = [] # Save original item selection and cursor position for i in range(num_selected): itm = RPR_GetSelectedMediaItem(0, i) orig_selection.append(itm) orig_cursor = RPR_GetCursorPosition() # Item: Unselect all items RPR_Main_OnCommand(40289, 0) # Process each item for itm in orig_selection: # Select item RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 1) # Put cursor X seconds to left of media item pos = RPR_GetMediaItemInfo_Value(itm, "D_POSITION") RPR_SetEditCurPos(pos-x_sec, False, False) # Item: Trim left edge of item to edit cursor RPR_Main_OnCommand(41305, 0) # Unselect item RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 0) # Restore state for itm in orig_selection: RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 1) RPR_SetEditCurPos(orig_cursor, False, False) finally: RPR_PreventUIRefresh(-1) RPR_Undo_EndBlock2(0,"Expand left edge of items by X second(s)",-1) RPR_UpdateTimeline() |
|
04-06-2013, 05:07 PM | #67 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
In the peak script you are using RPR_Main_OnCommand(RPR_NamedCommandLookup('_SWS_FI NDITEMPEAK'), 0)
using sws extension to do a find peak command. Does sws have a "find first point above X db?" So, it could potentially place the snap offset point where the media item first reaches a certain db. |
04-07-2013, 01:32 PM | #68 | |
Human being with feelings
Join Date: Mar 2013
Posts: 28
|
Quote:
Not sure if this is what you're looking for, but it's the closest solution I was able to find: Code:
# --------------------------------------------------- # Set snap offset to threshold dB for selected items # --------------------------------------------------- from reaper_python import * RPR_PreventUIRefresh(1) RPR_Undo_BeginBlock2(0) try : num_selected = RPR_CountSelectedMediaItems(0) orig_selection = [] # Save original item selection and cursor position for i in range(num_selected): itm = RPR_GetSelectedMediaItem(0, i) orig_selection.append(itm) orig_cursor = RPR_GetCursorPosition() # Transient detection sensitivity/threshold: adjust... (toggle dialog) RPR_Main_OnCommand(41208, 0) RPR_ShowMessageBox("Adjust transient detection settings.\nClick OK when done.", "Set snap offset to threshold dB", 0) RPR_Main_OnCommand(41208, 0) # Item: Unselect all items RPR_Main_OnCommand(40289, 0) # Process each item for itm in orig_selection: # Select item RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 1) # Move cursor to left edge of item RPR_SetEditCurPos(RPR_GetMediaItemInfo_Value(itm, "B_POSITION"), False, False) # Item navigaton: Move cursor to next transient in items RPR_Main_OnCommand(40375, 0) # Item: Set snap offset to cursor RPR_Main_OnCommand(40541, 0) # Unselect item RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 0) # Restore state for itm in orig_selection: RPR_SetMediaItemInfo_Value(itm, "B_UISEL", 1) RPR_SetEditCurPos(orig_cursor, False, False) finally: RPR_PreventUIRefresh(-1) RPR_Undo_EndBlock2(0,"Set snap offset to threshold dB for selected items",-1) RPR_UpdateTimeline() (NOTE1: You may have to set "Sensitivity" to 100%) (NOTE2: Just realized that on Mac OS, the second dialog box with the "Click OK" prompt prevents adjusting the sliders/settings in the Transient dialog. If this is an issue, then delete the three lines starting with 'RPR_Main_OnCommand(41208, 0)' and simply open the Transient dialog settings on your own before running the script.) If that's not quite it, then there IS a way to read the samples via ReaScript, but it will be very slow, especially on larger item sizes (or multiple items). Last edited by Astonisher; 04-07-2013 at 03:54 PM. |
|
04-07-2013, 03:13 PM | #69 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
I just tried it out, omg, that just might do it! I have to verify with a friend of mine. Basically, I'm trying to turn REAPER into the perfect tool for cutting samples for use in a sample library and it's almost perfect. You can almost export entire recordings as discreet samples with a handful of buttons, auto-named, cut, organized into folders, etc.
SWS's "sort by peak" saved my life, for example. |
04-07-2013, 07:14 PM | #70 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
I experimented with ReaFIR Gate mode to get rid of most of the noise before using the transient detector. The transient detector then is smart enough to skip other noises. So it works! Your latest script is extremely helpful, using only the first slice/transient. That's genius!
|
04-08-2013, 04:09 PM | #71 | |
Human being with feelings
Join Date: Mar 2013
Posts: 28
|
Quote:
Not sure if you've tried playing around with the "Sensitivity" setting, but I seem to recall setting it to 100% made it detect the first dB threshold correctly (you can hit a checkbox to visually see a line where the threshold is on the waveform). Setting sensitivity low seemed to make the behavior less accurate (at least for the purpose of finding the very first time a threshold dB was exceeded). |
|
04-08-2013, 04:11 PM | #72 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
In my experience, it will detect that and 10 more "transients" that are nothing more than oscillations, in other words it makes a lot of bad slices.
|
04-10-2013, 08:46 PM | #73 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
Alright, I'm running into a new dilemma. The only way to ensure that the phase alignment is proper is to put each item in its own track, stacked on top of one another. I use Xenakios "reposition item's start to 0s" to make them be in the same exact place in the project and then "explode items to tracks".
Awesome Ok! Oh wait... problem: there's no way to gaurantee that the media items stay in order, therefore exporting/naming samples will be impossible. The solution is: #1: Cut/Name/Export samples BEFORE I start phase aligning (I really wish I wouldn't have to do this) #2: A script or SOME TOOL that will allow me to rename items based on a txt list or somehow copy-paste in a list of names that correspond to the order that they appear in the project. #3: OH! Here's a really simple idea! I already know how to take a list and rename regions. What about something that will make the media item take on the name of the region it's in? I'm sure it'd be more difficult to program something that takes into account multiple tracks, so I could be sure to only have one track, one media item consecutively after the next, keep the project as simple as possible. If I could rename media items based on a list, REAPER would become twice as amazing as it already is. Last edited by Argitoth; 04-12-2013 at 02:03 PM. |
04-11-2013, 10:18 AM | #74 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
Came up with some new ideas on how to accomplish this.
#4: "Auto-rename selected takes" allows you to put in a numbering tag, so it applies 01 02 03 to the media items in order. That at least allows me to know where the media item originally sat. I could rename the items AFTER export, I guess that's ok, but not ideal! Does this give you ideas on how renaming media items could work? Last edited by Argitoth; 04-11-2013 at 01:15 PM. |
04-12-2013, 12:59 PM | #75 | |
Human being with feelings
Join Date: Mar 2013
Posts: 28
|
Quote:
So renaming media item takes is pretty trivial via ReaScript, and reading text files is also trivial via Python. BUT, the source file name would not be renamed. So it could rename the media item take in the project to whatever based on a text file. But the source filename (in your project directory) will remain the same. I think you should be able to use the Batch file processor to export the items based on item names though (File --> Batch file/item converter) if I'm understanding what you want to do correctly. |
|
04-12-2013, 01:48 PM | #76 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
I want to rename the items in the project. Yes! Not the actual media file. So for example:
I take a long recording and split it up in reaper 2000 times. So I have 2000 cuts, but they are all SHARING the same wav file. If I wanted to rename the ACTUAL files, I know a few ways of doing that outside reaper, that's not a problem. I just want to rename the media items inside the project even though they all share the same file. This would be so awesome! It would make my workflow amazing. |
04-13-2013, 03:54 PM | #77 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
Alright, so there's something else I need help with. Right now I am just using "auto-rename takes" and naming the media items 01 02 03 etc. I can keep them in order even after exploding them to tracks.
All I need now is a way to un-explode tracks, or get all items on the same track. At this point it doesn't need to be in order anymore, but it would be better to have it in order. |
04-14-2013, 12:22 PM | #78 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
I need an "explode to tracks (do not create new tracks unless needed)" the Xenakios version creates new tracks every time.
I also need "quantize item start to nearest gridline (ignore snap offset)" Another nice one would be "quantize item start to nearest marker" yet another would be "quantize item start to next grid line or marker" hmm, I need to learn some scripting. there's a whole lot of alternate versions of the above I could use. QUESTION: In your "peak detection" script, is it possible only allow detection of positive peaks OR negative peaks, but not both? |
04-14-2013, 12:40 PM | #79 | |
Human being with feelings
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
|
Quote:
The rest I think you can do with macros with existing actions. Basically, select an item, then the macro will move the edit cursor to grid line or marker, then move the selected item (or it's edge) to the edit cursor. those actions are all in the action list. I'm not sure if the snap offset is ignored or not in that type of action, however. how you set up the macros depends on your mouse behavior. Does left click move the edit cursor when you select an item? If yes, this is a bit easier. I can walk you through it, let me know. |
|
04-14-2013, 12:44 PM | #80 |
Human being with feelings
Join Date: Feb 2008
Posts: 2,057
|
|
Thread Tools | |
Display Modes | |
|
|