How long is a project?

Share your Audacity/Nyquist plug-ins here, or test drive the latest plug-ins submitted by Audacity users.

After testing a plug-in from this forum, please post feedback for the plug-in author.
Post Reply
Corvinus
Posts: 13
Joined: Sat Jul 03, 2010 7:09 pm
Operating System: Please select

How long is a project?

Post by Corvinus » Tue Mar 09, 2021 3:37 pm

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:

Code: Select all

(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?

steve
Site Admin
Posts: 81227
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How long is a project?

Post by steve » Tue Mar 09, 2021 3:55 pm

Corvinus wrote:
Tue Mar 09, 2021 3:37 pm
So, is there a way to get the correct project length?
If it's a "process" or "analyze" type plug-in:

Code: Select all

(print (/ len *sound-srate*))
Corvinus wrote:
Tue Mar 09, 2021 3:37 pm
The issue is that this returns an approximate, rather than exact, value.
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.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Corvinus
Posts: 13
Joined: Sat Jul 03, 2010 7:09 pm
Operating System: Please select

Re: How long is a project?

Post by Corvinus » Tue Mar 09, 2021 4:25 pm

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

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

Code: Select all

(- (get '*selection*' end) cur-tracks-end)
returns the value 0.001882.

Could you point me to where to request an enhancement? Is it viewforum.php?f=50 ?

steve
Site Admin
Posts: 81227
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How long is a project?

Post by steve » Tue Mar 09, 2021 7:26 pm

Corvinus wrote:
Tue Mar 09, 2021 4:25 pm
Just to be clear, the loss of accuracy comes from the *TRACKS* properties.
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:

Code: Select all

(format nil "~a" (aud-get-info "tracks"))
You can also run "GetInfo: Type=Tracks" directly from "Extra menu > Scriptables II > GetInfo"
(https://manual.audacityteam.org/man/extra_menu.html)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81227
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How long is a project?

Post by steve » Tue Mar 09, 2021 7:31 pm

Corvinus wrote:
Tue Mar 09, 2021 4:25 pm
Could you point me to where to request an enhancement?
Normally here: viewforum.php?f=20
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.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Corvinus
Posts: 13
Joined: Sat Jul 03, 2010 7:09 pm
Operating System: Please select

Re: How long is a project?

Post by Corvinus » Tue Mar 09, 2021 7:44 pm

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

Corvinus
Posts: 13
Joined: Sat Jul 03, 2010 7:09 pm
Operating System: Please select

Re: How long is a project?

Post by Corvinus » Wed Mar 10, 2021 11:34 am

steve wrote:
Tue Mar 09, 2021 7:26 pm
If you run this code on a long track, you will see that there's nowhere near enough decimal places for sample accuracy:

Code: Select all

(format nil "~a" (aud-get-info "tracks"))
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:

Code: Select all

(setq *float-format* "%f")
(format nil "~a" (aud-get-info "tracks"))
It just struck me now that it's "just" :P a matter of replicating what's done with the selection properties, as this retains the proper precision.

steve
Site Admin
Posts: 81227
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: How long is a project?

Post by steve » Wed Mar 10, 2021 2:10 pm

Corvinus wrote:
Wed Mar 10, 2021 11:34 am
It comes from the fact that get-info returns a truncated value
Yes. The value is rounded before it gets to Nyquist.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Post Reply