|
|
|
02-14-2020, 06:16 PM
|
#1
|
Human being with feelings
Join Date: Jun 2008
Posts: 67
|
Labeling Peaks
I'm creating a sample pool from organic drum performances I originally did without sampling in mind. The hits vary greatly in dynamics based on the piece and I would like to label them based on the dynamics without having to go through and sort hundreds (possibly thousands) of them manually.
My current workflow is to use dynamic split then Batch File/Item Converter>Add Selected Media Items but the great list of wildcards doesn't include one for peak/RMS or anything similar.
Does anybody have any tips?
|
|
|
02-14-2020, 11:55 PM
|
#2
|
Human being with feelings
Join Date: Jan 2017
Location: Los Angeles
Posts: 1,161
|
You could have a script that reads either peak, RMS, or loudness per item and changes the item name to that value. Would that be helpful?
|
|
|
02-15-2020, 01:14 AM
|
#3
|
Human being with feelings
Join Date: Jun 2008
Posts: 67
|
Yes, that would be perfect. How could that be accomplished?
|
|
|
02-15-2020, 06:13 PM
|
#4
|
Human being with feelings
Join Date: Jan 2017
Location: Los Angeles
Posts: 1,161
|
I'll take any chance I get to practice coding. See if this works for you.
It measures peak RMS (300 ms window) for each item and changes the item name to match.
You'll need to download SWS/S&M if you don't have it.
Lua Script:
Code:
--description: Set Item Names to Peak RMS Value
num_items = reaper.CountMediaItems(0)
window_size = 0.3 -- RMS Window Size (seconds)
for i=1,num_items do
item = reaper.GetMediaItem(0,i-1)
take = reaper.GetTake(item,0)
length = reaper.GetMediaItemInfo_Value(item,"D_LENGTH") -- Store Original Item Length
if length < 2*window_size then
length_mult = math.ceil(2*window_size/length)
new_length = length*length_mult
reaper.SetMediaItemLength(item,new_length,0) -- Increase Item Length for Proper Analysis
end
-- Initialize Arrays
array = reaper.new_array(1)
RMSs = reaper.new_array(1)
array.resize(0)
RMSs.resize(0)
-- Analyze Item Peak RMS
_ = reaper.NF_AnalyzeMediaItemPeakAndRMS(item,window_size,array,array,RMSs,array)
peak_RMS = RMSs[1]
peak_RMS_string = string.format("%.9f", peak_RMS) -- Change "%.#f" to set Decimal Precision
reaper.SetMediaItemLength(item,length,0) -- Restore Original Item Length
_,_ = reaper.GetSetMediaItemTakeInfo_String(take,"P_NAME",peak_RMS_string .. " dB RMS",1)
end
function exit()
reaper.SetMediaItemLength(item,length,0)
end
reaper.atexit(exit)
Code:
--description: Set Item Names to Peak Value
num_items = reaper.CountMediaItems(0)
for i=1,num_items do
item = reaper.GetMediaItem(0,i-1)
take = reaper.GetTake(item,0)
peak = reaper.NF_GetMediaItemMaxPeak(item)
peak_string = string.format("%.9f", peak) -- Change "%.#f" to set Decimal Precision
_,_ = reaper.GetSetMediaItemTakeInfo_String(take,"P_NAME",peak_string .. " dB Peak",1)
end
Last edited by ErBird; 02-15-2020 at 09:36 PM.
Reason: Added peak script
|
|
|
02-15-2020, 06:18 PM
|
#5
|
Human being with feelings
Join Date: Jun 2008
Posts: 67
|
Thank you so much! I’ll try that right away once I figure out where to paste code.
|
|
|
02-15-2020, 06:21 PM
|
#6
|
Human being with feelings
Join Date: Jan 2017
Location: Los Angeles
Posts: 1,161
|
Quote:
Originally Posted by Per Lichtman
Thank you so much! I’ll try that right away once I figure out where to paste code.
|
NP. I just made a small change, so re-copy.
Also, Actions -> Show Action list -> ReaScript: New
Make sure it's .lua.
If RMS turns out unreliable at predicting dynamics, it could be changed to use peak level.
Last edited by ErBird; 02-15-2020 at 06:26 PM.
|
|
|
02-15-2020, 06:25 PM
|
#7
|
Human being with feelings
Join Date: Jun 2008
Posts: 67
|
Okay, re-copied and I’ve got SWS/S&M 2.1.0 #1 running in Reaper 5.99.
I’m about to try “ReaScript; Edit new reaScript (EEL or lua)...” and then the “run” version thereof.
-Crossing my fingers.-
*EDIT: Just saw the actions directions. Will follow those instead.*
|
|
|
02-15-2020, 06:35 PM
|
#8
|
Human being with feelings
Join Date: Jun 2008
Posts: 67
|
I just tried on a few sample groups and it worked really well some of the percussion with a long decay (thank you so much!) but it not as well for particularly short hits.
Would it be possible to try the peak method you mentioned?
|
|
|
02-15-2020, 06:53 PM
|
#9
|
Human being with feelings
Join Date: Jan 2017
Location: Los Angeles
Posts: 1,161
|
Quote:
Originally Posted by Per Lichtman
Would it be possible to try the peak method you mentioned?
|
Sure. Will post a little later.
|
|
|
02-15-2020, 08:37 PM
|
#10
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
There's also the SWS Label processor which can name takes according to peak levels (run action 'SWS/IX: Label processor' to bring it up).
|
|
|
02-15-2020, 08:48 PM
|
#11
|
Human being with feelings
Join Date: Jun 2008
Posts: 67
|
Thanks - I'll try that, too. Much appreciated.
|
|
|
02-15-2020, 09:23 PM
|
#12
|
Human being with feelings
Join Date: Jan 2017
Location: Los Angeles
Posts: 1,161
|
Quote:
Originally Posted by nofish
There's also the SWS Label processor which can name takes according to peak levels (run action 'SWS/IX: Label processor' to bring it up).
|
Hi nofish,
What would you do with files shorter than the RMS window? In the script, I set short items to 4x the RMS window before analysis (2x should do), but now I'm thinking I'll change that to be a whole number multiple of the original length.
Edit: It seems changing the length does nothing unless you glue first. Need to look into this further. Label Processor may be the better option atm.
Last edited by ErBird; 02-15-2020 at 09:45 PM.
|
|
|
02-16-2020, 09:59 AM
|
#13
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
For drum hits I'd maybe try something shorter than 300 ms window size.
Here I've dragged some random snare/bassdrum hits in, time selection is 300 ms.
Maybe something around 100 ms to catch the 'body' of the hits?
I haven't done detailed experiments with this either though.
Btw., speaking of the label processor:
For the /R argument (peak RMS) the window size can be set via action: 'SWS: Set RMS analysis/normalize options', so that can also be experimented with without need for scripting.
Last edited by nofish; 02-16-2020 at 10:17 AM.
|
|
|
02-17-2020, 07:54 PM
|
#14
|
Human being with feelings
Join Date: Jan 2017
Location: Los Angeles
Posts: 1,161
|
Thank you. That makes more sense. I for some reason thought the difference in lengths would figure into the RMS calc as a section with zero amplitude.
Shorter window it is.
|
|
|
02-17-2020, 09:57 PM
|
#15
|
Mortal
Join Date: Jan 2006
Location: Wickenburg, Arizona
Posts: 14,047
|
ErBird, you are one seriously awesome person
(bro did you just assume my species?)
|
|
|
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 03:38 AM.
|