[LAD] writing a bpm counter with (or without) ALSA

Max Payne tobler_one at hotmail.it
Sat Sep 25 23:08:21 UTC 2010


Hi guys,
first of all forgive my not-so-perfect English :-)
I'm writing down some code for a minimal loop player based on two threads: one handles a beat counter, the other feeds the soundcard with audio frames, through ALSA. When the beat counter has completed a full cycle (e.g. 4/4) it simply rewinds the PCM data to byte 0 making a seamless loop. Really straightforward.
Now, I'm wondering how to implement the metronome side: should I rely on something like usleep/nanosleep or ALSA layer could offer an advanced timer? Another potential issue would come from latency, obviously present within the audio thread (due to ALSA): what happens when the beat counter restarts the audio sample but an alsa frame is still being written to the soundcard?
Thank you in advance for any suggestion! 

Tb 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20100926/4d72a232/attachment.html>


More information about the Linux-audio-dev mailing list