<div dir="ltr"><div>Your design is way too simple and fundamentally wrong.<br><br></div>If you want low latency you need to use a pull model (aka callback model) for audio i/o to the device. Let the device tell you when it wants audio data, and deliver it,on time, without blocking (which means no on-demand file i/o in the same thread as the device audio i/o). See <a href="http://www.rossbencina.com/code/real-time-audio-programming-101-time-waits-for-nothing">http://www.rossbencina.com/code/real-time-audio-programming-101-time-waits-for-nothing</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 17, 2016 at 4:26 AM, David Griffith <span dir="ltr"><<a href="mailto:dave@661.org" target="_blank">dave@661.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, 17 May 2016, Andrea Del Signore wrote:<br>
<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
On Tue, May 17, 2016 at 12:25 AM, David Griffith <<a href="mailto:dave@661.org" target="_blank">dave@661.org</a>> wrote:<br>
On Mon, 16 May 2016, Andrea Del Signore wrote:<br>
<br></span><span class="">
> I'm not simply trying to mix two files.  My main project is a<br>
> game engine in which two sounds are allowed at any one time. <br>
> For instance, there can be constant background music punctuated<br>
> by sound effects.  I can't get these to mix correctly.<br>
<br>
Hi,<br>
<br>
in that case you can just skip the right number of frames before starting<br>
playing sounds.<br>
<br>
I modified my code to take the start time for each file and schedule the<br>
play time with frame accuracy.<br>
<br>
<a href="http://pastebin.com/0PMyfPvK" rel="noreferrer" target="_blank">http://pastebin.com/0PMyfPvK</a><br>
<br>
If you want your timing to be sample accurate the algorithm is a bit more<br>
complex.<br>
</span></blockquote>
<br>
That won't work.  Your code schedules things ahead of time before anything else happens.  I need to be able to fire off sound effects the instant the player does something to cause them.  I can't know in advance.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
David Griffith<br>
<a href="mailto:dave@661.org" target="_blank">dave@661.org</a></font></span><br>_______________________________________________<br>
Linux-audio-dev mailing list<br>
<a href="mailto:Linux-audio-dev@lists.linuxaudio.org">Linux-audio-dev@lists.linuxaudio.org</a><br>
<a href="http://lists.linuxaudio.org/listinfo/linux-audio-dev" rel="noreferrer" target="_blank">http://lists.linuxaudio.org/listinfo/linux-audio-dev</a><br>
<br></blockquote></div><br></div>