[LAD] mixing while using libao and libsndfile

Andrea Del Signore sejerpz at gmail.com
Tue May 17 20:23:28 UTC 2016

On Tue, 17 May 2016 08:26:17 +0000, David Griffith wrote:

> On Tue, 17 May 2016, Andrea Del Signore wrote:
>> On Tue, May 17, 2016 at 12:25 AM, David Griffith
>> <dave at 661.org> wrote:
>> On Mon, 16 May 2016, Andrea Del Signore wrote:
>> > I'm not simply trying to mix two files.  My main project is a game
>> > engine in which two sounds are allowed at any one time. For instance,
>> > there can be constant background music punctuated by sound effects. 
>> > I can't get these to mix correctly.
>> Hi,
>> in that case you can just skip the right number of frames before
>> starting playing sounds.
>> I modified my code to take the start time for each file and schedule
>> the play time with frame accuracy.
>> http://pastebin.com/0PMyfPvK
>> If you want your timing to be sample accurate the algorithm is a bit
>> more complex.
> 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.


another code iteraction: http://pastebin.com/v8gTWBtJ

This is a basic implementation, there is a lot of things left todo (RT 
safeness as Paul already noted, code cleanup, etc...)


I don't code in C very often, may be this is my first time in 6 or 7 
years. For me this code snippet is just an excuse to do some exercise :)

More information about the Linux-audio-dev mailing list