Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 03-01-2024, 10:08 AM   #1
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,024
Default Calculate Loudness of Selected Items

Maybe I am missing something but the action Calculate loudness of selected items via dry run render, 42468 seems to display a smaller area of the selected item than it should. Also the area is divergent than the action : Calculate loudness of selected items, including take and track FX and settings, via dry run render 42437
The values between these actions seems fine tho, just the display of 42468 seems cutted.



Also on that note the function CalculateNormalization seems to retrieve different values of the calculate loudness actions ? Or maybe I am using it wrong?

Code:
local proj, selitem = 0, 0
local item = reaper.GetSelectedMediaItem(proj, selitem)
local take = reaper.GetActiveTake(item)
local source = reaper.GetMediaItemTake_Source( take )
-- Item bounds
local offset = reaper.GetMediaItemTakeInfo_Value(take, 'D_STARTOFFS')
local len = reaper.GetMediaItemInfo_Value(item, 'D_LENGTH')
local rate = reaper.GetMediaItemTakeInfo_Value(take, 'D_PLAYRATE')
-- configs
local normalizeTarget = 0
local normalizeTo = 0 -- 0=LUFS-I, 1=RMS-I, 2=peak, 3=true peak, 4=LUFS-M max, 5=LUFS-S max 
local norm = reaper.CalculateNormalization( source, normalizeTo, normalizeTarget, offset, offset+(len*rate))
reaper.ShowConsoleMsg('Normalize value: '..norm..'\n')
daniellumertz is offline   Reply With Quote
Old 03-01-2024, 10:22 AM   #2
RJHollins
Human being with feelings
 
Join Date: Dec 2011
Posts: 2,176
Default

I too have been having some issues with the 'Dry Run' action.

I've not narrowed it down ... but the 'Time Selected' version does not focus on the time selection [Region].

Was in the middle of session at the time. Will look into this closer to give better feedback on the issue.
RJHollins is online now   Reply With Quote
Old 03-01-2024, 12:32 PM   #3
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,929
Default

Ah yes, the action 'Calculate loudness of selected items via dry run render' can display too little of the peaks in the render window, although the reported numbers should be correct. We'll fix this.

As for your second question, to normalize the media item from -35.8 to LU you would need to multiply each sample by 61.79, which is what the API function is reporting.
schwa is offline   Reply With Quote
Old 03-01-2024, 12:46 PM   #4
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,024
Default

Quote:
Originally Posted by schwa View Post
Ah yes, the action 'Calculate loudness of selected items via dry run render' can display too little of the peaks in the render window, although the reported numbers should be correct. We'll fix this.

As for your second question, to normalize the media item from -35.8 to LU you would need to multiply each sample by 61.79, which is what the API function is reporting.
Thanks for the quick reply schwa

Ahh so in order to use CalculateNormalization to get the source LUFS value I need to convert the value to dB with 20 * math.log(value,10) :

Code:
--- Return value in db. 0 = -inf, 1 = 0dB, 2 = +6dB, etc...
function LinearTodB(value)
    return 20 * math.log(value,10)    
end
----
reaper.ClearConsole()

local proj, selitem = 0, 0
local item = reaper.GetSelectedMediaItem(proj, selitem)
local take = reaper.GetActiveTake(item)
local source = reaper.GetMediaItemTake_Source( take )
-- Item bounds
local offset = reaper.GetMediaItemTakeInfo_Value(take, 'D_STARTOFFS')
local len = reaper.GetMediaItemInfo_Value(item, 'D_LENGTH')
local rate = reaper.GetMediaItemTakeInfo_Value(take, 'D_PLAYRATE')
-- configs
local normalizeTo = 0 -- 0=LUFS-I, 1=RMS-I, 2=peak, 3=true peak, 4=LUFS-M max, 5=LUFS-S max 
local normalizeTarget = 0
local norm = reaper.CalculateNormalization( source, normalizeTo, normalizeTarget, offset, offset+(len*rate))
reaper.ShowConsoleMsg('Normalize value: '..LinearTodB(norm)..'\n')
Seems to be working!
daniellumertz is offline   Reply With Quote
Old 03-01-2024, 01:19 PM   #5
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,929
Default

If you only want the loudness calculation, you could call CalcMediaSrcLoudness().
schwa 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 11:24 PM.


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