Get sample number while recording

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

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?

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.

Perhaps you could use Pa_GetStreamTime http://portaudio.com/docs/v19-doxydocs/api_overview.html

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/selection_toolbar.html

WC

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!

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

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.

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?

It is the same small group of volunteers that contribute their time helping other users on all boards of this Audacity forum.