reaper-oss / sws

The SWS extension is a collection of features that seamlessly integrate into REAPER, the Digital Audio Workstation (DAW) software by Cockos, Inc
https://www.sws-extension.org/
MIT License
448 stars 85 forks source link

FR: Post Take/Item properties item loudness ReaScript Functions #957

Closed X-Raym closed 5 years ago

X-Raym commented 6 years ago

Hi,

the current Loudness ReaScript functions return loudness pre-fades and pre volume envelopes.

It would be nice if it could returns loudness after all take properties (fades, gain, volumes etc...)

As shown on the Loudness signal flow there: http://wiki.cockos.com/wiki/index.php/Measure_and_normalize_loudness_with_SWS

This was originally discussed on this issue: https://github.com/reaper-oss/sws/issues/953#issuecomment-370474451

Thanks for listening !

nofishonfriday commented 6 years ago

@X-Raym Hm, from a few tests it seems that even SWS/BR: Analyze loudness... doesn't properly take takes volume envelopes into account. Can you confirm ? (You can test by analyzing selected item, right-clicking an entry there -> Go to true peak, while having e.g. a curved / ramped take vol. env. active in the analyzed item. You need to have "Analyze true peak" enabled in the options.)

If yes, seems there may be a bug and nothing I can do about regarding this request. Which leads to next question...Breeder seems to use Envelope_Evaluate() for accounting for the envelops, have you ever used this and can confirm it's working correctly ?

X-Raym commented 6 years ago

@nofishonfriday Here is what I get from SWS/BR; Analyse Loudness... with two analyses of the same item (first with volume envelope at 0, then volume envelope -10dB).

1 - Epic Battle Dark.mp3: -17.0 LUFS, Range: 16.5 LU, True peak: -0.4 dBTP
1 - Epic Battle Dark.mp3: -26.8 LUFS, Range: 16.5 LU, True peak: -10.4 dBTP

As you can see, it seems that it works as expected.


Envelope_Evaluate() is working fine with other scripts of mine. You can try with _Script: X-RaymCopy envelope values at edit cursor and insert at time selection.lua

nofishonfriday commented 6 years ago

But in this scenario, the ReaScript loudness functions should already give the same results, don't they ? At least they seem to do here:

Alt Text

What I meant was when you do something like this:

Alt Text

then

Alt Text

This is a scenario I can't account for I think.

X-Raym commented 6 years ago

@nofishonfriday which SWS do you use ? I use the official v2.9.8.0.

Ok I notice something weird.

It does seems to works post env and post fades.... But only if item pos is 0.

Look

Can you confirm ?

nofishonfriday commented 6 years ago

Interesting find ! Thanks. When going to true peak from SWS/BR: Analyze loudness... directly it shows the exact same behaviour when item has vol env - only correct if item pos is 0. Looks like bug hunting, sigh...

X-Raym commented 6 years ago

@nofishonfriday If you dont want to bug hunt, just put the item at pos 0 within the function and restore to init pos after analyses :P

That would be a dirty solution though.

nofishonfriday commented 6 years ago

Haha good one. I'm trying to be not this dirty though, if there's another way. :D

X-Raym commented 6 years ago

@nofishonfriday Yes :P the SWS source code shoulf be logical for third party devs and not full of dirty reaper specific hacks ^^ else, it will be quite hard to handle for newcomers :P

nofishonfriday commented 6 years ago

Seems I found the issue: https://forum.cockos.com/showthread.php?t=129415

Actually a Reaper bug I'd think, created a BR: https://forum.cockos.com/showthread.php?t=204397

Let's see what comes out of it, could maybe also worked around it in SWS if it doesn't get fixed (or not classified as bug).

edit: Ok, schwa has spoken no bug. :D Then hopefully finding a way to fix in SWS.

nofishonfriday commented 6 years ago

May have it fixed, please test: https://www.dropbox.com/s/haynxbr2w8tx20x/reaper_sws64_LoudnessVsTakeEnvFix01.dll?dl=1

I couldn't make it fail so far with complex take vol. env's also if item pos not 0.0. Seems also work correctly if a take start offset set. Maybe fails if stretch markers involved, but couldn't do anything in this case anyway...

X-Raym commented 6 years ago

@nofishonfriday Nice !

truePeakPos, shortTermMaxPos, momentaryMaxPos doesn't seems to be consistent (some are relative, some are absolute).

(also, NF_GetMediaItemMaxPeakAndMaxPos() is absolute now ?)

nofishonfriday commented 6 years ago

You're right, currently TPpos: relative, shortTermMaxPos, momentaryMaxPos: absolute. When I started doing these functions I admit I didn't check and just returned what these functions returned internally (clearly a lack of coding experience!). I know it's not ideal, but I tend to leaving it this way (for not breaking existing scripts, mine for example :D) and put a note about it in the ReaScript doc.

NF_GetMediaItemMaxPeakAndMaxPos() should still be realtive though, it's here at least, could you recheck pls ?

Btw., the bug was quite hard to find (for me anyway), the crucial key was your observation working correctly if item pos = 0.0, so thanks for this again. :)

X-Raym commented 6 years ago

@nofishonfriday Oh sorry for NF_GetMediaItemMaxPeakAndMaxPos() , my bad, it do works as expected.

Ok for not breaking compatibility with previous scripts and for update in the doc. but maybe in this case TPpos should be absolute too ? At least it would be consistent within this function.

nofishonfriday commented 6 years ago

I follow the thought but it would be the same problem with potentially breaking existing scripts as it's been relative from the beginning (as you stated) so I think I'd rather leave it like this and try to do better next time. :)

X-Raym commented 6 years ago

@nofishonfriday backward compatibility is more important that consitency. And it is not as if the fix was hard to fix on the script side :P

At least the post fades and envelopes is fixed now :P The pull request can be proposed and the issue closed. At least the post fades

nofishonfriday commented 6 years ago

Pull request coming shortly... :) Post takes vol. envelopes yes, but are you sure it takes item fades also into account ? According to the Signal flow it doesn't (we're using the Take analysis with the ReaScript functions) and in my test so far it also seems it doesn't, or did you observe otherwise ? Anyway, that's also something I couldn't account for anyway...

X-Raym commented 6 years ago

@nofishonfriday You are right.

I think I'm starting to be confused by all these subtleties :P It definitely deserves to be in the doc for clarity.

(that said, GetMediaItemMaxPeakAndMaxPeakPos being post fades, it may be possible at some point to make a Loudness function which take cares of fades. But maybe another day... 😸 )

nofishonfriday commented 6 years ago

Thanks for confirming. I've now linked to the Signal flow chart for the ReaScript Loudness functions so it should make it clear.