<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hi guys,<br>first of all forgive my not-so-perfect English :-)<br>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 <span class="clickable" onclick='redirectWR(event,"OXenit")'><span class="hg"><span class="hw">straightforward</span>.<span class="pos" title="adjective"></span></span></span><br>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?<br>Thank you in advance for any suggestion! <br><br>Tb<span class="POS2"></span>                                     </body>
</html>