How long is a project?

Hello,

I need to get the end of a PROJECT. It doesn’t appear there is a simple answer. Instead, I calculate if from the end of the project tracks, which is not too complicated:

(setf proj-tracks (aud-get-info "tracks"))
(defun track-end (track-property)
	(setf end-time (cadr (assoc 'end track-property)))
	(if (null end-time) 0 end-time))
(setf cur-tracks-end (apply 'max (mapcar 'track-end proj-tracks)))

The issue is that this returns an approximate, rather than exact, value.
My current project is 1h15m32s0228samples long. The valuer returned by the code above is 4532.050000. That’s not right.

The value returned by selecting everything and getting the selection end [get ‘selection’ end] is 4532.051882, which is correct.

So, is there a way to get the correct project length?

If it’s a “process” or “analyze” type plug-in:

(print (/ len *sound-srate*))



Perhaps we should be requesting an enhancement - more accuracy.
Audacity is certainly capable of providing greater accuracy, but I guess that the value is being rounded for display purposes.

It’s neither. It’s a follow-up to this (despite the radio silence, I am working on it, but at my own pace :blush: ).

Just to be clear, the loss of accuracy comes from the TRACKS properties. The snippet

(- (get '*selection*' end) cur-tracks-end)

returns the value 0.001882.

Could you point me to where to request an enhancement? Is it https://forum.audacityteam.org/viewforum.php?f=50 ?

I think it comes from “GetInfo: Type=Tracks”, which is called by (aud-get-info “tracks”)

If you run this code on a long track, you will see that there’s nowhere near enough decimal places for sample accuracy:

(format nil "~a" (aud-get-info "tracks"))

You can also run “GetInfo: Type=Tracks” directly from “Extra menu > Scriptables II > GetInfo”
(Extra Menu - Audacity Manual)

Normally here: Adding Features - Audacity Forum
but I need to talk to the main developer of Audacity’s scripting about something else, so I’ll speak to him about this directly.

Thanks. I’ll put the request on hold then. No point raising it myself if you do.

True. The problem doesn’t come from the lack of space in the representation by the format function. It comes from the fact that get-info returns a truncated value. It’s quite clear with the slightly amended code:

(setq *float-format* "%f")
(format nil "~a" (aud-get-info "tracks"))

It just struck me now that it’s “just” :stuck_out_tongue: a matter of replicating what’s done with the selection properties, as this retains the proper precision.

Yes. The value is rounded before it gets to Nyquist.