Get sample number while recording

Audio software developers forum.

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

Get sample number while recording

Permanent link to this post Posted by bzb » Sat Nov 21, 2015 11:27 am

Hi,

I am trying to create a logfile that is being created while Audacity is recording - I need this logfile log:
1. current CLOCK_MONOTONIC.
2. current sample number being recorded.

Currently I managed to get a logging function to run on a separate thread (while recording audio) and log CLOCK_MONOTONIC at almost constant time intervals (good enough for what I need) - how, if at all, can I add to this log the number of the audio sample that is being recorded at that time?

Thanks
bzb
 
Posts: 10
Joined: Fri Oct 23, 2015 2:27 pm
Operating System: Please select

Re: Get sample number while recording

Permanent link to this post Posted by steve » Sat Nov 21, 2015 12:07 pm

What do you mean by "current sample number"? Do you mean you want to count the samples from the start of the recording, or do you mean that you want the sample value?
What's the job? What are you trying to do?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44687
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Get sample number while recording

Permanent link to this post Posted by bzb » Sat Nov 21, 2015 12:21 pm

Hi Steve,

by "current sample number" I mean the count of the samples from the start of the recording.

I have data from a second machine, that I need to synchronize with the data recorded by audacity.
the reason I need CLOCK_MONOTIONIC is that the way this is done is by performing a synchronization based on the CLOCK_MONOTIONIC and a series of synchronization signals being sent from the pc to that other machine.
bzb
 
Posts: 10
Joined: Fri Oct 23, 2015 2:27 pm
Operating System: Please select

Re: Get sample number while recording

Permanent link to this post Posted by steve » Sat Nov 21, 2015 12:58 pm

Perhaps you could use Pa_GetStreamTime http://portaudio.com/docs/v19-doxydocs/ ... rview.html
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44687
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Get sample number while recording

Permanent link to this post Posted by waxcylinder » Sat Nov 21, 2015 5:54 pm

Go to the Audio Selection Toolbar (normally at the bottom of the screen) and change your time format to "Samples" in one of the three drop-down menus.

See this page in the Audacity Manual: http://manual.audacityteam.org/o/man/se ... olbar.html

WC
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * FAQ * * * * * Tutorials * * * * * Audacity Manual * * * * * Audacity Wiki * * * * *
waxcylinder
Forum Staff
 
Posts: 8975
Joined: Tue Jul 31, 2007 11:03 am
Location: Manchester, UK
Operating System: Windows 10

Re: Get sample number while recording

Permanent link to this post Posted by bzb » Tue Nov 24, 2015 3:03 pm

Thanks for your replies.

waxcylinder - I am trying to log the computer's clock with the time since recording began in real time, so I need it while the recording is ongoing.


See update below!
steve (or anyone else who might know) - I am having trouble with Pa_GetStreamTime.
I am passing PaStream *mPortStreamV19; (I have changed this PaStream pointer to be public) to my logger function and called Pa_GetStreamTime on it - but although the perror is "success" I keep getting a result of 0.

any idea what I could be doing wrong? am I missing something major here? is the active stream not mPortStreamV19?

Thanks!

UPDATE:
Apparently, this is a known issue with portaudio - Pa_GetStreamTime() is malfunctioning on some systems.
http://osdir.com/ml/audio.portaudio.devel/2004-09/msg00043.html

Anybody has an idea on how to get the time since beginning of recording in another way? and I need to have a maximum of 1 millisecond inaccuracy.

Thanks again!
bzb
 
Posts: 10
Joined: Fri Oct 23, 2015 2:27 pm
Operating System: Please select

Re: Get sample number while recording

Permanent link to this post Posted by bzb » Fri Dec 04, 2015 11:53 pm

Can somebody please direct me to the function that copies the last recorded frame into the file? I need to get a timestamp of that event

thanks
bzb
 
Posts: 10
Joined: Fri Oct 23, 2015 2:27 pm
Operating System: Please select

Re: Get sample number while recording

Permanent link to this post Posted by steve » Sat Dec 05, 2015 12:33 pm

Audacity writes "blocks" rather than "frames".
This is really a user forum rather than a developers forum, so I doubt that anyone here knows all of the code, but I'd suggest that you start looking in AudioIO.cpp and BlockFile.cpp.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44687
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Get sample number while recording

Permanent link to this post Posted by bzb » Sun Dec 06, 2015 5:16 pm

Thanks steve!

should I try the 'compiling audacity' forum? if so - can you move this thread there or should I just post a new one there?
bzb
 
Posts: 10
Joined: Fri Oct 23, 2015 2:27 pm
Operating System: Please select

Re: Get sample number while recording

Permanent link to this post Posted by steve » Sun Dec 06, 2015 7:40 pm

bzb wrote:should I try the 'compiling audacity' forum?

It is the same small group of volunteers that contribute their time helping other users on all boards of this Audacity forum.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 44687
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu


Return to General Audio Programming



Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests