Where in code the length of current track can be found?

Audio software developers forum.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Post Reply
jerome42
Posts: 60
Joined: Fri Jan 11, 2013 9:20 am
Operating System: Please select

Where in code the length of current track can be found?

Post by jerome42 » Wed Jan 23, 2013 9:34 pm

In SelectionBar.cpp I need the length of the current track, thus the 'Audio Position' resulting from the 'Skip to End' knob being pressed.
Where can I find that info and how can I make that info available in the SelectionBar class?

Thanks for any suggestions!
jerome42

Edgar
Forum Crew
Posts: 2043
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: Where in code the length of current track can be found?

Post by Edgar » Thu Jan 24, 2013 4:53 am

Look for a variable:
t1
t0 is the beginning of the selection and t1 is the end of the selection; if the entire track is selected then
t0 = 0
(time zero) and
t1 = ( the timestamp of the final sample)

jerome42
Posts: 60
Joined: Fri Jan 11, 2013 9:20 am
Operating System: Please select

Re: Where in code the length of current track can be found?

Post by jerome42 » Thu Jan 24, 2013 10:25 am

Thanks Edgar for showing me the way to this code fragment which I could copy to and use in SelectionBar.cpp without any compiler problems:

Code: Select all

         AudacityProject *p = GetActiveProject();
         if (p)
         {
            p->SkipEnd(true);
            double playRegionStart, playRegionEnd;
            p->GetPlayRegion(&playRegionStart, &playRegionEnd);
         }
The extra p->SkipEnd(true) line brought me the correct value for playRegionEnd;
Regards, jerome42

Post Reply