Old 07-14-2019, 09:48 PM   #1
Human being with feelings
dsyrock's Avatar
Join Date: Sep 2018
Location: China
Posts: 150
Default Question about item's length and source length

Here is a simple reaper project that has only an item. I already set it to media source start and end. So the item's length and source length of it are suppose to be equal, right?

But I ran this script to check:

it=reaper.GetMediaItem(0, 0)


length=reaper.GetMediaItemInfo_Value(it, "D_LENGTH")





and I got this result:

So why doesn't length-orilen equal to zero, but a number that is clse to zero?
Attached Files
File Type: zip test.zip (338.9 KB, 4 views)
dsyrock is offline   Reply With Quote
Old 07-15-2019, 04:40 AM   #2
Human being with feelings
X-Raym's Avatar
Join Date: Apr 2013
Location: France
Posts: 5,919

Seems there is some roubding issue, maybe from a sample or sub sample value. Not sure why.
X-Raym is offline   Reply With Quote
Old 07-19-2019, 02:52 AM   #3
Human being with feelings
Join Date: Jul 2009
Posts: 2,659

Check out this thread: GetMediaItemInfo_Value API does not return the real values.

* REAPER's IDE and ShowConsoleMsg don't display floating point numbers to their full precision, so numbers may seem equal even if they are not.

* 4.4408920985006e-016 is close to the limits of the previous two numbers' 64-bit float precision, so this is probably just normal floating point errors, not sample rounding.

* Floating point numbers should never be compared directly for equality. Instead, compare their difference to a tiny cutoff value such as 1e-14 (or whatever is about 14 decimals smaller than your expected value range).

Last edited by juliansader; 07-19-2019 at 03:30 AM.
juliansader is offline   Reply With Quote

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 08:01 AM.

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